1// Copyright 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "chrome/browser/chromeos/first_run/first_run_view.h" 6 7#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" 8#include "chrome/browser/ui/webui/chromeos/first_run/first_run_ui.h" 9#include "chrome/common/url_constants.h" 10#include "content/public/browser/render_view_host.h" 11#include "content/public/browser/render_widget_host_view.h" 12#include "content/public/browser/web_contents.h" 13#include "third_party/WebKit/public/web/WebInputEvent.h" 14#include "third_party/skia/include/core/SkBitmap.h" 15#include "ui/views/controls/webview/webview.h" 16#include "url/gurl.h" 17 18namespace chromeos { 19 20FirstRunView::FirstRunView() 21 : web_view_(NULL) { 22} 23 24void FirstRunView::Init(content::BrowserContext* context) { 25 web_view_ = new views::WebView(context); 26 AddChildView(web_view_); 27 web_view_->LoadInitialURL(GURL(chrome::kChromeUIFirstRunURL)); 28 29 content::WebContents* web_contents = web_view_->web_contents(); 30 web_contents->SetDelegate(this); 31 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( 32 web_contents); 33 34 web_contents->GetRenderViewHost()->GetView()->SetBackgroundOpaque(false); 35} 36 37FirstRunActor* FirstRunView::GetActor() { 38 return static_cast<FirstRunUI*>( 39 web_view_->web_contents()->GetWebUI()->GetController())->get_actor(); 40} 41 42void FirstRunView::Layout() { 43 web_view_->SetBoundsRect(bounds()); 44} 45 46void FirstRunView::RequestFocus() { 47 web_view_->RequestFocus(); 48} 49 50content::WebContents* FirstRunView::GetWebContents() { 51 return web_view_->web_contents(); 52} 53 54bool FirstRunView::HandleContextMenu( 55 const content::ContextMenuParams& params) { 56 // Discards context menu. 57 return true; 58} 59 60bool FirstRunView::PreHandleGestureEvent( 61 content::WebContents* source, 62 const blink::WebGestureEvent& event) { 63 // Disable pinch zooming. 64 return event.type == blink::WebGestureEvent::GesturePinchBegin || 65 event.type == blink::WebGestureEvent::GesturePinchUpdate || 66 event.type == blink::WebGestureEvent::GesturePinchEnd; 67} 68 69} // namespace chromeos 70 71