OLD | NEW |
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_accessibility_state.h" | 7 #include "content/public/browser/browser_accessibility_state.h" |
8 #include "content/public/browser/browser_context.h" | 8 #include "content/public/browser/browser_context.h" |
9 #include "content/public/browser/navigation_controller.h" | 9 #include "content/public/browser/navigation_controller.h" |
10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
11 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
12 #include "content/public/browser/render_widget_host_view.h" | 12 #include "content/public/browser/render_widget_host_view.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
14 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
15 #include "ui/accessibility/ax_enums.h" | 15 #include "ui/accessibility/ax_enums.h" |
16 #include "ui/accessibility/ax_view_state.h" | 16 #include "ui/accessibility/ax_view_state.h" |
17 #include "ui/base/ui_base_switches_util.h" | 17 #include "ui/base/ui_base_switches_util.h" |
18 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
| 19 #include "ui/views/accessibility/native_view_accessibility.h" |
19 #include "ui/views/controls/native/native_view_host.h" | 20 #include "ui/views/controls/native/native_view_host.h" |
20 #include "ui/views/focus/focus_manager.h" | 21 #include "ui/views/focus/focus_manager.h" |
21 #include "ui/views/views_delegate.h" | 22 #include "ui/views/views_delegate.h" |
22 | 23 |
23 namespace views { | 24 namespace views { |
24 | 25 |
25 // static | 26 // static |
26 const char WebView::kViewClassName[] = "WebView"; | 27 const char WebView::kViewClassName[] = "WebView"; |
27 | 28 |
28 //////////////////////////////////////////////////////////////////////////////// | 29 //////////////////////////////////////////////////////////////////////////////// |
29 // WebView, public: | 30 // WebView, public: |
30 | 31 |
31 WebView::WebView(content::BrowserContext* browser_context) | 32 WebView::WebView(content::BrowserContext* browser_context) |
32 : holder_(new NativeViewHost()), | 33 : holder_(new NativeViewHost()), |
33 observing_render_process_host_(nullptr), | 34 observing_render_process_host_(nullptr), |
34 embed_fullscreen_widget_mode_enabled_(false), | 35 embed_fullscreen_widget_mode_enabled_(false), |
35 is_embedding_fullscreen_widget_(false), | 36 is_embedding_fullscreen_widget_(false), |
36 browser_context_(browser_context), | 37 browser_context_(browser_context), |
37 allow_accelerators_(false) { | 38 allow_accelerators_(false) { |
38 AddChildView(holder_); // Takes ownership of |holder_|. | 39 AddChildView(holder_); // Takes ownership of |holder_|. |
| 40 NativeViewAccessibility::RegisterWebView(this); |
39 } | 41 } |
40 | 42 |
41 WebView::~WebView() { | 43 WebView::~WebView() { |
42 SetWebContents(NULL); // Make sure all necessary tear-down takes place. | 44 SetWebContents(NULL); // Make sure all necessary tear-down takes place. |
| 45 NativeViewAccessibility::UnregisterWebView(this); |
43 } | 46 } |
44 | 47 |
45 content::WebContents* WebView::GetWebContents() { | 48 content::WebContents* WebView::GetWebContents() { |
46 if (!web_contents()) { | 49 if (!web_contents()) { |
47 wc_owner_.reset(CreateWebContents(browser_context_)); | 50 wc_owner_.reset(CreateWebContents(browser_context_)); |
48 wc_owner_->SetDelegate(this); | 51 wc_owner_->SetDelegate(this); |
49 SetWebContents(wc_owner_.get()); | 52 SetWebContents(wc_owner_.get()); |
50 } | 53 } |
51 return web_contents(); | 54 return web_contents(); |
52 } | 55 } |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 if (!contents) { | 424 if (!contents) { |
422 content::WebContents::CreateParams create_params( | 425 content::WebContents::CreateParams create_params( |
423 browser_context, NULL); | 426 browser_context, NULL); |
424 return content::WebContents::Create(create_params); | 427 return content::WebContents::Create(create_params); |
425 } | 428 } |
426 | 429 |
427 return contents; | 430 return contents; |
428 } | 431 } |
429 | 432 |
430 } // namespace views | 433 } // namespace views |
OLD | NEW |