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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_view_views.cc

Issue 363233002: Abstract base 'ExtensionView' to Fix DEPS violation in extension_view_host.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments Created 6 years, 5 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
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 "chrome/browser/ui/views/extensions/extension_view_views.h" 5 #include "chrome/browser/ui/views/extensions/extension_view_views.h"
6 6
7 #include "chrome/browser/extensions/extension_view_host.h"
8 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/views/extensions/extension_popup.h" 9 #include "chrome/browser/ui/views/extensions/extension_popup.h"
8 #include "content/public/browser/content_browser_client.h" 10 #include "content/public/browser/content_browser_client.h"
9 #include "content/public/browser/render_view_host.h" 11 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/render_widget_host_view.h" 12 #include "content/public/browser/render_widget_host_view.h"
11 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
12 #include "extensions/browser/extension_host.h" 14 #include "extensions/browser/extension_host.h"
13 #include "extensions/common/view_type.h" 15 #include "extensions/common/view_type.h"
14 #include "ui/events/event.h" 16 #include "ui/events/event.h"
15 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
16 18
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 return gfx::kNullCursor; 66 return gfx::kNullCursor;
65 } 67 }
66 68
67 void ExtensionViewViews::ViewHierarchyChanged( 69 void ExtensionViewViews::ViewHierarchyChanged(
68 const ViewHierarchyChangedDetails& details) { 70 const ViewHierarchyChangedDetails& details) {
69 NativeViewHost::ViewHierarchyChanged(details); 71 NativeViewHost::ViewHierarchyChanged(details);
70 if (details.is_add && GetWidget() && !initialized_) 72 if (details.is_add && GetWidget() && !initialized_)
71 CreateWidgetHostView(); 73 CreateWidgetHostView();
72 } 74 }
73 75
74 void ExtensionViewViews::DidStopLoading() {
75 ShowIfCompletelyLoaded();
76 }
77
78 void ExtensionViewViews::SetIsClipped(bool is_clipped) { 76 void ExtensionViewViews::SetIsClipped(bool is_clipped) {
79 if (is_clipped_ != is_clipped) { 77 if (is_clipped_ != is_clipped) {
80 is_clipped_ = is_clipped; 78 is_clipped_ = is_clipped;
81 if (visible()) 79 if (visible())
82 ShowIfCompletelyLoaded(); 80 ShowIfCompletelyLoaded();
83 } 81 }
84 } 82 }
85 83
84 void ExtensionViewViews::Init() {
85 // Initialization continues in ViewHierarchyChanged().
86 }
87
88 Browser* ExtensionViewViews::GetBrowser() {
89 return browser_;
90 }
91
92 gfx::NativeView ExtensionViewViews::GetNativeView() {
93 return native_view();
94 }
95
86 void ExtensionViewViews::ResizeDueToAutoResize(const gfx::Size& new_size) { 96 void ExtensionViewViews::ResizeDueToAutoResize(const gfx::Size& new_size) {
87 // Don't actually do anything with this information until we have been shown. 97 // Don't actually do anything with this information until we have been shown.
88 // Size changes will not be honored by lower layers while we are hidden. 98 // Size changes will not be honored by lower layers while we are hidden.
89 if (!visible()) { 99 if (!visible()) {
90 pending_preferred_size_ = new_size; 100 pending_preferred_size_ = new_size;
91 return; 101 return;
92 } 102 }
93 103
94 if (new_size != GetPreferredSize()) 104 if (new_size != GetPreferredSize())
95 SetPreferredSize(new_size); 105 SetPreferredSize(new_size);
96 } 106 }
97 107
98 void ExtensionViewViews::RenderViewCreated() { 108 void ExtensionViewViews::RenderViewCreated() {
99 extensions::ViewType host_type = host_->extension_host_type(); 109 extensions::ViewType host_type = host_->extension_host_type();
100 if (host_type == extensions::VIEW_TYPE_EXTENSION_POPUP) { 110 if (host_type == extensions::VIEW_TYPE_EXTENSION_POPUP) {
101 render_view_host()->EnableAutoResize( 111 render_view_host()->EnableAutoResize(
102 gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight), 112 gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight),
103 gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight)); 113 gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight));
104 } 114 }
105 } 115 }
106 116
107 void ExtensionViewViews::HandleKeyboardEvent( 117 void ExtensionViewViews::HandleKeyboardEvent(
118 content::WebContents* source,
108 const content::NativeWebKeyboardEvent& event) { 119 const content::NativeWebKeyboardEvent& event) {
120 if (browser_) {
121 // Handle lower priority browser shortcuts such as Ctrl-f.
122 browser_->HandleKeyboardEvent(source, event);
123 return;
124 }
125
109 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, 126 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event,
110 GetFocusManager()); 127 GetFocusManager());
111 } 128 }
112 129
130 void ExtensionViewViews::DidStopLoading() {
131 ShowIfCompletelyLoaded();
132 }
133
113 bool ExtensionViewViews::SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) { 134 bool ExtensionViewViews::SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) {
114 // Let the tab key event be processed by the renderer (instead of moving the 135 // Let the tab key event be processed by the renderer (instead of moving the
115 // focus to the next focusable view). Also handle Backspace, since otherwise 136 // focus to the next focusable view). Also handle Backspace, since otherwise
116 // (on Windows at least), pressing Backspace, when focus is on a text field 137 // (on Windows at least), pressing Backspace, when focus is on a text field
117 // within the ExtensionViewViews, will navigate the page back instead of 138 // within the ExtensionViewViews, will navigate the page back instead of
118 // erasing a character. 139 // erasing a character.
119 return (e.key_code() == ui::VKEY_TAB || e.key_code() == ui::VKEY_BACK); 140 return (e.key_code() == ui::VKEY_TAB || e.key_code() == ui::VKEY_BACK);
120 } 141 }
121 142
122 void ExtensionViewViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { 143 void ExtensionViewViews::OnBoundsChanged(const gfx::Rect& previous_bounds) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 177 }
157 } 178 }
158 179
159 void ExtensionViewViews::CleanUp() { 180 void ExtensionViewViews::CleanUp() {
160 if (!initialized_) 181 if (!initialized_)
161 return; 182 return;
162 if (native_view()) 183 if (native_view())
163 Detach(); 184 Detach();
164 initialized_ = false; 185 initialized_ = false;
165 } 186 }
187
188 namespace extensions {
189
190 // static
191 scoped_ptr<ExtensionView> ExtensionViewHost::CreateExtensionView(
192 ExtensionViewHost* host,
193 Browser* browser) {
194 scoped_ptr<ExtensionViewViews> view(new ExtensionViewViews(host, browser));
195 // We own |view_|, so don't auto delete when it's removed from the view
196 // hierarchy.
197 view->set_owned_by_client();
198 return view.PassAs<ExtensionView>();
199 }
200
201 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698