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/views/extensions/extension_view.h" | 5 #include "chrome/browser/ui/views/extensions/extension_view.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
8 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 8 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
9 #include "content/browser/renderer_host/render_view_host.h" | 9 #include "content/browser/renderer_host/render_view_host.h" |
10 #include "content/public/browser/content_browser_client.h" | 10 #include "content/public/browser/content_browser_client.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 return gfx::kNullCursor; | 57 return gfx::kNullCursor; |
58 } | 58 } |
59 | 59 |
60 void ExtensionView::SetVisible(bool is_visible) { | 60 void ExtensionView::SetVisible(bool is_visible) { |
61 if (is_visible != visible()) { | 61 if (is_visible != visible()) { |
62 NativeViewHost::SetVisible(is_visible); | 62 NativeViewHost::SetVisible(is_visible); |
63 | 63 |
64 // Also tell RenderWidgetHostView the new visibility. Despite its name, it | 64 // Also tell RenderWidgetHostView the new visibility. Despite its name, it |
65 // is not part of the View hierarchy and does not know about the change | 65 // is not part of the View hierarchy and does not know about the change |
66 // unless we tell it. | 66 // unless we tell it. |
67 if (render_view_host()->view()) { | 67 if (render_view_host()->GetView()) { |
68 if (is_visible) | 68 if (is_visible) |
69 render_view_host()->view()->Show(); | 69 render_view_host()->GetView()->Show(); |
70 else | 70 else |
71 render_view_host()->view()->Hide(); | 71 render_view_host()->GetView()->Hide(); |
72 } | 72 } |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 void ExtensionView::CreateWidgetHostView() { | 76 void ExtensionView::CreateWidgetHostView() { |
77 DCHECK(!initialized_); | 77 DCHECK(!initialized_); |
78 initialized_ = true; | 78 initialized_ = true; |
79 Attach(host_->host_contents()->GetView()->GetNativeView()); | 79 Attach(host_->host_contents()->GetView()->GetNativeView()); |
80 host_->CreateRenderViewSoon(); | 80 host_->CreateRenderViewSoon(); |
81 SetVisible(false); | 81 SetVisible(false); |
(...skipping 13 matching lines...) Expand all Loading... |
95 | 95 |
96 void ExtensionView::CleanUp() { | 96 void ExtensionView::CleanUp() { |
97 if (!initialized_) | 97 if (!initialized_) |
98 return; | 98 return; |
99 if (native_view()) | 99 if (native_view()) |
100 Detach(); | 100 Detach(); |
101 initialized_ = false; | 101 initialized_ = false; |
102 } | 102 } |
103 | 103 |
104 void ExtensionView::SetBackground(const SkBitmap& background) { | 104 void ExtensionView::SetBackground(const SkBitmap& background) { |
105 if (render_view_host()->IsRenderViewLive() && render_view_host()->view()) { | 105 if (render_view_host()->IsRenderViewLive() && render_view_host()->GetView()) { |
106 render_view_host()->view()->SetBackground(background); | 106 render_view_host()->GetView()->SetBackground(background); |
107 } else { | 107 } else { |
108 pending_background_ = background; | 108 pending_background_ = background; |
109 } | 109 } |
110 ShowIfCompletelyLoaded(); | 110 ShowIfCompletelyLoaded(); |
111 } | 111 } |
112 | 112 |
113 void ExtensionView::UpdatePreferredSize(const gfx::Size& new_size) { | 113 void ExtensionView::UpdatePreferredSize(const gfx::Size& new_size) { |
114 // Don't actually do anything with this information until we have been shown. | 114 // Don't actually do anything with this information until we have been shown. |
115 // Size changes will not be honored by lower layers while we are hidden. | 115 // Size changes will not be honored by lower layers while we are hidden. |
116 if (!visible()) { | 116 if (!visible()) { |
(...skipping 25 matching lines...) Expand all Loading... |
142 // focus to the next focusable view). Also handle Backspace, since otherwise | 142 // focus to the next focusable view). Also handle Backspace, since otherwise |
143 // (on Windows at least), pressing Backspace, when focus is on a text field | 143 // (on Windows at least), pressing Backspace, when focus is on a text field |
144 // within the ExtensionView, will navigate the page back instead of erasing a | 144 // within the ExtensionView, will navigate the page back instead of erasing a |
145 // character. | 145 // character. |
146 return (e.key_code() == ui::VKEY_TAB || e.key_code() == ui::VKEY_BACK); | 146 return (e.key_code() == ui::VKEY_TAB || e.key_code() == ui::VKEY_BACK); |
147 } | 147 } |
148 | 148 |
149 void ExtensionView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 149 void ExtensionView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
150 // Propagate the new size to RenderWidgetHostView. | 150 // Propagate the new size to RenderWidgetHostView. |
151 // We can't send size zero because RenderWidget DCHECKs that. | 151 // We can't send size zero because RenderWidget DCHECKs that. |
152 if (render_view_host()->view() && !bounds().IsEmpty()) { | 152 if (render_view_host()->GetView() && !bounds().IsEmpty()) { |
153 render_view_host()->view()->SetSize(size()); | 153 render_view_host()->GetView()->SetSize(size()); |
154 | 154 |
155 if (container_) | 155 if (container_) |
156 container_->OnViewWasResized(); | 156 container_->OnViewWasResized(); |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 void ExtensionView::RenderViewCreated() { | 160 void ExtensionView::RenderViewCreated() { |
161 if (!pending_background_.empty() && render_view_host()->view()) { | 161 if (!pending_background_.empty() && render_view_host()->GetView()) { |
162 render_view_host()->view()->SetBackground(pending_background_); | 162 render_view_host()->GetView()->SetBackground(pending_background_); |
163 pending_background_.reset(); | 163 pending_background_.reset(); |
164 } | 164 } |
165 | 165 |
166 // Tell the renderer not to draw scroll bars in popups unless the | 166 // Tell the renderer not to draw scroll bars in popups unless the |
167 // popups are at the maximum allowed size. | 167 // popups are at the maximum allowed size. |
168 gfx::Size largest_popup_size(ExtensionPopup::kMaxWidth, | 168 gfx::Size largest_popup_size(ExtensionPopup::kMaxWidth, |
169 ExtensionPopup::kMaxHeight); | 169 ExtensionPopup::kMaxHeight); |
170 host_->DisableScrollbarsForSmallWindows(largest_popup_size); | 170 host_->DisableScrollbarsForSmallWindows(largest_popup_size); |
171 | 171 |
172 if (container_) | 172 if (container_) |
173 container_->OnViewWasResized(); | 173 container_->OnViewWasResized(); |
174 } | 174 } |
OLD | NEW |