OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/app_list/google_now_extension.h" | 5 #include "chrome/browser/ui/app_list/google_now_extension.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | |
8 #include "chrome/browser/notifications/desktop_notification_service.h" | |
9 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | |
10 #include "chrome/browser/profiles/profile.h" | |
11 #include "chrome/common/pref_names.h" | |
7 #include "components/variations/variations_associated_data.h" | 12 #include "components/variations/variations_associated_data.h" |
8 | 13 |
9 namespace { | 14 namespace { |
10 const char kGoogleNowExtensionFieldTrialName[] = "GoogleNowExtension"; | 15 const char kGoogleNowExtensionFieldTrialName[] = "GoogleNowExtension"; |
16 | |
17 // Extension ID for previous Now notifications component. | |
18 const char kNowNotifierId[] = "pafkbggdmjlpgkdkcbjmhmfcdpncadgh"; | |
11 }; // namespace | 19 }; // namespace |
12 | 20 |
13 bool GetGoogleNowExtensionId(std::string* extension_id) { | 21 bool GetGoogleNowExtensionId(std::string* extension_id) { |
14 *extension_id = variations::GetVariationParamValue( | 22 *extension_id = variations::GetVariationParamValue( |
15 kGoogleNowExtensionFieldTrialName, "id"); | 23 kGoogleNowExtensionFieldTrialName, "id"); |
16 return !extension_id->empty(); | 24 return !extension_id->empty(); |
17 } | 25 } |
26 | |
27 // TODO(skare): Remove this if/when the Now Notifications component is | |
28 // deprecated. http://crbug.com/459846 | |
29 void MigrateGoogleNowPrefs(Profile* profile) { | |
30 std::string now_extension_id; | |
31 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.
| |
32 return; | |
33 } | |
34 | |
35 PrefService* prefs = profile->GetPrefs(); | |
36 const PrefService::Preference* enabled_pref = | |
37 prefs->FindPreference(prefs::kGoogleNowLauncherEnabled); | |
38 | |
39 // If the pref is not its default value, migration was performed. | |
40 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.
| |
41 return; | |
42 } | |
43 | |
44 DesktopNotificationService* const notification_service = | |
45 DesktopNotificationServiceFactory::GetForProfile(profile); | |
46 bool notifier_enabled = notification_service->IsNotifierEnabled( | |
47 message_center::NotifierId( | |
48 message_center::NotifierId::APPLICATION, kNowNotifierId)); | |
49 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
| |
50 } | |
OLD | NEW |