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

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: Conditionalize include 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..d66fcfa940816ef7000d466d0e3285a2c6a06598 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,26 @@ 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))
+ 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);
+}
« no previous file with comments | « chrome/browser/ui/app_list/google_now_extension.h ('k') | chrome/browser/ui/webui/options/browser_options_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698