Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: ui/views/controls/webview/webview.cc

Issue 10191010: Re-implement the screensaver to use WebView instead of ExtensionDialogHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ut fix. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/webview/webview.h ('k') | ui/views/test/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/webview/webview.h" 5 #include "ui/views/controls/webview/webview.h"
6 6
7 #include "content/public/browser/browser_context.h" 7 #include "content/public/browser/browser_context.h"
8 #include "content/public/browser/navigation_controller.h" 8 #include "content/public/browser/navigation_controller.h"
9 #include "content/public/browser/notification_details.h" 9 #include "content/public/browser/notification_details.h"
10 #include "content/public/browser/notification_registrar.h" 10 #include "content/public/browser/notification_registrar.h"
11 #include "content/public/browser/notification_source.h" 11 #include "content/public/browser/notification_source.h"
12 #include "content/public/browser/notification_types.h" 12 #include "content/public/browser/notification_types.h"
13 #include "content/public/browser/render_view_host.h" 13 #include "content/public/browser/render_view_host.h"
14 #include "content/public/browser/render_widget_host_view.h" 14 #include "content/public/browser/render_widget_host_view.h"
15 #include "ipc/ipc_message.h" 15 #include "ipc/ipc_message.h"
16 #include "ui/base/accessibility/accessible_view_state.h" 16 #include "ui/base/accessibility/accessible_view_state.h"
17 #include "ui/base/accessibility/accessibility_types.h" 17 #include "ui/base/accessibility/accessibility_types.h"
18 #include "ui/views/controls/native/native_view_host.h" 18 #include "ui/views/controls/native/native_view_host.h"
19 #include "ui/views/focus/focus_manager.h" 19 #include "ui/views/focus/focus_manager.h"
20 #include "ui/views/views_delegate.h"
20 21
21 namespace views { 22 namespace views {
22 23
23 // static 24 // static
24 const char WebView::kViewClassName[] = 25 const char WebView::kViewClassName[] =
25 "ui/views/WebView"; 26 "ui/views/WebView";
26 27
27 //////////////////////////////////////////////////////////////////////////////// 28 ////////////////////////////////////////////////////////////////////////////////
28 // WebView, public: 29 // WebView, public:
29 30
30 WebView::WebView(content::BrowserContext* browser_context) 31 WebView::WebView(content::BrowserContext* browser_context)
31 : wcv_holder_(new NativeViewHost), 32 : wcv_holder_(new NativeViewHost),
32 web_contents_(NULL), 33 web_contents_(NULL),
33 browser_context_(browser_context), 34 browser_context_(browser_context),
34 allow_accelerators_(false) { 35 allow_accelerators_(false) {
35 AddChildView(wcv_holder_); 36 AddChildView(wcv_holder_);
36 } 37 }
37 38
38 WebView::~WebView() { 39 WebView::~WebView() {
39 } 40 }
40 41
41 content::WebContents* WebView::GetWebContents() { 42 content::WebContents* WebView::GetWebContents() {
42 CreateWebContentsWithSiteInstance(NULL); 43 CreateWebContentsWithSiteInstance(NULL);
43 return web_contents_; 44 return web_contents_;
44 } 45 }
45 46
46 void WebView::CreateWebContentsWithSiteInstance( 47 void WebView::CreateWebContentsWithSiteInstance(
47 content::SiteInstance* site_instance) { 48 content::SiteInstance* site_instance) {
48 if (!web_contents_) { 49 if (!web_contents_) {
49 wc_owner_.reset(content::WebContents::Create(browser_context_, 50 wc_owner_.reset(CreateWebContents(browser_context_, site_instance));
50 site_instance,
51 MSG_ROUTING_NONE,
52 NULL,
53 NULL));
54 web_contents_ = wc_owner_.get(); 51 web_contents_ = wc_owner_.get();
55 web_contents_->SetDelegate(this); 52 web_contents_->SetDelegate(this);
56 AttachWebContents(); 53 AttachWebContents();
57 } 54 }
58 } 55 }
59 56
60 void WebView::SetWebContents(content::WebContents* web_contents) { 57 void WebView::SetWebContents(content::WebContents* web_contents) {
61 if (web_contents == web_contents_) 58 if (web_contents == web_contents_)
62 return; 59 return;
63 DetachWebContents(); 60 DetachWebContents();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 content::RenderViewHost* new_host) { 218 content::RenderViewHost* new_host) {
222 if (GetFocusManager()->GetFocusedView() == this) 219 if (GetFocusManager()->GetFocusedView() == this)
223 web_contents_->Focus(); 220 web_contents_->Focus();
224 } 221 }
225 222
226 void WebView::WebContentsDestroyed(content::WebContents* web_contents) { 223 void WebView::WebContentsDestroyed(content::WebContents* web_contents) {
227 DCHECK(web_contents == web_contents_); 224 DCHECK(web_contents == web_contents_);
228 SetWebContents(NULL); 225 SetWebContents(NULL);
229 } 226 }
230 227
228 content::WebContents* WebView::CreateWebContents(
229 content::BrowserContext* browser_context,
230 content::SiteInstance* site_instance) {
231 content::WebContents* contents = NULL;
232 if (ViewsDelegate::views_delegate) {
233 contents = ViewsDelegate::views_delegate->CreateWebContents(
234 browser_context, site_instance);
235 }
236
237 if (!contents) {
238 return content::WebContents::Create(browser_context,
239 site_instance,
240 MSG_ROUTING_NONE,
241 NULL,
242 NULL);
243 }
244
245 return contents;
246 }
247
231 } // namespace views 248 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/webview/webview.h ('k') | ui/views/test/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698