Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / first_run / first_run_view.cc
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/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/skia/include/core/SkBitmap.h"
14 #include "ui/views/controls/webview/webview.h"
15 #include "url/gurl.h"
16
17 namespace chromeos {
18
19 FirstRunView::FirstRunView()
20     : web_view_(NULL) {
21 }
22
23 void FirstRunView::Init(content::BrowserContext* context) {
24   web_view_ = new views::WebView(context);
25   AddChildView(web_view_);
26   web_view_->LoadInitialURL(GURL(chrome::kChromeUIFirstRunURL));
27
28   content::WebContents* web_contents = web_view_->web_contents();
29   web_contents->SetDelegate(this);
30   extensions::ExtensionWebContentsObserver::CreateForWebContents(web_contents);
31
32   SkBitmap background;
33   background.setConfig(SkBitmap::kA8_Config, 1, 1);
34   background.allocPixels();
35   background.eraseARGB(0, 0, 0, 0);
36   web_contents->GetRenderViewHost()->GetView()->
37     SetBackground(background);
38 }
39
40 FirstRunActor* FirstRunView::GetActor() {
41   return static_cast<FirstRunUI*>(
42       web_view_->web_contents()->GetWebUI()->GetController())->get_actor();
43 }
44
45 void FirstRunView::Layout() {
46   web_view_->SetBoundsRect(bounds());
47 }
48
49 void FirstRunView::RequestFocus() {
50   web_view_->RequestFocus();
51 }
52
53 content::WebContents* FirstRunView::GetWebContents() {
54   return web_view_->web_contents();
55 }
56
57 bool FirstRunView::HandleContextMenu(
58     const content::ContextMenuParams& params) {
59   // Discards context menu.
60   return true;
61 }
62
63 }  // namespace chromeos
64