| 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 "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "chrome/browser/chromeos/notifications/system_notification.h" | |
| 12 #include "chrome/browser/notifications/notification_delegate.h" | |
| 13 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 14 | 12 |
| 15 class ListValue; | 13 class ListValue; |
| 16 class TabContents; | 14 class TabContents; |
| 17 | 15 |
| 18 namespace chromeos { | 16 namespace chromeos { |
| 19 | 17 |
| 18 class SystemNotification; |
| 19 |
| 20 class LocaleChangeGuard { | 20 class LocaleChangeGuard { |
| 21 public: | 21 public: |
| 22 // When called first time for user profile: performs check whether | 22 // When called first time for user profile: performs check whether |
| 23 // locale has been changed automatically recently (based on synchronized user | 23 // locale has been changed automatically recently (based on synchronized user |
| 24 // preference). If so: shows notification that allows user to revert change. | 24 // preference). If so: shows notification that allows user to revert change. |
| 25 // On subsequent calls: does nothing (hopefully fast). | 25 // On subsequent calls: does nothing (hopefully fast). |
| 26 static void Check(TabContents* tab_contents); | 26 static void Check(TabContents* tab_contents); |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 class Delegate : public NotificationDelegate { | 29 class Delegate; |
| 30 public: | |
| 31 explicit Delegate(chromeos::LocaleChangeGuard* master) : master_(master) {} | |
| 32 void Close(bool by_user); | |
| 33 void Display() {} | |
| 34 void Error() {} | |
| 35 void Click() {} | |
| 36 std::string id() const; | |
| 37 | |
| 38 private: | |
| 39 chromeos::LocaleChangeGuard* master_; | |
| 40 | |
| 41 DISALLOW_COPY_AND_ASSIGN(Delegate); | |
| 42 }; | |
| 43 | 30 |
| 44 LocaleChangeGuard(); | 31 LocaleChangeGuard(); |
| 45 void CheckLocaleChange(TabContents* tab_contents); | 32 void CheckLocaleChange(TabContents* tab_contents); |
| 46 void RevertLocaleChange(const ListValue* list); | 33 void RevertLocaleChange(const ListValue* list); |
| 47 void AcceptLocaleChange(); | 34 void AcceptLocaleChange(); |
| 48 | 35 |
| 49 std::string from_locale_; | 36 std::string from_locale_; |
| 50 std::string to_locale_; | 37 std::string to_locale_; |
| 51 ProfileId profile_id_; | 38 ProfileId profile_id_; |
| 52 TabContents* tab_contents_; | 39 TabContents* tab_contents_; |
| 53 scoped_ptr<chromeos::SystemNotification> note_; | 40 scoped_ptr<chromeos::SystemNotification> note_; |
| 54 bool reverted_; | 41 bool reverted_; |
| 55 | 42 |
| 56 friend struct base::DefaultLazyInstanceTraits<LocaleChangeGuard>; | 43 friend struct base::DefaultLazyInstanceTraits<LocaleChangeGuard>; |
| 57 }; | 44 }; |
| 58 | 45 |
| 59 } // namespace chromeos | 46 } // namespace chromeos |
| 60 | 47 |
| 61 #endif // CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ | 48 #endif // CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ |
| OLD | NEW |