OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/login/multi_profile_first_run_notification.h" | 5 #include "chrome/browser/chromeos/login/multi_profile_first_run_notification.h" |
6 | 6 |
7 #include "ash/system/system_notifier.h" | |
7 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
8 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
9 #include "chrome/browser/chromeos/login/user_manager.h" | 10 #include "chrome/browser/chromeos/login/user_manager.h" |
10 #include "chrome/browser/prefs/pref_service_syncable.h" | 11 #include "chrome/browser/prefs/pref_service_syncable.h" |
11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
14 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
16 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
17 #include "ui/message_center/message_center.h" | 18 #include "ui/message_center/message_center.h" |
18 #include "ui/message_center/notification.h" | 19 #include "ui/message_center/notification.h" |
19 #include "ui/message_center/notification_delegate.h" | 20 #include "ui/message_center/notification_delegate.h" |
20 | 21 |
21 using message_center::Notification; | 22 using message_center::Notification; |
22 | 23 |
23 namespace chromeos { | 24 namespace chromeos { |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 const char kNotificationId[] = "chrome:://login/multiprofile"; | 28 const char kNotificationId[] = "chrome:://login/multiprofile"; |
28 | 29 |
30 class MultiProfileFirstRunNotificationDelegate | |
31 : public message_center::NotificationDelegate { | |
32 public: | |
33 MultiProfileFirstRunNotificationDelegate(base::Closure callback) | |
xiyuan
2013/12/09 19:54:01
nit: const base::Closure&
stevenjb
2013/12/09 20:18:52
explicit
Also, maybe name 'user_close_callback'?
Jun Mukai
2013/12/09 21:23:43
Done.
Jun Mukai
2013/12/09 21:23:43
Done.
| |
34 : callback_(callback) {} | |
35 | |
36 // Overridden from message_center::NotificationDelegate: | |
37 virtual void Display() OVERRIDE {} | |
38 virtual void Error() OVERRIDE {} | |
39 virtual void Close(bool by_user) OVERRIDE { | |
40 if (by_user) | |
41 callback_.Run(); | |
42 } | |
43 virtual void Click() OVERRIDE {} | |
44 | |
45 protected: | |
46 virtual ~MultiProfileFirstRunNotificationDelegate() {} | |
47 | |
48 private: | |
49 base::Closure callback_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(MultiProfileFirstRunNotificationDelegate); | |
52 }; | |
53 | |
29 } // namespace | 54 } // namespace |
30 | 55 |
31 MultiProfileFirstRunNotification::MultiProfileFirstRunNotification() | 56 MultiProfileFirstRunNotification::MultiProfileFirstRunNotification() |
32 : weak_ptr_factory_(this) {} | 57 : weak_ptr_factory_(this) {} |
33 | 58 |
34 MultiProfileFirstRunNotification::~MultiProfileFirstRunNotification() {} | 59 MultiProfileFirstRunNotification::~MultiProfileFirstRunNotification() {} |
35 | 60 |
36 // static | 61 // static |
37 void MultiProfileFirstRunNotification::RegisterProfilePrefs( | 62 void MultiProfileFirstRunNotification::RegisterProfilePrefs( |
38 user_prefs::PrefRegistrySyncable* registry) { | 63 user_prefs::PrefRegistrySyncable* registry) { |
(...skipping 15 matching lines...) Expand all Loading... | |
54 const base::string16 title; | 79 const base::string16 title; |
55 const base::string16 display_source; | 80 const base::string16 display_source; |
56 scoped_ptr<Notification> notification(new Notification( | 81 scoped_ptr<Notification> notification(new Notification( |
57 message_center::NOTIFICATION_TYPE_SIMPLE, | 82 message_center::NOTIFICATION_TYPE_SIMPLE, |
58 kNotificationId, | 83 kNotificationId, |
59 title, | 84 title, |
60 l10n_util::GetStringUTF16(IDS_MULTI_PROFILES_WARNING), | 85 l10n_util::GetStringUTF16(IDS_MULTI_PROFILES_WARNING), |
61 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 86 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
62 IDR_NOTIFICATION_ALERT), | 87 IDR_NOTIFICATION_ALERT), |
63 display_source, | 88 display_source, |
64 message_center::NotifierId(), | 89 message_center::NotifierId( |
90 message_center::NotifierId::SYSTEM_COMPONENT, | |
91 ash::system_notifier::kNotifierMultiProfileFirstRun), | |
65 message_center::RichNotificationData(), | 92 message_center::RichNotificationData(), |
66 new message_center::HandleNotificationClickedDelegate( | 93 new MultiProfileFirstRunNotificationDelegate( |
67 base::Bind(&MultiProfileFirstRunNotification::OnDismissed, | 94 base::Bind(&MultiProfileFirstRunNotification::OnDismissed, |
68 weak_ptr_factory_.GetWeakPtr(), | 95 weak_ptr_factory_.GetWeakPtr(), |
69 user_profile)))); | 96 user_profile)))); |
70 notification->SetSystemPriority(); | 97 notification->SetSystemPriority(); |
71 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 98 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); |
72 } | 99 } |
73 | 100 |
74 void MultiProfileFirstRunNotification::OnDismissed(Profile* user_profile) { | 101 void MultiProfileFirstRunNotification::OnDismissed(Profile* user_profile) { |
75 user_profile->GetPrefs()->SetBoolean( | 102 user_profile->GetPrefs()->SetBoolean( |
76 prefs::kMultiProfileNotificationDismissed, true); | 103 prefs::kMultiProfileNotificationDismissed, true); |
77 } | 104 } |
78 | 105 |
79 } // namespace chromeos | 106 } // namespace chromeos |
OLD | NEW |