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 "chrome/browser/ui/views/extensions/extension_view.h" | 5 #include "chrome/browser/ui/views/extensions/extension_view.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
8 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 8 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
9 #include "chrome/common/view_type.h" | 9 #include "chrome/common/view_type.h" |
10 #include "content/public/browser/content_browser_client.h" | 10 #include "content/public/browser/content_browser_client.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 "content/public/browser/web_contents_view.h" | 14 #include "content/public/browser/web_contents_view.h" |
| 15 #include "ui/base/event.h" |
15 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
16 | 17 |
17 ExtensionView::ExtensionView(extensions::ExtensionHost* host, Browser* browser) | 18 ExtensionView::ExtensionView(extensions::ExtensionHost* host, Browser* browser) |
18 : host_(host), | 19 : host_(host), |
19 browser_(browser), | 20 browser_(browser), |
20 initialized_(false), | 21 initialized_(false), |
21 container_(NULL), | 22 container_(NULL), |
22 is_clipped_(false) { | 23 is_clipped_(false) { |
23 host_->set_view(this); | 24 host_->set_view(this); |
24 | 25 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 if (is_add && GetWidget() && !initialized_) | 132 if (is_add && GetWidget() && !initialized_) |
132 CreateWidgetHostView(); | 133 CreateWidgetHostView(); |
133 } | 134 } |
134 | 135 |
135 void ExtensionView::PreferredSizeChanged() { | 136 void ExtensionView::PreferredSizeChanged() { |
136 View::PreferredSizeChanged(); | 137 View::PreferredSizeChanged(); |
137 if (container_) | 138 if (container_) |
138 container_->OnExtensionSizeChanged(this); | 139 container_->OnExtensionSizeChanged(this); |
139 } | 140 } |
140 | 141 |
141 bool ExtensionView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { | 142 bool ExtensionView::SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) { |
142 // Let the tab key event be processed by the renderer (instead of moving the | 143 // Let the tab key event be processed by the renderer (instead of moving the |
143 // focus to the next focusable view). Also handle Backspace, since otherwise | 144 // focus to the next focusable view). Also handle Backspace, since otherwise |
144 // (on Windows at least), pressing Backspace, when focus is on a text field | 145 // (on Windows at least), pressing Backspace, when focus is on a text field |
145 // within the ExtensionView, will navigate the page back instead of erasing a | 146 // within the ExtensionView, will navigate the page back instead of erasing a |
146 // character. | 147 // character. |
147 return (e.key_code() == ui::VKEY_TAB || e.key_code() == ui::VKEY_BACK); | 148 return (e.key_code() == ui::VKEY_TAB || e.key_code() == ui::VKEY_BACK); |
148 } | 149 } |
149 | 150 |
150 void ExtensionView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 151 void ExtensionView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
151 // Propagate the new size to RenderWidgetHostView. | 152 // Propagate the new size to RenderWidgetHostView. |
(...skipping 17 matching lines...) Expand all Loading... |
169 gfx::Size min_size(ExtensionPopup::kMinWidth, | 170 gfx::Size min_size(ExtensionPopup::kMinWidth, |
170 ExtensionPopup::kMinHeight); | 171 ExtensionPopup::kMinHeight); |
171 gfx::Size max_size(ExtensionPopup::kMaxWidth, | 172 gfx::Size max_size(ExtensionPopup::kMaxWidth, |
172 ExtensionPopup::kMaxHeight); | 173 ExtensionPopup::kMaxHeight); |
173 render_view_host()->EnableAutoResize(min_size, max_size); | 174 render_view_host()->EnableAutoResize(min_size, max_size); |
174 } | 175 } |
175 | 176 |
176 if (container_) | 177 if (container_) |
177 container_->OnViewWasResized(); | 178 container_->OnViewWasResized(); |
178 } | 179 } |
OLD | NEW |