| OLD | NEW |
| 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" | |
| 11 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/toolbar/toolbar_actions_model.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 prefs->SetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged, true); | 21 prefs->SetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged, true); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 47 return false; | 47 return false; |
| 48 | 48 |
| 49 // We don't show more than once per day. | 49 // We don't show more than once per day. |
| 50 if (prefs->HasPrefPath(prefs::kToolbarIconSurfacingBubbleLastShowTime)) { | 50 if (prefs->HasPrefPath(prefs::kToolbarIconSurfacingBubbleLastShowTime)) { |
| 51 base::Time last_shown_time = base::Time::FromInternalValue( | 51 base::Time last_shown_time = base::Time::FromInternalValue( |
| 52 prefs->GetInt64(prefs::kToolbarIconSurfacingBubbleLastShowTime)); | 52 prefs->GetInt64(prefs::kToolbarIconSurfacingBubbleLastShowTime)); |
| 53 if (base::Time::Now() - last_shown_time < base::TimeDelta::FromDays(1)) | 53 if (base::Time::Now() - last_shown_time < base::TimeDelta::FromDays(1)) |
| 54 return false; | 54 return false; |
| 55 } | 55 } |
| 56 | 56 |
| 57 if (!extensions::ExtensionToolbarModel::Get(profile)-> | 57 if (!ToolbarActionsModel::Get(profile)->RedesignIsShowingNewIcons()) { |
| 58 RedesignIsShowingNewIcons()) { | |
| 59 // We only show the bubble if there are any new icons present - otherwise, | 58 // 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. | 59 // the user won't see anything different, so we treat it as acknowledged. |
| 61 AcknowledgeInPrefs(prefs); | 60 AcknowledgeInPrefs(prefs); |
| 62 return false; | 61 return false; |
| 63 } | 62 } |
| 64 | 63 |
| 65 return true; | 64 return true; |
| 66 } | 65 } |
| 67 | 66 |
| 68 base::string16 ExtensionToolbarIconSurfacingBubbleDelegate::GetHeadingText() { | 67 base::string16 ExtensionToolbarIconSurfacingBubbleDelegate::GetHeadingText() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 96 // Record the last time the bubble was shown. | 95 // Record the last time the bubble was shown. |
| 97 profile_->GetPrefs()->SetInt64( | 96 profile_->GetPrefs()->SetInt64( |
| 98 prefs::kToolbarIconSurfacingBubbleLastShowTime, | 97 prefs::kToolbarIconSurfacingBubbleLastShowTime, |
| 99 base::Time::Now().ToInternalValue()); | 98 base::Time::Now().ToInternalValue()); |
| 100 } | 99 } |
| 101 | 100 |
| 102 void ExtensionToolbarIconSurfacingBubbleDelegate::OnBubbleClosed( | 101 void ExtensionToolbarIconSurfacingBubbleDelegate::OnBubbleClosed( |
| 103 CloseAction action) { | 102 CloseAction action) { |
| 104 if (action == CLOSE_EXECUTE) | 103 if (action == CLOSE_EXECUTE) |
| 105 AcknowledgeInPrefs(profile_->GetPrefs()); | 104 AcknowledgeInPrefs(profile_->GetPrefs()); |
| 106 extensions::ExtensionToolbarModel::Get(profile_)->StopHighlighting(); | 105 ToolbarActionsModel::Get(profile_)->StopHighlighting(); |
| 107 } | 106 } |
| OLD | NEW |