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

Side by Side Diff: chrome/browser/notifications/extension_welcome_notification.cc

Issue 2459823002: [Sync] Rename syncable_prefs to sync_preferences. (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/notifications/extension_welcome_notification.h" 5 #include "chrome/browser/notifications/extension_welcome_notification.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/guid.h" 11 #include "base/guid.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/notifications/notification.h" 19 #include "chrome/browser/notifications/notification.h"
20 #include "chrome/browser/prefs/pref_service_syncable_util.h" 20 #include "chrome/browser/prefs/pref_service_syncable_util.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/browser_navigator.h" 22 #include "chrome/browser/ui/browser_navigator.h"
23 #include "chrome/browser/ui/browser_navigator_params.h" 23 #include "chrome/browser/ui/browser_navigator_params.h"
24 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
25 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
26 #include "chrome/grit/generated_resources.h" 26 #include "chrome/grit/generated_resources.h"
27 #include "chrome/grit/theme_resources.h" 27 #include "chrome/grit/theme_resources.h"
28 #include "components/pref_registry/pref_registry_syncable.h" 28 #include "components/pref_registry/pref_registry_syncable.h"
29 #include "components/prefs/pref_service.h" 29 #include "components/prefs/pref_service.h"
30 #include "components/syncable_prefs/pref_service_syncable.h" 30 #include "components/sync_preferences/pref_service_syncable.h"
31 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/base/resource/resource_bundle.h" 32 #include "ui/base/resource/resource_bundle.h"
33 #include "ui/message_center/message_center.h" 33 #include "ui/message_center/message_center.h"
34 #include "ui/message_center/notification.h" 34 #include "ui/message_center/notification.h"
35 #include "ui/message_center/notification_delegate.h" 35 #include "ui/message_center/notification_delegate.h"
36 #include "ui/message_center/notification_types.h" 36 #include "ui/message_center/notification_types.h"
37 37
38 const int ExtensionWelcomeNotification::kRequestedShowTimeDays = 14; 38 const int ExtensionWelcomeNotification::kRequestedShowTimeDays = 14;
39 const char ExtensionWelcomeNotification::kChromeNowExtensionID[] = 39 const char ExtensionWelcomeNotification::kChromeNowExtensionID[] =
40 "pafkbggdmjlpgkdkcbjmhmfcdpncadgh"; 40 "pafkbggdmjlpgkdkcbjmhmfcdpncadgh";
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 if (delayed_notification_) { 172 if (delayed_notification_) {
173 delayed_notification_.reset(); 173 delayed_notification_.reset();
174 PrefServiceSyncableFromProfile(profile_)->RemoveObserver(this); 174 PrefServiceSyncableFromProfile(profile_)->RemoveObserver(this);
175 } else { 175 } else {
176 HideWelcomeNotification(); 176 HideWelcomeNotification();
177 } 177 }
178 } 178 }
179 179
180 void ExtensionWelcomeNotification::OnIsSyncingChanged() { 180 void ExtensionWelcomeNotification::OnIsSyncingChanged() {
181 DCHECK(delayed_notification_); 181 DCHECK(delayed_notification_);
182 syncable_prefs::PrefServiceSyncable* const pref_service_syncable = 182 sync_preferences::PrefServiceSyncable* const pref_service_syncable =
183 PrefServiceSyncableFromProfile(profile_); 183 PrefServiceSyncableFromProfile(profile_);
184 if (pref_service_syncable->IsSyncing()) { 184 if (pref_service_syncable->IsSyncing()) {
185 pref_service_syncable->RemoveObserver(this); 185 pref_service_syncable->RemoveObserver(this);
186 std::unique_ptr<Notification> previous_notification( 186 std::unique_ptr<Notification> previous_notification(
187 delayed_notification_.release()); 187 delayed_notification_.release());
188 ShowWelcomeNotificationIfNecessary(*(previous_notification.get())); 188 ShowWelcomeNotificationIfNecessary(*(previous_notification.get()));
189 } 189 }
190 } 190 }
191 191
192 void ExtensionWelcomeNotification::ShowWelcomeNotificationIfNecessary( 192 void ExtensionWelcomeNotification::ShowWelcomeNotificationIfNecessary(
193 const Notification& notification) { 193 const Notification& notification) {
194 if ((notification.notifier_id() == notifier_id_) && !delayed_notification_) { 194 if ((notification.notifier_id() == notifier_id_) && !delayed_notification_) {
195 syncable_prefs::PrefServiceSyncable* const pref_service_syncable = 195 sync_preferences::PrefServiceSyncable* const pref_service_syncable =
196 PrefServiceSyncableFromProfile(profile_); 196 PrefServiceSyncableFromProfile(profile_);
197 if (pref_service_syncable->IsSyncing()) { 197 if (pref_service_syncable->IsSyncing()) {
198 PrefService* const pref_service = profile_->GetPrefs(); 198 PrefService* const pref_service = profile_->GetPrefs();
199 if (!UserHasDismissedWelcomeNotification()) { 199 if (!UserHasDismissedWelcomeNotification()) {
200 const PopUpRequest pop_up_request = 200 const PopUpRequest pop_up_request =
201 pref_service->GetBoolean( 201 pref_service->GetBoolean(
202 prefs::kWelcomeNotificationPreviouslyPoppedUp) 202 prefs::kWelcomeNotificationPreviouslyPoppedUp)
203 ? POP_UP_HIDDEN 203 ? POP_UP_HIDDEN
204 : POP_UP_SHOWN; 204 : POP_UP_SHOWN;
205 if (pop_up_request == POP_UP_SHOWN) { 205 if (pop_up_request == POP_UP_SHOWN) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 prefs::kWelcomeNotificationExpirationTimestamp, 352 prefs::kWelcomeNotificationExpirationTimestamp,
353 (delegate_->GetCurrentTime() + 353 (delegate_->GetCurrentTime() +
354 base::TimeDelta::FromDays(kRequestedShowTimeDays)).ToInternalValue()); 354 base::TimeDelta::FromDays(kRequestedShowTimeDays)).ToInternalValue());
355 } 355 }
356 356
357 bool ExtensionWelcomeNotification::IsWelcomeNotificationExpired() const { 357 bool ExtensionWelcomeNotification::IsWelcomeNotificationExpired() const {
358 const base::Time expiration_timestamp = GetExpirationTimestamp(); 358 const base::Time expiration_timestamp = GetExpirationTimestamp();
359 return !expiration_timestamp.is_null() && 359 return !expiration_timestamp.is_null() &&
360 (expiration_timestamp <= delegate_->GetCurrentTime()); 360 (expiration_timestamp <= delegate_->GetCurrentTime());
361 } 361 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698