| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "chrome/browser/extensions/extension_message_bubble_controller.h" | |
| 10 #include "chrome/browser/extensions/tab_helper.h" | 9 #include "chrome/browser/extensions/tab_helper.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 14 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" | 13 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" |
| 15 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" | 14 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
| 16 #include "chrome/browser/ui/view_ids.h" | 15 #include "chrome/browser/ui/view_ids.h" |
| 17 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" | 16 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" |
| 18 #include "chrome/browser/ui/views/extensions/extension_message_bubble_view.h" | |
| 19 #include "chrome/browser/ui/views/extensions/extension_toolbar_icon_surfacing_bu
bble_views.h" | 17 #include "chrome/browser/ui/views/extensions/extension_toolbar_icon_surfacing_bu
bble_views.h" |
| 20 #include "chrome/browser/ui/views/frame/browser_view.h" | 18 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 21 #include "chrome/browser/ui/views/toolbar/browser_actions_container_observer.h" | 19 #include "chrome/browser/ui/views/toolbar/browser_actions_container_observer.h" |
| 22 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 23 #include "chrome/browser/ui/views/toolbar/wrench_toolbar_button.h" | 21 #include "chrome/browser/ui/views/toolbar/wrench_toolbar_button.h" |
| 24 #include "chrome/common/extensions/command.h" | 22 #include "chrome/common/extensions/command.h" |
| 25 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 26 #include "extensions/common/feature_switch.h" | 24 #include "extensions/common/feature_switch.h" |
| 27 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
| 28 #include "third_party/skia/include/core/SkColor.h" | 26 #include "third_party/skia/include/core/SkColor.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 332 } |
| 335 | 333 |
| 336 void BrowserActionsContainer::OnOverflowedActionWantsToRunChanged( | 334 void BrowserActionsContainer::OnOverflowedActionWantsToRunChanged( |
| 337 bool overflowed_action_wants_to_run) { | 335 bool overflowed_action_wants_to_run) { |
| 338 DCHECK(!in_overflow_mode()); | 336 DCHECK(!in_overflow_mode()); |
| 339 BrowserView::GetBrowserViewForBrowser(browser_)->toolbar()-> | 337 BrowserView::GetBrowserViewForBrowser(browser_)->toolbar()-> |
| 340 app_menu()->SetOverflowedToolbarActionWantsToRun( | 338 app_menu()->SetOverflowedToolbarActionWantsToRun( |
| 341 overflowed_action_wants_to_run); | 339 overflowed_action_wants_to_run); |
| 342 } | 340 } |
| 343 | 341 |
| 344 void BrowserActionsContainer::ShowExtensionMessageBubble( | |
| 345 scoped_ptr<extensions::ExtensionMessageBubbleController> controller) { | |
| 346 if (animating()) { | |
| 347 // If the container is animating, we can't effectively anchor the bubble, | |
| 348 // so wait until animation stops. | |
| 349 pending_extension_bubble_controller_ = controller.Pass(); | |
| 350 return; | |
| 351 } | |
| 352 | |
| 353 views::View* reference_view = VisibleBrowserActions() > 0 ? | |
| 354 static_cast<views::View*>(toolbar_action_views_[0]) : | |
| 355 BrowserView::GetBrowserViewForBrowser(browser_)->toolbar()->app_menu(); | |
| 356 | |
| 357 extensions::ExtensionMessageBubbleController* weak_controller = | |
| 358 controller.get(); | |
| 359 extensions::ExtensionMessageBubbleView* bubble = | |
| 360 new extensions::ExtensionMessageBubbleView( | |
| 361 reference_view, | |
| 362 views::BubbleBorder::TOP_RIGHT, | |
| 363 controller.Pass()); | |
| 364 views::BubbleDelegateView::CreateBubble(bubble); | |
| 365 weak_controller->Show(bubble); | |
| 366 } | |
| 367 | |
| 368 void BrowserActionsContainer::AddObserver( | 342 void BrowserActionsContainer::AddObserver( |
| 369 BrowserActionsContainerObserver* observer) { | 343 BrowserActionsContainerObserver* observer) { |
| 370 observers_.AddObserver(observer); | 344 observers_.AddObserver(observer); |
| 371 } | 345 } |
| 372 | 346 |
| 373 void BrowserActionsContainer::RemoveObserver( | 347 void BrowserActionsContainer::RemoveObserver( |
| 374 BrowserActionsContainerObserver* observer) { | 348 BrowserActionsContainerObserver* observer) { |
| 375 observers_.RemoveObserver(observer); | 349 observers_.RemoveObserver(observer); |
| 376 } | 350 } |
| 377 | 351 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 | 661 |
| 688 void BrowserActionsContainer::AnimationEnded(const gfx::Animation* animation) { | 662 void BrowserActionsContainer::AnimationEnded(const gfx::Animation* animation) { |
| 689 container_width_ = animation_target_size_; | 663 container_width_ = animation_target_size_; |
| 690 animation_target_size_ = 0; | 664 animation_target_size_ = 0; |
| 691 resize_amount_ = 0; | 665 resize_amount_ = 0; |
| 692 suppress_chevron_ = false; | 666 suppress_chevron_ = false; |
| 693 Redraw(false); | 667 Redraw(false); |
| 694 FOR_EACH_OBSERVER(BrowserActionsContainerObserver, | 668 FOR_EACH_OBSERVER(BrowserActionsContainerObserver, |
| 695 observers_, | 669 observers_, |
| 696 OnBrowserActionsContainerAnimationEnded()); | 670 OnBrowserActionsContainerAnimationEnded()); |
| 697 | |
| 698 if (pending_extension_bubble_controller_) | |
| 699 ShowExtensionMessageBubble(pending_extension_bubble_controller_.Pass()); | |
| 700 } | 671 } |
| 701 | 672 |
| 702 content::WebContents* BrowserActionsContainer::GetCurrentWebContents() { | 673 content::WebContents* BrowserActionsContainer::GetCurrentWebContents() { |
| 703 return browser_->tab_strip_model()->GetActiveWebContents(); | 674 return browser_->tab_strip_model()->GetActiveWebContents(); |
| 704 } | 675 } |
| 705 | 676 |
| 706 extensions::ActiveTabPermissionGranter* | 677 extensions::ActiveTabPermissionGranter* |
| 707 BrowserActionsContainer::GetActiveTabPermissionGranter() { | 678 BrowserActionsContainer::GetActiveTabPermissionGranter() { |
| 708 content::WebContents* web_contents = GetCurrentWebContents(); | 679 content::WebContents* web_contents = GetCurrentWebContents(); |
| 709 if (!web_contents) | 680 if (!web_contents) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 | 773 |
| 803 ui::ThemeProvider* tp = GetThemeProvider(); | 774 ui::ThemeProvider* tp = GetThemeProvider(); |
| 804 if (tp && chevron_) { | 775 if (tp && chevron_) { |
| 805 chevron_->SetImage(views::Button::STATE_NORMAL, | 776 chevron_->SetImage(views::Button::STATE_NORMAL, |
| 806 *tp->GetImageSkiaNamed(IDR_BROWSER_ACTIONS_OVERFLOW)); | 777 *tp->GetImageSkiaNamed(IDR_BROWSER_ACTIONS_OVERFLOW)); |
| 807 } | 778 } |
| 808 | 779 |
| 809 const int kImages[] = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT); | 780 const int kImages[] = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT); |
| 810 highlight_painter_.reset(views::Painter::CreateImageGridPainter(kImages)); | 781 highlight_painter_.reset(views::Painter::CreateImageGridPainter(kImages)); |
| 811 } | 782 } |
| OLD | NEW |