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/views/extensions/extension_popup.h" | 5 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "chrome/browser/debugger/devtools_manager.h" | 9 #include "chrome/browser/debugger/devtools_manager.h" |
10 #include "chrome/browser/debugger/devtools_toggle_action.h" | 10 #include "chrome/browser/debugger/devtools_toggle_action.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // Show the border first, then the popup overlaid on top. | 149 // Show the border first, then the popup overlaid on top. |
150 border_widget_->Show(); | 150 border_widget_->Show(); |
151 BrowserBubble::Show(activate); | 151 BrowserBubble::Show(activate); |
152 } | 152 } |
153 | 153 |
154 void ExtensionPopup::ResizeToView() { | 154 void ExtensionPopup::ResizeToView() { |
155 // We'll be sizing ourselves to this size shortly, but wait until we | 155 // We'll be sizing ourselves to this size shortly, but wait until we |
156 // know our position to do it. | 156 // know our position to do it. |
157 gfx::Size new_size = view()->size(); | 157 gfx::Size new_size = view()->size(); |
158 | 158 |
| 159 // |relative_to_| is in browser-relative coordinates, so convert it to |
| 160 // screen coordinates for use in placing the popup widgets. |
| 161 gfx::Rect relative_rect = relative_to_; |
| 162 gfx::Point relative_origin = relative_rect.origin(); |
| 163 views::View::ConvertPointToScreen(frame_->GetRootView(), &relative_origin); |
| 164 relative_rect.set_origin(relative_origin); |
| 165 |
159 // The rounded corners cut off more of the view than the border insets claim. | 166 // The rounded corners cut off more of the view than the border insets claim. |
160 // Since we can't clip the ExtensionView's corners, we need to increase the | 167 // Since we can't clip the ExtensionView's corners, we need to increase the |
161 // inset by half the corner radius as well as lying about the size of the | 168 // inset by half the corner radius as well as lying about the size of the |
162 // contents size to compensate. | 169 // contents size to compensate. |
163 int corner_inset = BubbleBorder::GetCornerRadius() / 2; | 170 int corner_inset = BubbleBorder::GetCornerRadius() / 2; |
164 gfx::Size adjusted_size = new_size; | 171 gfx::Size adjusted_size = new_size; |
165 adjusted_size.Enlarge(2 * corner_inset, 2 * corner_inset); | 172 adjusted_size.Enlarge(2 * corner_inset, 2 * corner_inset); |
166 gfx::Rect rect = border_->GetBounds(relative_to_, adjusted_size); | 173 gfx::Rect rect = border_->GetBounds(relative_rect, adjusted_size); |
167 border_widget_->SetBounds(rect); | 174 border_widget_->SetBounds(rect); |
168 | 175 |
169 // Now calculate the inner bounds. This is a bit more convoluted than | 176 // Now calculate the inner bounds. This is a bit more convoluted than |
170 // it should be because BrowserBubble coordinates are in Browser coordinates | 177 // it should be because BrowserBubble coordinates are in Browser coordinates |
171 // while |rect| is in screen coordinates. | 178 // while |rect| is in screen coordinates. |
172 gfx::Insets border_insets; | 179 gfx::Insets border_insets; |
173 border_->GetInsets(&border_insets); | 180 border_->GetInsets(&border_insets); |
174 gfx::Point origin = rect.origin(); | 181 gfx::Point origin = rect.origin(); |
175 views::View::ConvertPointToView(NULL, frame_->GetRootView(), &origin); | 182 views::View::ConvertPointToView(NULL, frame_->GetRootView(), &origin); |
176 | 183 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 if (closing_) | 308 if (closing_) |
302 return; | 309 return; |
303 closing_ = true; | 310 closing_ = true; |
304 DetachFromBrowser(); | 311 DetachFromBrowser(); |
305 | 312 |
306 if (observer_) | 313 if (observer_) |
307 observer_->ExtensionPopupIsClosing(this); | 314 observer_->ExtensionPopupIsClosing(this); |
308 | 315 |
309 Release(); // Balanced in ctor. | 316 Release(); // Balanced in ctor. |
310 } | 317 } |
OLD | NEW |