OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/browser_actions_container.h" | 5 #include "chrome/browser/views/browser_actions_container.h" |
6 | 6 |
7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "chrome/browser/browser.h" |
| 12 #include "chrome/browser/browser_window.h" |
11 #include "chrome/browser/extensions/extension_browser_event_router.h" | 13 #include "chrome/browser/extensions/extension_browser_event_router.h" |
12 #include "chrome/browser/extensions/extensions_service.h" | 14 #include "chrome/browser/extensions/extensions_service.h" |
13 #include "chrome/browser/extensions/extension_tabs_module.h" | 15 #include "chrome/browser/extensions/extension_tabs_module.h" |
14 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 16 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
15 #include "chrome/browser/profile.h" | 17 #include "chrome/browser/profile.h" |
16 #include "chrome/browser/view_ids.h" | 18 #include "chrome/browser/view_ids.h" |
17 #include "chrome/browser/views/extensions/extension_popup.h" | 19 #include "chrome/browser/views/extensions/extension_popup.h" |
18 #include "chrome/browser/views/toolbar_view.h" | 20 #include "chrome/browser/views/toolbar_view.h" |
19 #include "chrome/common/notification_source.h" | 21 #include "chrome/common/notification_source.h" |
20 #include "chrome/common/notification_type.h" | 22 #include "chrome/common/notification_type.h" |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 HidePopup(); | 371 HidePopup(); |
370 | 372 |
371 if (same_showing) | 373 if (same_showing) |
372 return; | 374 return; |
373 | 375 |
374 gfx::Point origin; | 376 gfx::Point origin; |
375 View::ConvertPointToScreen(button, &origin); | 377 View::ConvertPointToScreen(button, &origin); |
376 gfx::Rect rect = button->bounds(); | 378 gfx::Rect rect = button->bounds(); |
377 rect.set_x(origin.x()); | 379 rect.set_x(origin.x()); |
378 rect.set_y(origin.y()); | 380 rect.set_y(origin.y()); |
| 381 |
| 382 gfx::NativeWindow frame_window = |
| 383 toolbar_->browser()->window()->GetNativeHandle(); |
379 popup_ = ExtensionPopup::Show(browser_action->popup_url(), | 384 popup_ = ExtensionPopup::Show(browser_action->popup_url(), |
380 toolbar_->browser(), | 385 toolbar_->browser(), |
| 386 toolbar_->browser()->profile(), |
| 387 frame_window, |
381 rect, | 388 rect, |
382 BubbleBorder::TOP_RIGHT, | 389 BubbleBorder::TOP_RIGHT, |
383 true); // Activate the popup window. | 390 true); // Activate the popup window. |
384 popup_->set_delegate(this); | 391 popup_->set_delegate(this); |
385 popup_button_ = button; | 392 popup_button_ = button; |
386 popup_button_->PopupDidShow(); | 393 popup_button_->PopupDidShow(); |
387 return; | 394 return; |
388 } | 395 } |
389 | 396 |
390 // Otherwise, we send the action to the extension. | 397 // Otherwise, we send the action to the extension. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 std::min(static_cast<int>(browser_action_views_.size()), | 502 std::min(static_cast<int>(browser_action_views_.size()), |
496 kMinimumNumberOfVisibleBrowserActions) * kButtonSize; | 503 kMinimumNumberOfVisibleBrowserActions) * kButtonSize; |
497 | 504 |
498 // Even if available_width is <= 0, we still return at least the |min_width|. | 505 // Even if available_width is <= 0, we still return at least the |min_width|. |
499 if (available_width <= 0) | 506 if (available_width <= 0) |
500 return min_width; | 507 return min_width; |
501 | 508 |
502 return std::max(min_width, available_width - available_width % kButtonSize + | 509 return std::max(min_width, available_width - available_width % kButtonSize + |
503 kHorizontalPadding * 2); | 510 kHorizontalPadding * 2); |
504 } | 511 } |
OLD | NEW |