| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/system/locale/locale_observer.h" | 10 #include "ash/system/locale/locale_observer.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // (based on synchronized user preference). If so: shows notification that | 30 // (based on synchronized user preference). If so: shows notification that |
| 31 // allows user to revert change. | 31 // allows user to revert change. |
| 32 class LocaleChangeGuard : public content::NotificationObserver, | 32 class LocaleChangeGuard : public content::NotificationObserver, |
| 33 public ash::LocaleObserver::Delegate, | 33 public ash::LocaleObserver::Delegate, |
| 34 public base::SupportsWeakPtr<LocaleChangeGuard> { | 34 public base::SupportsWeakPtr<LocaleChangeGuard> { |
| 35 public: | 35 public: |
| 36 explicit LocaleChangeGuard(Profile* profile); | 36 explicit LocaleChangeGuard(Profile* profile); |
| 37 virtual ~LocaleChangeGuard(); | 37 virtual ~LocaleChangeGuard(); |
| 38 | 38 |
| 39 // ash::LocaleChangeDelegate implementation. | 39 // ash::LocaleChangeDelegate implementation. |
| 40 virtual void AcceptLocaleChange() OVERRIDE; | 40 virtual void AcceptLocaleChange() override; |
| 41 virtual void RevertLocaleChange() OVERRIDE; | 41 virtual void RevertLocaleChange() override; |
| 42 | 42 |
| 43 // Called just before changing locale. | 43 // Called just before changing locale. |
| 44 void PrepareChangingLocale( | 44 void PrepareChangingLocale( |
| 45 const std::string& from_locale, const std::string& to_locale); | 45 const std::string& from_locale, const std::string& to_locale); |
| 46 | 46 |
| 47 // Called after login. | 47 // Called after login. |
| 48 void OnLogin(); | 48 void OnLogin(); |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 FRIEND_TEST_ALL_PREFIXES(LocaleChangeGuardTest, | 51 FRIEND_TEST_ALL_PREFIXES(LocaleChangeGuardTest, |
| 52 ShowNotificationLocaleChanged); | 52 ShowNotificationLocaleChanged); |
| 53 FRIEND_TEST_ALL_PREFIXES(LocaleChangeGuardTest, | 53 FRIEND_TEST_ALL_PREFIXES(LocaleChangeGuardTest, |
| 54 ShowNotificationLocaleChangedList); | 54 ShowNotificationLocaleChangedList); |
| 55 | 55 |
| 56 void RevertLocaleChangeCallback(const base::ListValue* list); | 56 void RevertLocaleChangeCallback(const base::ListValue* list); |
| 57 void Check(); | 57 void Check(); |
| 58 | 58 |
| 59 // content::NotificationObserver implementation. | 59 // content::NotificationObserver implementation. |
| 60 virtual void Observe(int type, | 60 virtual void Observe(int type, |
| 61 const content::NotificationSource& source, | 61 const content::NotificationSource& source, |
| 62 const content::NotificationDetails& details) OVERRIDE; | 62 const content::NotificationDetails& details) override; |
| 63 | 63 |
| 64 // Returns true if we should notify user about automatic locale change. | 64 // Returns true if we should notify user about automatic locale change. |
| 65 static bool ShouldShowLocaleChangeNotification(const std::string& from_locale, | 65 static bool ShouldShowLocaleChangeNotification(const std::string& from_locale, |
| 66 const std::string& to_locale); | 66 const std::string& to_locale); |
| 67 | 67 |
| 68 static const char* const* GetSkipShowNotificationLanguagesForTesting(); | 68 static const char* const* GetSkipShowNotificationLanguagesForTesting(); |
| 69 static size_t GetSkipShowNotificationLanguagesSizeForTesting(); | 69 static size_t GetSkipShowNotificationLanguagesSizeForTesting(); |
| 70 | 70 |
| 71 std::string from_locale_; | 71 std::string from_locale_; |
| 72 std::string to_locale_; | 72 std::string to_locale_; |
| 73 Profile* profile_; | 73 Profile* profile_; |
| 74 bool reverted_; | 74 bool reverted_; |
| 75 bool session_started_; | 75 bool session_started_; |
| 76 bool main_frame_loaded_; | 76 bool main_frame_loaded_; |
| 77 content::NotificationRegistrar registrar_; | 77 content::NotificationRegistrar registrar_; |
| 78 | 78 |
| 79 // We want to show locale change notification in previous language however | 79 // We want to show locale change notification in previous language however |
| 80 // we cannot directly load strings for non-current locale. So we cache | 80 // we cannot directly load strings for non-current locale. So we cache |
| 81 // messages before locale change. | 81 // messages before locale change. |
| 82 base::string16 title_text_; | 82 base::string16 title_text_; |
| 83 base::string16 message_text_; | 83 base::string16 message_text_; |
| 84 base::string16 revert_link_text_; | 84 base::string16 revert_link_text_; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 } // namespace chromeos | 87 } // namespace chromeos |
| 88 | 88 |
| 89 #endif // CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ | 89 #endif // CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ |
| OLD | NEW |