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

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: weak 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 (GetRenderViewHost()->IsRenderViewLive() &&
36 render_view_host()->GetView()->SetBackground(background); 31 GetRenderViewHost()->GetView()) {
32 GetRenderViewHost()->GetView()->SetBackground(background);
37 } else { 33 } else {
38 pending_background_ = background; 34 pending_background_ = background;
39 } 35 }
40 } 36 }
41 37
38 Browser* ExtensionViewGtk::GetBrowser() {
39 return browser_;
40 }
41
42 const Browser* ExtensionViewGtk::GetBrowser() const {
43 return browser_;
44 }
45
46 gfx::NativeView ExtensionViewGtk::GetNativeView() {
47 return extension_host_->host_contents()->GetView()->GetNativeView();
48 }
49
50 content::RenderViewHost* ExtensionViewGtk::GetRenderViewHost() const {
51 return extension_host_->render_view_host();
52 }
53
54 void ExtensionViewGtk::SetContainer(ExtensionViewContainer* container) {
55 container_ = container;
56 }
57
42 void ExtensionViewGtk::ResizeDueToAutoResize(const gfx::Size& new_size) { 58 void ExtensionViewGtk::ResizeDueToAutoResize(const gfx::Size& new_size) {
43 if (container_) 59 if (container_)
44 container_->OnExtensionSizeChanged(this, new_size); 60 container_->OnExtensionSizeChanged(this, new_size);
45 } 61 }
46 62
47 void ExtensionViewGtk::CreateWidgetHostView() {
48 extension_host_->CreateRenderViewSoon();
49 }
50
51 void ExtensionViewGtk::RenderViewCreated() { 63 void ExtensionViewGtk::RenderViewCreated() {
52 if (!pending_background_.empty() && render_view_host()->GetView()) { 64 if (!pending_background_.empty() && GetRenderViewHost()->GetView()) {
53 render_view_host()->GetView()->SetBackground(pending_background_); 65 GetRenderViewHost()->GetView()->SetBackground(pending_background_);
54 pending_background_.reset(); 66 pending_background_.reset();
55 } 67 }
56 68
57 chrome::ViewType host_type = extension_host_->extension_host_type(); 69 chrome::ViewType host_type = extension_host_->extension_host_type();
58 if (host_type == chrome::VIEW_TYPE_EXTENSION_POPUP) { 70 if (host_type == chrome::VIEW_TYPE_EXTENSION_POPUP) {
59 gfx::Size min_size(ExtensionPopupGtk::kMinWidth, 71 gfx::Size min_size(ExtensionPopupGtk::kMinWidth,
60 ExtensionPopupGtk::kMinHeight); 72 ExtensionPopupGtk::kMinHeight);
61 gfx::Size max_size(ExtensionPopupGtk::kMaxWidth, 73 gfx::Size max_size(ExtensionPopupGtk::kMaxWidth,
62 ExtensionPopupGtk::kMaxHeight); 74 ExtensionPopupGtk::kMaxHeight);
63 render_view_host()->EnableAutoResize(min_size, max_size); 75 GetRenderViewHost()->EnableAutoResize(min_size, max_size);
64 } 76 }
65 } 77 }
78
79 void ExtensionViewGtk::DidStopLoading() {
80 NOTIMPLEMENTED();
81 }
82
83 void ExtensionViewGtk::WindowFrameChanged() {
84 NOTIMPLEMENTED();
85 }
86
87 void ExtensionViewGtk::CreateWidgetHostView() {
88 extension_host_->CreateRenderViewSoon();
89 }
90
91 // static
92 ExtensionView* ExtensionView::Create(extensions::ExtensionHost* host,
93 Browser* browser) {
94 ExtensionViewGtk* extension_view = new ExtensionViewGtk(host, browser);
95 extension_view->Init();
96 return extension_view;
97 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/extensions/extension_view_gtk.h ('k') | chrome/browser/ui/gtk/extensions/shell_window_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698