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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_view_mac.mm

Issue 10913243: extensions: Add ExtensionView interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: instantiate android and mac too 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" 7 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h"
8 8
9 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/common/view_type.h" 10 #include "chrome/common/view_type.h"
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 37
38 gfx::NativeView ExtensionViewMac::native_view() { 38 gfx::NativeView ExtensionViewMac::native_view() {
39 return extension_host_->host_contents()->GetView()->GetNativeView(); 39 return extension_host_->host_contents()->GetView()->GetNativeView();
40 } 40 }
41 41
42 content::RenderViewHost* ExtensionViewMac::render_view_host() const { 42 content::RenderViewHost* ExtensionViewMac::render_view_host() const {
43 return extension_host_->render_view_host(); 43 return extension_host_->render_view_host();
44 } 44 }
45 45
46 void ExtensionViewMac::DidStopLoading() {
47 ShowIfCompletelyLoaded();
48 }
49
50 void ExtensionViewMac::SetBackground(const SkBitmap& background) { 46 void ExtensionViewMac::SetBackground(const SkBitmap& background) {
51 if (!pending_background_.empty() && render_view_host()->GetView()) { 47 if (!pending_background_.empty() && render_view_host()->GetView()) {
52 render_view_host()->GetView()->SetBackground(background); 48 render_view_host()->GetView()->SetBackground(background);
53 } else { 49 } else {
54 pending_background_ = background; 50 pending_background_ = background;
55 } 51 }
56 ShowIfCompletelyLoaded(); 52 ShowIfCompletelyLoaded();
57 } 53 }
58 54
55 Browser* ExtensionViewMac::GetBrowser() {
56 return browser_;
57 }
58
59 void ExtensionViewMac::ResizeDueToAutoResize(const gfx::Size& new_size) { 59 void ExtensionViewMac::ResizeDueToAutoResize(const gfx::Size& new_size) {
60 if (container_) 60 if (container_)
61 container_->OnExtensionSizeChanged(this, new_size); 61 container_->OnExtensionSizeChanged(this, new_size);
62 } 62 }
63 63
64 void ExtensionViewMac::RenderViewCreated() { 64 void ExtensionViewMac::RenderViewCreated() {
65 if (!pending_background_.empty() && render_view_host()->GetView()) { 65 if (!pending_background_.empty() && render_view_host()->GetView()) {
66 render_view_host()->GetView()->SetBackground(pending_background_); 66 render_view_host()->GetView()->SetBackground(pending_background_);
67 pending_background_.reset(); 67 pending_background_.reset();
68 } 68 }
69 69
70 chrome::ViewType host_type = extension_host_->extension_host_type(); 70 chrome::ViewType host_type = extension_host_->extension_host_type();
71 if (host_type == chrome::VIEW_TYPE_EXTENSION_POPUP) { 71 if (host_type == chrome::VIEW_TYPE_EXTENSION_POPUP) {
72 gfx::Size min_size(ExtensionViewMac::kMinWidth, 72 gfx::Size min_size(ExtensionViewMac::kMinWidth,
73 ExtensionViewMac::kMinHeight); 73 ExtensionViewMac::kMinHeight);
74 gfx::Size max_size(ExtensionViewMac::kMaxWidth, 74 gfx::Size max_size(ExtensionViewMac::kMaxWidth,
75 ExtensionViewMac::kMaxHeight); 75 ExtensionViewMac::kMaxHeight);
76 render_view_host()->EnableAutoResize(min_size, max_size); 76 render_view_host()->EnableAutoResize(min_size, max_size);
77 } 77 }
78 } 78 }
79 79
80 void ExtensionViewMac::DidStopLoading() {
81 ShowIfCompletelyLoaded();
82 }
83
80 void ExtensionViewMac::WindowFrameChanged() { 84 void ExtensionViewMac::WindowFrameChanged() {
81 if (render_view_host()->GetView()) 85 if (render_view_host()->GetView())
82 render_view_host()->GetView()->WindowFrameChanged(); 86 render_view_host()->GetView()->WindowFrameChanged();
83 } 87 }
84 88
85 void ExtensionViewMac::CreateWidgetHostView() { 89 void ExtensionViewMac::CreateWidgetHostView() {
86 extension_host_->CreateRenderViewSoon(); 90 extension_host_->CreateRenderViewSoon();
87 } 91 }
88 92
89 void ExtensionViewMac::ShowIfCompletelyLoaded() { 93 void ExtensionViewMac::ShowIfCompletelyLoaded() {
90 // We wait to show the ExtensionView until it has loaded, and the view has 94 // We wait to show the ExtensionView until it has loaded, and the view has
91 // actually been created. These can happen in different orders. 95 // actually been created. These can happen in different orders.
92 if (extension_host_->did_stop_loading()) { 96 if (extension_host_->did_stop_loading()) {
93 [native_view() setHidden:NO]; 97 [native_view() setHidden:NO];
94 if (container_) 98 if (container_)
95 container_->OnExtensionViewDidShow(this); 99 container_->OnExtensionViewDidShow(this);
96 } 100 }
97 } 101 }
102
103 // static
104 ExtensionView* ExtensionView::Create(extensions::ExtensionHost* host,
105 Browser* browser) {
106 ExtensionViewMac* extension_view = new ExtensionViewMac(host, browser);
107 extension_view->Init();
108 return extension_view;
109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698