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

Side by Side Diff: chrome/browser/ui/gtk/extensions/extension_view_gtk.cc

Issue 10913243: extensions: Add ExtensionView interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: virtual dtor for cocoa and gtk ports Created 8 years, 3 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/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 "chrome/common/view_type.h" 9 #include "chrome/common/view_type.h"
10 #include "content/public/browser/render_view_host.h" 10 #include "content/public/browser/render_view_host.h"
11 #include "content/public/browser/render_widget_host_view.h" 11 #include "content/public/browser/render_widget_host_view.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "content/public/browser/web_contents_view.h" 13 #include "content/public/browser/web_contents_view.h"
14 14
15 ExtensionViewGtk::ExtensionViewGtk(extensions::ExtensionHost* extension_host, 15 ExtensionViewGtk::ExtensionViewGtk(extensions::ExtensionHost* extension_host,
16 Browser* browser) 16 Browser* browser)
17 : browser_(browser), 17 : browser_(browser),
18 extension_host_(extension_host), 18 extension_host_(extension_host),
19 container_(NULL) { 19 container_(NULL) {
20 } 20 }
21 21
22 ExtensionViewGtk::~ExtensionViewGtk() {
23 }
24
22 void ExtensionViewGtk::Init() { 25 void ExtensionViewGtk::Init() {
23 CreateWidgetHostView(); 26 CreateWidgetHostView();
24 } 27 }
25 28
26 gfx::NativeView ExtensionViewGtk::native_view() {
27 return extension_host_->host_contents()->GetView()->GetNativeView();
28 }
29
30 content::RenderViewHost* ExtensionViewGtk::render_view_host() const {
31 return extension_host_->render_view_host();
32 }
33
34 void ExtensionViewGtk::SetBackground(const SkBitmap& background) { 29 void ExtensionViewGtk::SetBackground(const SkBitmap& background) {
35 if (render_view_host()->IsRenderViewLive() && render_view_host()->GetView()) { 30 if (render_view_host()->IsRenderViewLive() && render_view_host()->GetView()) {
36 render_view_host()->GetView()->SetBackground(background); 31 render_view_host()->GetView()->SetBackground(background);
37 } else { 32 } else {
38 pending_background_ = background; 33 pending_background_ = background;
39 } 34 }
40 } 35 }
41 36
37 Browser* ExtensionViewGtk::GetBrowser() {
38 return browser_;
39 }
40
41 const Browser* ExtensionViewGtk::GetBrowser() const {
42 return browser_;
43 }
44
45 gfx::NativeView ExtensionViewGtk::GetNativeView() {
46 return extension_host_->host_contents()->GetView()->GetNativeView();
47 }
48
49 void ExtensionViewGtk::SetContainer(ExtensionViewContainer* container) {
50 container_ = container;
51 }
52
42 void ExtensionViewGtk::ResizeDueToAutoResize(const gfx::Size& new_size) { 53 void ExtensionViewGtk::ResizeDueToAutoResize(const gfx::Size& new_size) {
43 if (container_) 54 if (container_)
44 container_->OnExtensionSizeChanged(this, new_size); 55 container_->OnExtensionSizeChanged(this, new_size);
45 } 56 }
46 57
47 void ExtensionViewGtk::CreateWidgetHostView() {
48 extension_host_->CreateRenderViewSoon();
49 }
50
51 void ExtensionViewGtk::RenderViewCreated() { 58 void ExtensionViewGtk::RenderViewCreated() {
52 if (!pending_background_.empty() && render_view_host()->GetView()) { 59 if (!pending_background_.empty() && render_view_host()->GetView()) {
53 render_view_host()->GetView()->SetBackground(pending_background_); 60 render_view_host()->GetView()->SetBackground(pending_background_);
54 pending_background_.reset(); 61 pending_background_.reset();
55 } 62 }
56 63
57 chrome::ViewType host_type = extension_host_->extension_host_type(); 64 chrome::ViewType host_type = extension_host_->extension_host_type();
58 if (host_type == chrome::VIEW_TYPE_EXTENSION_POPUP) { 65 if (host_type == chrome::VIEW_TYPE_EXTENSION_POPUP) {
59 gfx::Size min_size(ExtensionPopupGtk::kMinWidth, 66 gfx::Size min_size(ExtensionPopupGtk::kMinWidth,
60 ExtensionPopupGtk::kMinHeight); 67 ExtensionPopupGtk::kMinHeight);
61 gfx::Size max_size(ExtensionPopupGtk::kMaxWidth, 68 gfx::Size max_size(ExtensionPopupGtk::kMaxWidth,
62 ExtensionPopupGtk::kMaxHeight); 69 ExtensionPopupGtk::kMaxHeight);
63 render_view_host()->EnableAutoResize(min_size, max_size); 70 render_view_host()->EnableAutoResize(min_size, max_size);
64 } 71 }
65 } 72 }
73
74 void ExtensionViewGtk::DidStopLoading() {
75 NOTIMPLEMENTED();
76 }
77
78 void ExtensionViewGtk::CreateWidgetHostView() {
79 extension_host_->CreateRenderViewSoon();
80 }
81
82 content::RenderViewHost* ExtensionViewGtk::render_view_host() const {
83 return extension_host_->render_view_host();
84 }
85
86 // static
87 ExtensionView* ExtensionView::Create(extensions::ExtensionHost* host,
88 Browser* browser) {
89 ExtensionViewGtk* extension_view = new ExtensionViewGtk(host, browser);
90 extension_view->Init();
91 return extension_view;
92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698