Chromium Code Reviews| Index: chrome/browser/ui/app_list/google_now_extension.cc |
| diff --git a/chrome/browser/ui/app_list/google_now_extension.cc b/chrome/browser/ui/app_list/google_now_extension.cc |
| index 303eb301a5c56ad69f6cf63543060a10c3b41a9d..816016cf03a12ec23ff9af9dcfa5f788b34543e9 100644 |
| --- a/chrome/browser/ui/app_list/google_now_extension.cc |
| +++ b/chrome/browser/ui/app_list/google_now_extension.cc |
| @@ -4,10 +4,18 @@ |
| #include "chrome/browser/ui/app_list/google_now_extension.h" |
| +#include "base/prefs/pref_service.h" |
| +#include "chrome/browser/notifications/desktop_notification_service.h" |
| +#include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/common/pref_names.h" |
| #include "components/variations/variations_associated_data.h" |
| namespace { |
| const char kGoogleNowExtensionFieldTrialName[] = "GoogleNowExtension"; |
| + |
| +// Extension ID for previous Now notifications component. |
| +const char kNowNotifierId[] = "pafkbggdmjlpgkdkcbjmhmfcdpncadgh"; |
| }; // namespace |
| bool GetGoogleNowExtensionId(std::string* extension_id) { |
| @@ -15,3 +23,28 @@ bool GetGoogleNowExtensionId(std::string* extension_id) { |
| kGoogleNowExtensionFieldTrialName, "id"); |
| return !extension_id->empty(); |
| } |
| + |
| +// TODO(skare): Remove this if/when the Now Notifications component is |
| +// deprecated. http://crbug.com/459846 |
| +void MigrateGoogleNowPrefs(Profile* profile) { |
| + std::string now_extension_id; |
| + if (!GetGoogleNowExtensionId(&now_extension_id)) { |
|
Matt Giuca
2015/02/20 01:40:30
nit: No curly braces (one-line condition and one-l
skare_
2015/02/20 17:54:49
Done.
|
| + return; |
| + } |
| + |
| + PrefService* prefs = profile->GetPrefs(); |
| + const PrefService::Preference* enabled_pref = |
| + prefs->FindPreference(prefs::kGoogleNowLauncherEnabled); |
| + |
| + // If the pref is not its default value, migration was performed. |
| + if (!enabled_pref->IsDefaultValue()) { |
|
Matt Giuca
2015/02/20 01:40:30
Nit: No curly braces.
Matt Giuca
2015/02/20 01:40:30
Can I just clarify the meaning of IsDefaultValue()
skare_
2015/02/20 17:54:49
yes, it's akin to a) the pref has not been explici
skare_
2015/02/20 17:54:49
Done.
|
| + return; |
| + } |
| + |
| + DesktopNotificationService* const notification_service = |
| + DesktopNotificationServiceFactory::GetForProfile(profile); |
| + bool notifier_enabled = notification_service->IsNotifierEnabled( |
| + message_center::NotifierId( |
| + message_center::NotifierId::APPLICATION, kNowNotifierId)); |
| + prefs->SetBoolean(prefs::kGoogleNowLauncherEnabled, notifier_enabled); |
|
gab
2015/02/20 15:11:21
User prefs should typically reflect explicit user
skare_
2015/02/20 17:54:49
thanks for verifying Matt's question and the detai
|
| +} |