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_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" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // static | 23 // static |
24 const char WebView::kViewClassName[] = | 24 const char WebView::kViewClassName[] = |
25 "ui/views/WebView"; | 25 "ui/views/WebView"; |
26 | 26 |
27 //////////////////////////////////////////////////////////////////////////////// | 27 //////////////////////////////////////////////////////////////////////////////// |
28 // WebView, public: | 28 // WebView, public: |
29 | 29 |
30 WebView::WebView(content::BrowserContext* browser_context) | 30 WebView::WebView(content::BrowserContext* browser_context) |
31 : wcv_holder_(new NativeViewHost), | 31 : wcv_holder_(new NativeViewHost), |
32 web_contents_(NULL), | 32 web_contents_(NULL), |
33 browser_context_(browser_context) { | 33 browser_context_(browser_context), |
| 34 allow_accelerators_(false) { |
34 AddChildView(wcv_holder_); | 35 AddChildView(wcv_holder_); |
35 } | 36 } |
36 | 37 |
37 WebView::~WebView() { | 38 WebView::~WebView() { |
38 } | 39 } |
39 | 40 |
40 content::WebContents* WebView::GetWebContents() { | 41 content::WebContents* WebView::GetWebContents() { |
41 CreateWebContentsWithSiteInstance(NULL); | 42 CreateWebContentsWithSiteInstance(NULL); |
42 return web_contents_; | 43 return web_contents_; |
43 } | 44 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 void WebView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 92 void WebView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
92 wcv_holder_->SetSize(bounds().size()); | 93 wcv_holder_->SetSize(bounds().size()); |
93 } | 94 } |
94 | 95 |
95 void WebView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { | 96 void WebView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { |
96 if (is_add) | 97 if (is_add) |
97 AttachWebContents(); | 98 AttachWebContents(); |
98 } | 99 } |
99 | 100 |
100 bool WebView::SkipDefaultKeyEventProcessing(const views::KeyEvent& event) { | 101 bool WebView::SkipDefaultKeyEventProcessing(const views::KeyEvent& event) { |
| 102 if (allow_accelerators_) |
| 103 return FocusManager::IsTabTraversalKeyEvent(event); |
| 104 |
101 // Don't look-up accelerators or tab-traversal if we are showing a non-crashed | 105 // Don't look-up accelerators or tab-traversal if we are showing a non-crashed |
102 // TabContents. | 106 // TabContents. |
103 // We'll first give the page a chance to process the key events. If it does | 107 // We'll first give the page a chance to process the key events. If it does |
104 // not process them, they'll be returned to us and we'll treat them as | 108 // not process them, they'll be returned to us and we'll treat them as |
105 // accelerators then. | 109 // accelerators then. |
106 return web_contents_ && !web_contents_->IsCrashed(); | 110 return web_contents_ && !web_contents_->IsCrashed(); |
107 } | 111 } |
108 | 112 |
109 bool WebView::IsFocusable() const { | 113 bool WebView::IsFocusable() const { |
110 // We need to be focusable when our contents is not a view hierarchy, as | 114 // We need to be focusable when our contents is not a view hierarchy, as |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 if (GetFocusManager()->GetFocusedView() == this) | 222 if (GetFocusManager()->GetFocusedView() == this) |
219 web_contents_->Focus(); | 223 web_contents_->Focus(); |
220 } | 224 } |
221 | 225 |
222 void WebView::WebContentsDestroyed(content::WebContents* web_contents) { | 226 void WebView::WebContentsDestroyed(content::WebContents* web_contents) { |
223 DCHECK(web_contents == web_contents_); | 227 DCHECK(web_contents == web_contents_); |
224 SetWebContents(NULL); | 228 SetWebContents(NULL); |
225 } | 229 } |
226 | 230 |
227 } // namespace views | 231 } // namespace views |
OLD | NEW |