OLD | NEW |
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/gtk/extensions/extension_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
8 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" | 8 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.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_gtk.h" |
11 #include "content/browser/tab_contents/tab_contents.h" | |
12 #include "content/browser/tab_contents/tab_contents_view.h" | |
13 | 11 |
14 ExtensionViewGtk::ExtensionViewGtk(ExtensionHost* extension_host, | 12 ExtensionViewGtk::ExtensionViewGtk(ExtensionHost* extension_host, |
15 Browser* browser) | 13 Browser* browser) |
16 : browser_(browser), | 14 : browser_(browser), |
17 extension_host_(extension_host), | 15 extension_host_(extension_host), |
| 16 render_widget_host_view_(NULL), |
18 container_(NULL) { | 17 container_(NULL) { |
19 } | 18 } |
20 | 19 |
21 void ExtensionViewGtk::Init() { | 20 void ExtensionViewGtk::Init() { |
22 CreateWidgetHostView(); | 21 CreateWidgetHostView(); |
23 } | 22 } |
24 | 23 |
25 gfx::NativeView ExtensionViewGtk::native_view() { | 24 gfx::NativeView ExtensionViewGtk::native_view() { |
26 return extension_host_->host_contents()->view()->GetNativeView(); | 25 return render_widget_host_view_->native_view(); |
27 } | 26 } |
28 | 27 |
29 RenderViewHost* ExtensionViewGtk::render_view_host() const { | 28 RenderViewHost* ExtensionViewGtk::render_view_host() const { |
30 return extension_host_->render_view_host(); | 29 return extension_host_->render_view_host(); |
31 } | 30 } |
32 | 31 |
33 void ExtensionViewGtk::SetBackground(const SkBitmap& background) { | 32 void ExtensionViewGtk::SetBackground(const SkBitmap& background) { |
34 if (render_view_host()->IsRenderViewLive() && render_view_host()->view()) { | 33 if (render_view_host()->IsRenderViewLive()) { |
35 render_view_host()->view()->SetBackground(background); | 34 render_widget_host_view_->SetBackground(background); |
36 } else { | 35 } else { |
37 pending_background_ = background; | 36 pending_background_ = background; |
38 } | 37 } |
39 } | 38 } |
40 | 39 |
41 void ExtensionViewGtk::UpdatePreferredSize(const gfx::Size& new_size) { | 40 void ExtensionViewGtk::UpdatePreferredSize(const gfx::Size& new_size) { |
42 if (container_) | 41 if (container_) |
43 container_->OnExtensionPreferredSizeChanged(this, new_size); | 42 container_->OnExtensionPreferredSizeChanged(this, new_size); |
44 } | 43 } |
45 | 44 |
46 void ExtensionViewGtk::CreateWidgetHostView() { | 45 void ExtensionViewGtk::CreateWidgetHostView() { |
47 extension_host_->CreateRenderViewSoon(); | 46 DCHECK(!render_widget_host_view_); |
| 47 render_widget_host_view_ = new RenderWidgetHostViewGtk(render_view_host()); |
| 48 render_widget_host_view_->InitAsChild(); |
| 49 |
| 50 extension_host_->CreateRenderViewSoon(render_widget_host_view_); |
48 } | 51 } |
49 | 52 |
50 void ExtensionViewGtk::RenderViewCreated() { | 53 void ExtensionViewGtk::RenderViewCreated() { |
51 if (!pending_background_.empty() && render_view_host()->view()) { | 54 if (!pending_background_.empty() && render_view_host()->view()) { |
52 render_view_host()->view()->SetBackground(pending_background_); | 55 render_widget_host_view_->SetBackground(pending_background_); |
53 pending_background_.reset(); | 56 pending_background_.reset(); |
54 } | 57 } |
55 | 58 |
56 // Tell the renderer not to draw scrollbars in popups unless the | 59 // Tell the renderer not to draw scrollbars in popups unless the |
57 // popups are at the maximum allowed size. | 60 // popups are at the maximum allowed size. |
58 gfx::Size largest_popup_size(ExtensionPopupGtk::kMaxWidth, | 61 gfx::Size largest_popup_size(ExtensionPopupGtk::kMaxWidth, |
59 ExtensionPopupGtk::kMaxHeight); | 62 ExtensionPopupGtk::kMaxHeight); |
60 extension_host_->DisableScrollbarsForSmallWindows(largest_popup_size); | 63 extension_host_->DisableScrollbarsForSmallWindows(largest_popup_size); |
61 } | 64 } |
OLD | NEW |