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.
5 #include "chrome/browser/chromeos/first_run/first_run_view.h"
7 #include "chrome/browser/extensions/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"
20 FirstRunView::FirstRunView()
24 void FirstRunView::Init(content::BrowserContext* context) {
25 web_view_ = new views::WebView(context);
26 AddChildView(web_view_);
27 web_view_->LoadInitialURL(GURL(chrome::kChromeUIFirstRunURL));
29 content::WebContents* web_contents = web_view_->web_contents();
30 web_contents->SetDelegate(this);
31 extensions::ExtensionWebContentsObserver::CreateForWebContents(web_contents);
34 background.setConfig(SkBitmap::kA8_Config, 1, 1);
35 background.allocPixels();
36 background.eraseARGB(0, 0, 0, 0);
37 web_contents->GetRenderViewHost()->GetView()->
38 SetBackground(background);
41 FirstRunActor* FirstRunView::GetActor() {
42 return static_cast<FirstRunUI*>(
43 web_view_->web_contents()->GetWebUI()->GetController())->get_actor();
46 void FirstRunView::Layout() {
47 web_view_->SetBoundsRect(bounds());
50 void FirstRunView::RequestFocus() {
51 web_view_->RequestFocus();
54 content::WebContents* FirstRunView::GetWebContents() {
55 return web_view_->web_contents();
58 bool FirstRunView::HandleContextMenu(
59 const content::ContextMenuParams& params) {
60 // Discards context menu.
64 bool FirstRunView::PreHandleGestureEvent(
65 content::WebContents* source,
66 const blink::WebGestureEvent& event) {
67 // Disable pinch zooming.
68 return event.type == blink::WebGestureEvent::GesturePinchBegin ||
69 event.type == blink::WebGestureEvent::GesturePinchUpdate ||
70 event.type == blink::WebGestureEvent::GesturePinchEnd;
73 } // namespace chromeos