Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(909)

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_actions_bar.cc

Issue 1086973004: [Extensions Mac] Implement developer mode warning on mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avi's Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/toolbar/toolbar_actions_bar.h" 5 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/profiler/scoped_tracker.h" 8 #include "base/profiler/scoped_tracker.h"
9 #include "chrome/browser/extensions/extension_action_manager.h" 9 #include "chrome/browser/extensions/extension_action_manager.h"
10 #include "chrome/browser/extensions/extension_message_bubble_controller.h" 10 #include "chrome/browser/extensions/extension_message_bubble_controller.h"
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 delta = -1; 710 delta = -1;
711 else if (drag_type == DRAG_TO_MAIN) 711 else if (drag_type == DRAG_TO_MAIN)
712 delta = 1; 712 delta = 1;
713 model_->MoveExtensionIcon(toolbar_actions_[dragged_index]->GetId(), 713 model_->MoveExtensionIcon(toolbar_actions_[dragged_index]->GetId(),
714 dropped_index); 714 dropped_index);
715 if (delta) 715 if (delta)
716 model_->SetVisibleIconCount(model_->visible_icon_count() + delta); 716 model_->SetVisibleIconCount(model_->visible_icon_count() + delta);
717 } 717 }
718 } 718 }
719 719
720 bool ToolbarActionsBar::ShouldShowInfoBubble() {
721 // If the redesign isn't running, or the user has already acknowledged it,
722 // we don't show the bubble.
723 PrefService* prefs = browser_->profile()->GetPrefs();
724 if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled() ||
725 (prefs->HasPrefPath(prefs::kToolbarIconSurfacingBubbleAcknowledged) &&
726 prefs->GetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged)))
727 return false;
728
729 // We don't show more than once per day.
730 if (prefs->HasPrefPath(prefs::kToolbarIconSurfacingBubbleLastShowTime)) {
731 base::Time last_shown_time = base::Time::FromInternalValue(
732 prefs->GetInt64(prefs::kToolbarIconSurfacingBubbleLastShowTime));
733 if (base::Time::Now() - last_shown_time < base::TimeDelta::FromDays(1))
734 return false;
735 }
736
737 if (!model_->RedesignIsShowingNewIcons()) {
738 // We only show the bubble if there are any new icons present - otherwise,
739 // the user won't see anything different, so we treat it as acknowledged.
740 OnToolbarActionsBarBubbleClosed(
741 ToolbarActionsBarBubbleDelegate::ACKNOWLEDGED);
742 return false;
743 }
744
745 return true;
746 }
747
748 void ToolbarActionsBar::MaybeShowExtensionBubble() { 720 void ToolbarActionsBar::MaybeShowExtensionBubble() {
749 scoped_ptr<extensions::ExtensionMessageBubbleController> controller = 721 scoped_ptr<extensions::ExtensionMessageBubbleController> controller =
750 ExtensionMessageBubbleFactory(browser_->profile()).GetController(); 722 ExtensionMessageBubbleFactory(browser_->profile()).GetController();
751 if (controller) { 723 if (controller) {
752 controller->HighlightExtensionsIfNecessary(); 724 controller->HighlightExtensionsIfNecessary();
753 delegate_->ShowExtensionMessageBubble(controller.Pass()); 725 delegate_->ShowExtensionMessageBubble(controller.Pass());
754 } 726 }
755 } 727 }
756 728
757 void ToolbarActionsBar::OnToolbarExtensionAdded( 729 void ToolbarActionsBar::OnToolbarExtensionAdded(
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 tracked_objects::ScopedTracker tracking_profile( 888 tracked_objects::ScopedTracker tracking_profile(
917 FROM_HERE_WITH_EXPLICIT_FUNCTION( 889 FROM_HERE_WITH_EXPLICIT_FUNCTION(
918 "ToolbarActionsBar::OnToolbarModelInitialized")); 890 "ToolbarActionsBar::OnToolbarModelInitialized"));
919 ResizeDelegate(gfx::Tween::EASE_OUT, false); 891 ResizeDelegate(gfx::Tween::EASE_OUT, false);
920 } 892 }
921 893
922 Browser* ToolbarActionsBar::GetBrowser() { 894 Browser* ToolbarActionsBar::GetBrowser() {
923 return browser_; 895 return browser_;
924 } 896 }
925 897
926 void ToolbarActionsBar::OnToolbarActionsBarBubbleShown() {
927 // Record the last time the bubble was shown.
928 browser_->profile()->GetPrefs()->SetInt64(
929 prefs::kToolbarIconSurfacingBubbleLastShowTime,
930 base::Time::Now().ToInternalValue());
931 }
932
933 void ToolbarActionsBar::OnToolbarActionsBarBubbleClosed(CloseAction action) {
934 if (action == ToolbarActionsBarBubbleDelegate::ACKNOWLEDGED) {
935 PrefService* prefs = browser_->profile()->GetPrefs();
936 prefs->SetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged, true);
937 // Once the bubble is acknowledged, we no longer need to store the last
938 // show time.
939 if (prefs->HasPrefPath(prefs::kToolbarIconSurfacingBubbleLastShowTime))
940 prefs->ClearPref(prefs::kToolbarIconSurfacingBubbleLastShowTime);
941 }
942 }
943
944 void ToolbarActionsBar::ReorderActions() { 898 void ToolbarActionsBar::ReorderActions() {
945 if (toolbar_actions_.empty()) 899 if (toolbar_actions_.empty())
946 return; 900 return;
947 901
948 // First, reset the order to that of the model. 902 // First, reset the order to that of the model.
949 auto compare = [](ToolbarActionViewController* const& action, 903 auto compare = [](ToolbarActionViewController* const& action,
950 const scoped_refptr<const extensions::Extension>& ext) { 904 const scoped_refptr<const extensions::Extension>& ext) {
951 return action->GetId() == ext->id(); 905 return action->GetId() == ext->id();
952 }; 906 };
953 SortContainer(&toolbar_actions_.get(), model_->toolbar_items(), compare); 907 SortContainer(&toolbar_actions_.get(), model_->toolbar_items(), compare);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 for (ToolbarActionViewController* action : toolbar_actions_) { 956 for (ToolbarActionViewController* action : toolbar_actions_) {
1003 if (action->GetId() == id) 957 if (action->GetId() == id)
1004 return action; 958 return action;
1005 } 959 }
1006 return nullptr; 960 return nullptr;
1007 } 961 }
1008 962
1009 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() { 963 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() {
1010 return browser_->tab_strip_model()->GetActiveWebContents(); 964 return browser_->tab_strip_model()->GetActiveWebContents();
1011 } 965 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_actions_bar.h ('k') | chrome/browser/ui/toolbar/toolbar_actions_bar_bubble_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698