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

Side by Side Diff: chrome/browser/ui/extensions/extension_toolbar_icon_surfacing_bubble_delegate.cc

Issue 1391893003: NOT FOR REVIEW: Aura on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/extensions/extension_toolbar_icon_surfacing_bubble_d elegate.h" 5 #include "chrome/browser/ui/extensions/extension_toolbar_icon_surfacing_bubble_d elegate.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "chrome/browser/extensions/extension_toolbar_model.h" 10 #include "chrome/browser/extensions/extension_toolbar_model.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
13 #include "extensions/common/feature_switch.h" 13 #include "extensions/common/feature_switch.h"
14 #include "grit/chromium_strings.h" 14 #include "grit/chromium_strings.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 17
18 namespace { 18 namespace {
19 19
20 void AcknowledgeInPrefs(PrefService* prefs) { 20 void AcknowledgeInPrefs(PrefService* prefs) {
21 #if !defined(OS_ANDROID)
21 prefs->SetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged, true); 22 prefs->SetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged, true);
22 // Once the bubble is acknowledged, we no longer need to store the last 23 // Once the bubble is acknowledged, we no longer need to store the last
23 // show time. 24 // show time.
24 if (prefs->HasPrefPath(prefs::kToolbarIconSurfacingBubbleLastShowTime)) 25 if (prefs->HasPrefPath(prefs::kToolbarIconSurfacingBubbleLastShowTime))
25 prefs->ClearPref(prefs::kToolbarIconSurfacingBubbleLastShowTime); 26 prefs->ClearPref(prefs::kToolbarIconSurfacingBubbleLastShowTime);
27 #endif
26 } 28 }
27 29
28 } // namespace 30 } // namespace
29 31
30 ExtensionToolbarIconSurfacingBubbleDelegate:: 32 ExtensionToolbarIconSurfacingBubbleDelegate::
31 ExtensionToolbarIconSurfacingBubbleDelegate(Profile* profile) 33 ExtensionToolbarIconSurfacingBubbleDelegate(Profile* profile)
32 : profile_(profile) { 34 : profile_(profile) {
33 } 35 }
34 36
35 ExtensionToolbarIconSurfacingBubbleDelegate:: 37 ExtensionToolbarIconSurfacingBubbleDelegate::
36 ~ExtensionToolbarIconSurfacingBubbleDelegate() { 38 ~ExtensionToolbarIconSurfacingBubbleDelegate() {
37 } 39 }
38 40
39 bool ExtensionToolbarIconSurfacingBubbleDelegate::ShouldShowForProfile( 41 bool ExtensionToolbarIconSurfacingBubbleDelegate::ShouldShowForProfile(
40 Profile* profile) { 42 Profile* profile) {
43 #if !defined(OS_ANDROID)
41 // If the redesign isn't running, or the user has already acknowledged it, 44 // If the redesign isn't running, or the user has already acknowledged it,
42 // we don't show the bubble. 45 // we don't show the bubble.
43 PrefService* prefs = profile->GetPrefs(); 46 PrefService* prefs = profile->GetPrefs();
44 if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled() || 47 if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled() ||
45 (prefs->HasPrefPath(prefs::kToolbarIconSurfacingBubbleAcknowledged) && 48 (prefs->HasPrefPath(prefs::kToolbarIconSurfacingBubbleAcknowledged) &&
46 prefs->GetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged))) 49 prefs->GetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged)))
47 return false; 50 return false;
48 51
49 // We don't show more than once per day. 52 // We don't show more than once per day.
50 if (prefs->HasPrefPath(prefs::kToolbarIconSurfacingBubbleLastShowTime)) { 53 if (prefs->HasPrefPath(prefs::kToolbarIconSurfacingBubbleLastShowTime)) {
51 base::Time last_shown_time = base::Time::FromInternalValue( 54 base::Time last_shown_time = base::Time::FromInternalValue(
52 prefs->GetInt64(prefs::kToolbarIconSurfacingBubbleLastShowTime)); 55 prefs->GetInt64(prefs::kToolbarIconSurfacingBubbleLastShowTime));
53 if (base::Time::Now() - last_shown_time < base::TimeDelta::FromDays(1)) 56 if (base::Time::Now() - last_shown_time < base::TimeDelta::FromDays(1))
54 return false; 57 return false;
55 } 58 }
56 59
57 if (!extensions::ExtensionToolbarModel::Get(profile)-> 60 if (!extensions::ExtensionToolbarModel::Get(profile)->
58 RedesignIsShowingNewIcons()) { 61 RedesignIsShowingNewIcons()) {
59 // We only show the bubble if there are any new icons present - otherwise, 62 // We only show the bubble if there are any new icons present - otherwise,
60 // the user won't see anything different, so we treat it as acknowledged. 63 // the user won't see anything different, so we treat it as acknowledged.
61 AcknowledgeInPrefs(prefs); 64 AcknowledgeInPrefs(prefs);
62 return false; 65 return false;
63 } 66 }
67 #endif
64 68
65 return true; 69 return true;
66 } 70 }
67 71
68 base::string16 ExtensionToolbarIconSurfacingBubbleDelegate::GetHeadingText() { 72 base::string16 ExtensionToolbarIconSurfacingBubbleDelegate::GetHeadingText() {
69 return l10n_util::GetStringUTF16(IDS_EXTENSION_TOOLBAR_BUBBLE_HEADING); 73 return l10n_util::GetStringUTF16(IDS_EXTENSION_TOOLBAR_BUBBLE_HEADING);
70 } 74 }
71 75
72 base::string16 ExtensionToolbarIconSurfacingBubbleDelegate::GetBodyText() { 76 base::string16 ExtensionToolbarIconSurfacingBubbleDelegate::GetBodyText() {
73 return l10n_util::GetStringUTF16(IDS_EXTENSION_TOOLBAR_BUBBLE_CONTENT); 77 return l10n_util::GetStringUTF16(IDS_EXTENSION_TOOLBAR_BUBBLE_CONTENT);
(...skipping 12 matching lines...) Expand all
86 ExtensionToolbarIconSurfacingBubbleDelegate::GetDismissButtonText() { 90 ExtensionToolbarIconSurfacingBubbleDelegate::GetDismissButtonText() {
87 return base::string16(); // No dismiss button. 91 return base::string16(); // No dismiss button.
88 } 92 }
89 93
90 base::string16 94 base::string16
91 ExtensionToolbarIconSurfacingBubbleDelegate::GetLearnMoreButtonText() { 95 ExtensionToolbarIconSurfacingBubbleDelegate::GetLearnMoreButtonText() {
92 return base::string16(); // No learn more link. 96 return base::string16(); // No learn more link.
93 } 97 }
94 98
95 void ExtensionToolbarIconSurfacingBubbleDelegate::OnBubbleShown() { 99 void ExtensionToolbarIconSurfacingBubbleDelegate::OnBubbleShown() {
100 #if !defined(OS_ANDROID)
96 // Record the last time the bubble was shown. 101 // Record the last time the bubble was shown.
97 profile_->GetPrefs()->SetInt64( 102 profile_->GetPrefs()->SetInt64(
98 prefs::kToolbarIconSurfacingBubbleLastShowTime, 103 prefs::kToolbarIconSurfacingBubbleLastShowTime,
99 base::Time::Now().ToInternalValue()); 104 base::Time::Now().ToInternalValue());
105 #endif
100 } 106 }
101 107
102 void ExtensionToolbarIconSurfacingBubbleDelegate::OnBubbleClosed( 108 void ExtensionToolbarIconSurfacingBubbleDelegate::OnBubbleClosed(
103 CloseAction action) { 109 CloseAction action) {
104 if (action == CLOSE_EXECUTE) 110 if (action == CLOSE_EXECUTE)
105 AcknowledgeInPrefs(profile_->GetPrefs()); 111 AcknowledgeInPrefs(profile_->GetPrefs());
106 extensions::ExtensionToolbarModel::Get(profile_)->StopHighlighting(); 112 extensions::ExtensionToolbarModel::Get(profile_)->StopHighlighting();
107 } 113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698