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/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/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" |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
679 index = model_->OriginalIndexToIncognito(index); | 679 index = model_->OriginalIndexToIncognito(index); |
680 | 680 |
681 DCHECK(index >= 0 && index < static_cast<int>(browser_action_views_.size())); | 681 DCHECK(index >= 0 && index < static_cast<int>(browser_action_views_.size())); |
682 | 682 |
683 DeleteBrowserActionViews(); | 683 DeleteBrowserActionViews(); |
684 CreateBrowserActionViews(); | 684 CreateBrowserActionViews(); |
685 Layout(); | 685 Layout(); |
686 SchedulePaint(); | 686 SchedulePaint(); |
687 } | 687 } |
688 | 688 |
689 void BrowserActionsContainer::BrowserActionShowPopup( | |
690 const extensions::Extension* extension) { | |
691 // DO_NOT_REVIEW: This is not completely correct yet. | |
Finnur
2013/10/15 10:44:21
Can you elaborate?
justinlin
2013/10/16 07:06:48
This is done now.
| |
692 BrowserActionButton* button = NULL; | |
693 for (BrowserActionViews::iterator it = browser_action_views_.begin(); | |
694 it != browser_action_views_.end(); ++it) { | |
695 if ((*it)->button()->extension() == extension) { | |
696 button = (*it)->button(); | |
697 } | |
698 } | |
699 if (button != NULL) | |
700 ShowPopup(button, ExtensionPopup::SHOW); | |
701 } | |
702 | |
689 void BrowserActionsContainer::ModelLoaded() { | 703 void BrowserActionsContainer::ModelLoaded() { |
690 SetContainerWidth(); | 704 SetContainerWidth(); |
691 } | 705 } |
692 | 706 |
693 void BrowserActionsContainer::LoadImages() { | 707 void BrowserActionsContainer::LoadImages() { |
694 ui::ThemeProvider* tp = GetThemeProvider(); | 708 ui::ThemeProvider* tp = GetThemeProvider(); |
695 chevron_->SetIcon(*tp->GetImageSkiaNamed(IDR_BROWSER_ACTIONS_OVERFLOW)); | 709 chevron_->SetIcon(*tp->GetImageSkiaNamed(IDR_BROWSER_ACTIONS_OVERFLOW)); |
696 chevron_->SetHoverIcon(*tp->GetImageSkiaNamed( | 710 chevron_->SetHoverIcon(*tp->GetImageSkiaNamed( |
697 IDR_BROWSER_ACTIONS_OVERFLOW_H)); | 711 IDR_BROWSER_ACTIONS_OVERFLOW_H)); |
698 chevron_->SetPushedIcon(*tp->GetImageSkiaNamed( | 712 chevron_->SetPushedIcon(*tp->GetImageSkiaNamed( |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
808 // Only display incognito-enabled extensions while in incognito mode. | 822 // Only display incognito-enabled extensions while in incognito mode. |
809 return | 823 return |
810 (!profile_->IsOffTheRecord() || | 824 (!profile_->IsOffTheRecord() || |
811 extensions::ExtensionSystem::Get(profile_)->extension_service()-> | 825 extensions::ExtensionSystem::Get(profile_)->extension_service()-> |
812 IsIncognitoEnabled(extension->id())); | 826 IsIncognitoEnabled(extension->id())); |
813 } | 827 } |
814 | 828 |
815 void BrowserActionsContainer::ShowPopup( | 829 void BrowserActionsContainer::ShowPopup( |
816 BrowserActionButton* button, | 830 BrowserActionButton* button, |
817 ExtensionPopup::ShowAction show_action) { | 831 ExtensionPopup::ShowAction show_action) { |
818 const Extension* extension = button->extension(); | 832 const extensions::Extension* extension = button->extension(); |
819 GURL popup_url; | 833 GURL popup_url; |
820 if (model_->ExecuteBrowserAction(extension, browser_, &popup_url) != | 834 if (model_->ExecuteBrowserAction(extension, browser_, &popup_url) != |
821 ExtensionToolbarModel::ACTION_SHOW_POPUP) { | 835 ExtensionToolbarModel::ACTION_SHOW_POPUP) { |
822 return; | 836 return; |
823 } | 837 } |
824 | 838 |
825 // If we're showing the same popup, just hide it and return. | 839 // If we're showing the same popup, just hide it and return. |
826 bool same_showing = popup_ && button == popup_button_; | 840 bool same_showing = popup_ && button == popup_button_; |
827 | 841 |
828 // Always hide the current popup, even if it's not the same. | 842 // Always hide the current popup, even if it's not the same. |
(...skipping 11 matching lines...) Expand all Loading... | |
840 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; | 854 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; |
841 popup_ = ExtensionPopup::ShowPopup(popup_url, | 855 popup_ = ExtensionPopup::ShowPopup(popup_url, |
842 browser_, | 856 browser_, |
843 reference_view, | 857 reference_view, |
844 arrow, | 858 arrow, |
845 show_action); | 859 show_action); |
846 popup_->GetWidget()->AddObserver(this); | 860 popup_->GetWidget()->AddObserver(this); |
847 popup_button_ = button; | 861 popup_button_ = button; |
848 popup_button_->SetButtonPushed(); | 862 popup_button_->SetButtonPushed(); |
849 } | 863 } |
OLD | NEW |