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/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/extension_system.h" | 11 #include "chrome/browser/extensions/extension_system.h" |
12 #include "chrome/browser/extensions/extension_util.h" | 12 #include "chrome/browser/extensions/extension_util.h" |
13 #include "chrome/browser/extensions/extension_view_host.h" | 13 #include "chrome/browser/extensions/extension_view_host.h" |
14 #include "chrome/browser/extensions/tab_helper.h" | 14 #include "chrome/browser/extensions/tab_helper.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/sessions/session_tab_helper.h" | 16 #include "chrome/browser/sessions/session_tab_helper.h" |
17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
20 #include "chrome/browser/ui/view_ids.h" | 20 #include "chrome/browser/ui/view_ids.h" |
21 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" | 21 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" |
22 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" | 22 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" |
23 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 23 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
24 #include "chrome/browser/ui/views/toolbar/browser_action_view.h" | 24 #include "chrome/browser/ui/views/toolbar/browser_action_view.h" |
25 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 25 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "extensions/browser/pref_names.h" | 27 #include "extensions/browser/pref_names.h" |
| 28 #include "extensions/browser/runtime_data.h" |
28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
29 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
30 #include "grit/ui_resources.h" | 31 #include "grit/ui_resources.h" |
31 #include "ui/base/accessibility/accessible_view_state.h" | 32 #include "ui/base/accessibility/accessible_view_state.h" |
32 #include "ui/base/dragdrop/drag_utils.h" | 33 #include "ui/base/dragdrop/drag_utils.h" |
33 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
34 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
35 #include "ui/base/theme_provider.h" | 36 #include "ui/base/theme_provider.h" |
36 #include "ui/gfx/animation/slide_animation.h" | 37 #include "ui/gfx/animation/slide_animation.h" |
37 #include "ui/gfx/canvas.h" | 38 #include "ui/gfx/canvas.h" |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 browser_action_views_.insert(browser_action_views_.begin() + index, view); | 619 browser_action_views_.insert(browser_action_views_.begin() + index, view); |
619 AddChildViewAt(view, index); | 620 AddChildViewAt(view, index); |
620 | 621 |
621 // If we are still initializing the container, don't bother animating. | 622 // If we are still initializing the container, don't bother animating. |
622 if (!model_->extensions_initialized()) | 623 if (!model_->extensions_initialized()) |
623 return; | 624 return; |
624 | 625 |
625 // Enlarge the container if it was already at maximum size and we're not in | 626 // Enlarge the container if it was already at maximum size and we're not in |
626 // the middle of upgrading. | 627 // the middle of upgrading. |
627 if ((model_->GetVisibleIconCount() < 0) && | 628 if ((model_->GetVisibleIconCount() < 0) && |
628 !extensions::ExtensionSystem::Get(profile_)->extension_service()-> | 629 !extensions::ExtensionSystem::Get(profile_)->runtime_data()-> |
629 IsBeingUpgraded(extension)) { | 630 IsBeingUpgraded(extension)) { |
630 suppress_chevron_ = true; | 631 suppress_chevron_ = true; |
631 SaveDesiredSizeAndAnimate(gfx::Tween::LINEAR, visible_actions + 1); | 632 SaveDesiredSizeAndAnimate(gfx::Tween::LINEAR, visible_actions + 1); |
632 } else { | 633 } else { |
633 // Just redraw the (possibly modified) visible icon set. | 634 // Just redraw the (possibly modified) visible icon set. |
634 OnBrowserActionVisibilityChanged(); | 635 OnBrowserActionVisibilityChanged(); |
635 } | 636 } |
636 } | 637 } |
637 | 638 |
638 void BrowserActionsContainer::BrowserActionRemoved(const Extension* extension) { | 639 void BrowserActionsContainer::BrowserActionRemoved(const Extension* extension) { |
639 CloseOverflowMenu(); | 640 CloseOverflowMenu(); |
640 | 641 |
641 if (popup_ && popup_->host()->extension() == extension) | 642 if (popup_ && popup_->host()->extension() == extension) |
642 HidePopup(); | 643 HidePopup(); |
643 | 644 |
644 size_t visible_actions = VisibleBrowserActions(); | 645 size_t visible_actions = VisibleBrowserActions(); |
645 for (BrowserActionViews::iterator i(browser_action_views_.begin()); | 646 for (BrowserActionViews::iterator i(browser_action_views_.begin()); |
646 i != browser_action_views_.end(); ++i) { | 647 i != browser_action_views_.end(); ++i) { |
647 if ((*i)->button()->extension() == extension) { | 648 if ((*i)->button()->extension() == extension) { |
648 delete *i; | 649 delete *i; |
649 browser_action_views_.erase(i); | 650 browser_action_views_.erase(i); |
650 | 651 |
651 // If the extension is being upgraded we don't want the bar to shrink | 652 // If the extension is being upgraded we don't want the bar to shrink |
652 // because the icon is just going to get re-added to the same location. | 653 // because the icon is just going to get re-added to the same location. |
653 if (extensions::ExtensionSystem::Get(profile_)->extension_service()-> | 654 if (extensions::ExtensionSystem::Get(profile_)->runtime_data()-> |
654 IsBeingUpgraded(extension)) | 655 IsBeingUpgraded(extension)) |
655 return; | 656 return; |
656 | 657 |
657 if (browser_action_views_.size() > visible_actions) { | 658 if (browser_action_views_.size() > visible_actions) { |
658 // If we have more icons than we can show, then we must not be changing | 659 // If we have more icons than we can show, then we must not be changing |
659 // the container size (since we either removed an icon from the main | 660 // the container size (since we either removed an icon from the main |
660 // area and one from the overflow list will have shifted in, or we | 661 // area and one from the overflow list will have shifted in, or we |
661 // removed an entry directly from the overflow list). | 662 // removed an entry directly from the overflow list). |
662 OnBrowserActionVisibilityChanged(); | 663 OnBrowserActionVisibilityChanged(); |
663 } else { | 664 } else { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 arrow, | 871 arrow, |
871 show_action); | 872 show_action); |
872 popup_->GetWidget()->AddObserver(this); | 873 popup_->GetWidget()->AddObserver(this); |
873 popup_button_ = button; | 874 popup_button_ = button; |
874 | 875 |
875 // Only set button as pushed if it was triggered by a user click. | 876 // Only set button as pushed if it was triggered by a user click. |
876 if (should_grant) | 877 if (should_grant) |
877 popup_button_->SetButtonPushed(); | 878 popup_button_->SetButtonPushed(); |
878 return true; | 879 return true; |
879 } | 880 } |
OLD | NEW |