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

Unified Diff: chrome/browser/ui/app_list/google_now_extension.cc

Issue 938713004: Add Now setting and migration logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
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);
+}

Powered by Google App Engine
This is Rietveld 408576698