Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / ui / app_list / google_now_extension.cc
blob36bea6d66a24d70c33ad2c04d59b227f8c479ae2
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/app_list/google_now_extension.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/notifications/notifier_state_tracker.h"
9 #include "chrome/browser/notifications/notifier_state_tracker_factory.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/pref_names.h"
12 #include "components/variations/variations_associated_data.h"
13 #include "ui/message_center/notifier_settings.h"
15 namespace {
16 const char kGoogleNowExtensionFieldTrialName[] = "GoogleNowExtension";
18 // Extension ID for previous Now notifications component.
19 const char kNowNotifierId[] = "pafkbggdmjlpgkdkcbjmhmfcdpncadgh";
20 }; // namespace
22 bool GetGoogleNowExtensionId(std::string* extension_id) {
23 *extension_id = variations::GetVariationParamValue(
24 kGoogleNowExtensionFieldTrialName, "id");
25 return !extension_id->empty();
28 // TODO(skare): Remove this if/when the Now Notifications component is
29 // deprecated. http://crbug.com/459846
30 void MigrateGoogleNowPrefs(Profile* profile) {
31 std::string now_extension_id;
32 if (!GetGoogleNowExtensionId(&now_extension_id))
33 return;
35 PrefService* prefs = profile->GetPrefs();
36 const PrefService::Preference* enabled_pref =
37 prefs->FindPreference(prefs::kGoogleNowLauncherEnabled);
39 // If the pref is not its default value, migration was performed.
40 if (!enabled_pref->IsDefaultValue())
41 return;
43 NotifierStateTracker* const notifier_state_tracker =
44 NotifierStateTrackerFactory::GetForProfile(profile);
45 bool notifier_enabled = notifier_state_tracker->IsNotifierEnabled(
46 message_center::NotifierId(
47 message_center::NotifierId::APPLICATION, kNowNotifierId));
48 prefs->SetBoolean(prefs::kGoogleNowLauncherEnabled, notifier_enabled);