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

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

Issue 8520036: Revert 110262 - Have ExtensionHost use TabContents instead of RenderViewHost. Try #2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/renderer_host/render_view_host.h" 9 #include "content/browser/renderer_host/render_view_host.h"
10 #include "content/browser/renderer_host/render_widget_host_view.h" 10 #include "content/browser/renderer_host/render_widget_host_view.h"
11 #include "content/browser/tab_contents/tab_contents.h"
12 #include "content/browser/tab_contents/tab_contents_view.h"
13 #include "content/public/browser/content_browser_client.h" 11 #include "content/public/browser/content_browser_client.h"
14 #include "views/widget/widget.h" 12 #include "views/widget/widget.h"
15 13
14 #if defined(USE_AURA)
15 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
16 #elif defined(TOUCH_UI)
17 #include "chrome/browser/renderer_host/render_widget_host_view_views.h"
18 #elif defined(TOOLKIT_USES_GTK)
19 #include "content/browser/renderer_host/render_widget_host_view_gtk.h"
20 #elif defined(OS_WIN)
21 #include "content/browser/renderer_host/render_widget_host_view_win.h"
22 #endif
23
16 ExtensionView::ExtensionView(ExtensionHost* host, Browser* browser) 24 ExtensionView::ExtensionView(ExtensionHost* host, Browser* browser)
17 : host_(host), 25 : host_(host),
18 browser_(browser), 26 browser_(browser),
19 initialized_(false), 27 initialized_(false),
20 container_(NULL), 28 container_(NULL),
21 is_clipped_(false) { 29 is_clipped_(false) {
22 host_->set_view(this); 30 host_->set_view(this);
23 31
24 // This view needs to be focusable so it can act as the focused view for the 32 // This view needs to be focusable so it can act as the focused view for the
25 // focus manager. This is required to have SkipDefaultKeyEventProcessing 33 // focus manager. This is required to have SkipDefaultKeyEventProcessing
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 render_view_host()->view()->Show(); 77 render_view_host()->view()->Show();
70 else 78 else
71 render_view_host()->view()->Hide(); 79 render_view_host()->view()->Hide();
72 } 80 }
73 } 81 }
74 } 82 }
75 83
76 void ExtensionView::CreateWidgetHostView() { 84 void ExtensionView::CreateWidgetHostView() {
77 DCHECK(!initialized_); 85 DCHECK(!initialized_);
78 initialized_ = true; 86 initialized_ = true;
79 Attach(host_->host_contents()->view()->GetNativeView()); 87 RenderWidgetHostView* view =
80 host_->CreateRenderViewSoon(); 88 content::GetContentClient()->browser()->CreateViewForWidget(
89 render_view_host());
90
91 // TODO(mpcomplete): RWHV needs a cross-platform Init function.
92 #if defined(USE_AURA)
93 static_cast<RenderWidgetHostViewAura*>(view)->InitAsChild();
94 #elif defined(TOUCH_UI)
95 static_cast<RenderWidgetHostViewViews*>(view)->InitAsChild();
96 #elif defined(TOOLKIT_USES_GTK)
97 static_cast<RenderWidgetHostViewGtk*>(view)->InitAsChild();
98 #elif defined(OS_WIN)
99 // Create the HWND. Note:
100 // RenderWidgetHostHWND supports windowed plugins, but if we ever also
101 // wanted to support constrained windows with this, we would need an
102 // additional HWND to parent off of because windowed plugin HWNDs cannot
103 // exist in the same z-order as constrained windows.
104 RenderWidgetHostViewWin* view_win =
105 static_cast<RenderWidgetHostViewWin*>(view);
106 view_win->Create(GetWidget()->GetNativeView());
107 view_win->ShowWindow(SW_SHOW);
108 #else
109 NOTIMPLEMENTED();
110 #endif
111
112 Attach(view->GetNativeView());
113 host_->CreateRenderViewSoon(view);
81 SetVisible(false); 114 SetVisible(false);
82 } 115 }
83 116
84 void ExtensionView::ShowIfCompletelyLoaded() { 117 void ExtensionView::ShowIfCompletelyLoaded() {
85 if (IsVisible() || is_clipped_) 118 if (IsVisible() || is_clipped_)
86 return; 119 return;
87 120
88 // We wait to show the ExtensionView until it has loaded, and the view has 121 // We wait to show the ExtensionView until it has loaded, and the view has
89 // actually been created. These can happen in different orders. 122 // actually been created. These can happen in different orders.
90 if (host_->did_stop_loading()) { 123 if (host_->did_stop_loading()) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return (e.key_code() == ui::VKEY_TAB || e.key_code() == ui::VKEY_BACK); 179 return (e.key_code() == ui::VKEY_TAB || e.key_code() == ui::VKEY_BACK);
147 } 180 }
148 181
149 void ExtensionView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 182 void ExtensionView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
150 // Propagate the new size to RenderWidgetHostView. 183 // Propagate the new size to RenderWidgetHostView.
151 // We can't send size zero because RenderWidget DCHECKs that. 184 // We can't send size zero because RenderWidget DCHECKs that.
152 if (render_view_host()->view() && !bounds().IsEmpty()) 185 if (render_view_host()->view() && !bounds().IsEmpty())
153 render_view_host()->view()->SetSize(size()); 186 render_view_host()->view()->SetSize(size());
154 } 187 }
155 188
189 void ExtensionView::HandleMouseMove() {
190 if (container_)
191 container_->OnExtensionMouseMove(this);
192 }
193
194 void ExtensionView::HandleMouseLeave() {
195 if (container_)
196 container_->OnExtensionMouseLeave(this);
197 }
198
156 void ExtensionView::RenderViewCreated() { 199 void ExtensionView::RenderViewCreated() {
157 if (!pending_background_.empty() && render_view_host()->view()) { 200 if (!pending_background_.empty() && render_view_host()->view()) {
158 render_view_host()->view()->SetBackground(pending_background_); 201 render_view_host()->view()->SetBackground(pending_background_);
159 pending_background_.reset(); 202 pending_background_.reset();
160 } 203 }
161 204
162 // Tell the renderer not to draw scroll bars in popups unless the 205 // Tell the renderer not to draw scroll bars in popups unless the
163 // popups are at the maximum allowed size. 206 // popups are at the maximum allowed size.
164 gfx::Size largest_popup_size(ExtensionPopup::kMaxWidth, 207 gfx::Size largest_popup_size(ExtensionPopup::kMaxWidth,
165 ExtensionPopup::kMaxHeight); 208 ExtensionPopup::kMaxHeight);
166 host_->DisableScrollbarsForSmallWindows(largest_popup_size); 209 host_->DisableScrollbarsForSmallWindows(largest_popup_size);
167 } 210 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_view.h ('k') | content/browser/renderer_host/render_widget_host_view_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698