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..f04d06cd48c5e2154dc987b3e83262fd11f41416 100644 |
| --- a/chrome/browser/ui/app_list/google_now_extension.cc |
| +++ b/chrome/browser/ui/app_list/google_now_extension.cc |
| @@ -4,10 +4,17 @@ |
| #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. |
|
robliao
2015/02/19 18:43:25
Since there is more than one item in this namespac
skare_
2015/02/19 20:19:29
Done.
|
| +const char kNowNotifierId[] = "pafkbggdmjlpgkdkcbjmhmfcdpncadgh"; |
| }; // namespace |
| bool GetGoogleNowExtensionId(std::string* extension_id) { |
| @@ -15,3 +22,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) == false) { |
|
robliao
2015/02/19 18:43:25
Replace == false with !GetGoogleNowExtensionId
skare_
2015/02/19 20:19:29
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()) { |
| + 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); |
| +} |