OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/chromeos/notifications/system_notification.h" | 13 #include "chrome/browser/chromeos/notifications/system_notification.h" |
14 #include "content/common/content_notification_types.h" | 14 #include "content/common/content_notification_types.h" |
15 #include "content/common/notification_observer.h" | 15 #include "content/common/notification_observer.h" |
16 #include "content/common/notification_registrar.h" | 16 #include "content/common/notification_registrar.h" |
17 | 17 |
18 class ListValue; | |
19 class NotificationDetails; | 18 class NotificationDetails; |
20 class NotificationSource; | 19 class NotificationSource; |
21 class Profile; | 20 class Profile; |
22 | 21 |
| 22 namespace base { |
| 23 class ListValue; |
| 24 } |
| 25 |
23 namespace chromeos { | 26 namespace chromeos { |
24 | 27 |
25 // Performs check whether locale has been changed automatically recently | 28 // Performs check whether locale has been changed automatically recently |
26 // (based on synchronized user preference). If so: shows notification that | 29 // (based on synchronized user preference). If so: shows notification that |
27 // allows user to revert change. | 30 // allows user to revert change. |
28 class LocaleChangeGuard : public NotificationObserver { | 31 class LocaleChangeGuard : public NotificationObserver { |
29 public: | 32 public: |
30 explicit LocaleChangeGuard(Profile* profile); | 33 explicit LocaleChangeGuard(Profile* profile); |
31 virtual ~LocaleChangeGuard(); | 34 virtual ~LocaleChangeGuard(); |
32 | 35 |
33 // Called just before changing locale. | 36 // Called just before changing locale. |
34 void PrepareChangingLocale( | 37 void PrepareChangingLocale( |
35 const std::string& from_locale, const std::string& to_locale); | 38 const std::string& from_locale, const std::string& to_locale); |
36 | 39 |
37 // Called after login. | 40 // Called after login. |
38 void OnLogin(); | 41 void OnLogin(); |
39 | 42 |
40 private: | 43 private: |
41 class Delegate; | 44 class Delegate; |
42 | 45 |
43 void RevertLocaleChange(const ListValue* list); | 46 void RevertLocaleChange(const base::ListValue* list); |
44 void AcceptLocaleChange(); | 47 void AcceptLocaleChange(); |
45 void Check(); | 48 void Check(); |
46 | 49 |
47 // NotificationObserver implementation. | 50 // NotificationObserver implementation. |
48 virtual void Observe(int type, | 51 virtual void Observe(int type, |
49 const NotificationSource& source, | 52 const NotificationSource& source, |
50 const NotificationDetails& details); | 53 const NotificationDetails& details); |
51 | 54 |
52 std::string from_locale_; | 55 std::string from_locale_; |
53 std::string to_locale_; | 56 std::string to_locale_; |
54 Profile* profile_; | 57 Profile* profile_; |
55 scoped_ptr<chromeos::SystemNotification> note_; | 58 scoped_ptr<chromeos::SystemNotification> note_; |
56 bool reverted_; | 59 bool reverted_; |
57 NotificationRegistrar registrar_; | 60 NotificationRegistrar registrar_; |
58 | 61 |
59 // We want to show locale change notification in previous language however | 62 // We want to show locale change notification in previous language however |
60 // we cannot directly load strings for non-current locale. So we cache | 63 // we cannot directly load strings for non-current locale. So we cache |
61 // messages before locale change. | 64 // messages before locale change. |
62 string16 title_text_; | 65 string16 title_text_; |
63 string16 message_text_; | 66 string16 message_text_; |
64 string16 revert_link_text_; | 67 string16 revert_link_text_; |
65 }; | 68 }; |
66 | 69 |
67 } // namespace chromeos | 70 } // namespace chromeos |
68 | 71 |
69 #endif // CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ | 72 #endif // CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ |
OLD | NEW |