| OLD | NEW |
| 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/cocoa/extensions/extension_view_mac.h" | 5 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "chrome/browser/extensions/extension_view_host.h" | 10 #include "chrome/browser/extensions/extension_view_host.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 ExtensionViewMac::~ExtensionViewMac() { | 33 ExtensionViewMac::~ExtensionViewMac() { |
| 34 } | 34 } |
| 35 | 35 |
| 36 void ExtensionViewMac::WindowFrameChanged() { | 36 void ExtensionViewMac::WindowFrameChanged() { |
| 37 if (render_view_host()->GetView()) | 37 if (render_view_host()->GetView()) |
| 38 render_view_host()->GetView()->WindowFrameChanged(); | 38 render_view_host()->GetView()->WindowFrameChanged(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void ExtensionViewMac::Init() { | 41 void ExtensionViewMac::CreateWidgetHostViewIn(gfx::NativeView superview) { |
| 42 CreateWidgetHostView(); | 42 [superview addSubview:GetNativeView()]; |
| 43 extension_host_->CreateRenderViewSoon(); |
| 43 } | 44 } |
| 44 | 45 |
| 45 Browser* ExtensionViewMac::GetBrowser() { | 46 Browser* ExtensionViewMac::GetBrowser() { |
| 46 return browser_; | 47 return browser_; |
| 47 } | 48 } |
| 48 | 49 |
| 49 gfx::NativeView ExtensionViewMac::GetNativeView() { | 50 gfx::NativeView ExtensionViewMac::GetNativeView() { |
| 50 return extension_host_->host_contents()->GetNativeView(); | 51 return extension_host_->host_contents()->GetNativeView(); |
| 51 } | 52 } |
| 52 | 53 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 82 } | 83 } |
| 83 | 84 |
| 84 void ExtensionViewMac::DidStopLoading() { | 85 void ExtensionViewMac::DidStopLoading() { |
| 85 ShowIfCompletelyLoaded(); | 86 ShowIfCompletelyLoaded(); |
| 86 } | 87 } |
| 87 | 88 |
| 88 content::RenderViewHost* ExtensionViewMac::render_view_host() const { | 89 content::RenderViewHost* ExtensionViewMac::render_view_host() const { |
| 89 return extension_host_->render_view_host(); | 90 return extension_host_->render_view_host(); |
| 90 } | 91 } |
| 91 | 92 |
| 92 void ExtensionViewMac::CreateWidgetHostView() { | |
| 93 extension_host_->CreateRenderViewSoon(); | |
| 94 } | |
| 95 | |
| 96 void ExtensionViewMac::ShowIfCompletelyLoaded() { | 93 void ExtensionViewMac::ShowIfCompletelyLoaded() { |
| 97 // 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 |
| 98 // actually been created. These can happen in different orders. | 95 // actually been created. These can happen in different orders. |
| 99 if (extension_host_->did_stop_loading()) { | 96 if (extension_host_->did_stop_loading()) { |
| 100 [GetNativeView() setHidden:NO]; | 97 [GetNativeView() setHidden:NO]; |
| 101 if (container_) | 98 if (container_) |
| 102 container_->OnExtensionViewDidShow(this); | 99 container_->OnExtensionViewDidShow(this); |
| 103 } | 100 } |
| 104 } | 101 } |
| 105 | 102 |
| 106 namespace extensions { | 103 namespace extensions { |
| 107 | 104 |
| 108 // static | 105 // static |
| 109 scoped_ptr<ExtensionView> ExtensionViewHost::CreateExtensionView( | 106 scoped_ptr<ExtensionView> ExtensionViewHost::CreateExtensionView( |
| 110 ExtensionViewHost* host, | 107 ExtensionViewHost* host, |
| 111 Browser* browser) { | 108 Browser* browser) { |
| 112 return make_scoped_ptr(new ExtensionViewMac(host, browser)); | 109 return make_scoped_ptr(new ExtensionViewMac(host, browser)); |
| 113 } | 110 } |
| 114 | 111 |
| 115 } // namespace extensions | 112 } // namespace extensions |
| OLD | NEW |