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/cocoa/extensions/extension_view_mac.h" | 5 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
8 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" | 8 #include "chrome/browser/tab_contents/tab_contents_view_mac.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.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 render_view_host()->view()->SetBackground(background); | 50 render_view_host()->view()->SetBackground(background); |
51 } else { | 51 } else { |
52 pending_background_ = background; | 52 pending_background_ = background; |
53 } | 53 } |
54 ShowIfCompletelyLoaded(); | 54 ShowIfCompletelyLoaded(); |
55 } | 55 } |
56 | 56 |
57 void ExtensionViewMac::UpdatePreferredSize(const gfx::Size& new_size) { | 57 void ExtensionViewMac::UpdatePreferredSize(const gfx::Size& new_size) { |
58 // When we update the size, our container becomes visible. Stay hidden until | 58 // When we update the size, our container becomes visible. Stay hidden until |
59 // the host is loaded. | 59 // the host is loaded. |
60 if (!extension_host_->did_stop_loading()) { | 60 pending_preferred_size_ = new_size; |
61 pending_preferred_size_ = new_size; | 61 if (!extension_host_->did_stop_loading()) |
62 return; | 62 return; |
63 } | |
64 | 63 |
65 // No need to use CA here, our caller calls us repeatedly to animate the | 64 // No need to use CA here, our caller calls us repeatedly to animate the |
66 // resizing. | 65 // resizing. |
67 NSView* view = native_view(); | 66 NSView* view = native_view(); |
68 NSRect frame = [view frame]; | 67 NSRect frame = [view frame]; |
69 frame.size.width = new_size.width(); | 68 frame.size.width = new_size.width(); |
70 frame.size.height = new_size.height(); | 69 frame.size.height = new_size.height(); |
71 | 70 |
72 // |new_size| is in pixels. Convert to view units. | 71 // |new_size| is in pixels. Convert to view units. |
73 frame.size = [view convertSize:frame.size fromView:nil]; | 72 frame.size = [view convertSize:frame.size fromView:nil]; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 114 } |
116 | 115 |
117 void ExtensionViewMac::ShowIfCompletelyLoaded() { | 116 void ExtensionViewMac::ShowIfCompletelyLoaded() { |
118 // We wait to show the ExtensionView until it has loaded, and the view has | 117 // We wait to show the ExtensionView until it has loaded, and the view has |
119 // actually been created. These can happen in different orders. | 118 // actually been created. These can happen in different orders. |
120 if (extension_host_->did_stop_loading()) { | 119 if (extension_host_->did_stop_loading()) { |
121 [native_view() setHidden:NO]; | 120 [native_view() setHidden:NO]; |
122 UpdatePreferredSize(pending_preferred_size_); | 121 UpdatePreferredSize(pending_preferred_size_); |
123 } | 122 } |
124 } | 123 } |
OLD | NEW |