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

Side by Side Diff: chrome/browser/chromeos/locale_change_guard.h

Issue 10391177: Add TrayLocale for locale change notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase w/ icons in tot Created 8 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « ash/system/tray/system_tray.cc ('k') | chrome/browser/chromeos/locale_change_guard.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/system/locale/locale_observer.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/chromeos/notifications/system_notification.h" 16 #include "chrome/browser/chromeos/notifications/system_notification.h"
16 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
18 #include "content/public/browser/notification_types.h" 19 #include "content/public/browser/notification_types.h"
19 20
20 class Profile; 21 class Profile;
21 22
22 namespace base { 23 namespace base {
23 class ListValue; 24 class ListValue;
24 } 25 }
25 26
26 namespace chromeos { 27 namespace chromeos {
27 28
28 // Performs check whether locale has been changed automatically recently 29 // Performs check whether locale has been changed automatically recently
29 // (based on synchronized user preference). If so: shows notification that 30 // (based on synchronized user preference). If so: shows notification that
30 // allows user to revert change. 31 // allows user to revert change.
31 class LocaleChangeGuard : public content::NotificationObserver, 32 class LocaleChangeGuard : public content::NotificationObserver,
33 public ash::LocaleObserver::Delegate,
32 public base::SupportsWeakPtr<LocaleChangeGuard> { 34 public base::SupportsWeakPtr<LocaleChangeGuard> {
33 public: 35 public:
34 explicit LocaleChangeGuard(Profile* profile); 36 explicit LocaleChangeGuard(Profile* profile);
35 virtual ~LocaleChangeGuard(); 37 virtual ~LocaleChangeGuard();
36 38
39 // ash::LocaleChangeDelegate implementation.
40 virtual void AcceptLocaleChange() OVERRIDE;
41 virtual void RevertLocaleChange() OVERRIDE;
42
37 // Called just before changing locale. 43 // Called just before changing locale.
38 void PrepareChangingLocale( 44 void PrepareChangingLocale(
39 const std::string& from_locale, const std::string& to_locale); 45 const std::string& from_locale, const std::string& to_locale);
40 46
41 // Called after login. 47 // Called after login.
42 void OnLogin(); 48 void OnLogin();
43 49
44 private: 50 private:
45 class Delegate; 51 class Delegate;
46 52
47 void RevertLocaleChange(const base::ListValue* list); 53 void RevertLocaleChangeCallback(const base::ListValue* list);
48 void AcceptLocaleChange();
49 void Check(); 54 void Check();
50 55
51 // content::NotificationObserver implementation. 56 // content::NotificationObserver implementation.
52 virtual void Observe(int type, 57 virtual void Observe(int type,
53 const content::NotificationSource& source, 58 const content::NotificationSource& source,
54 const content::NotificationDetails& details) OVERRIDE; 59 const content::NotificationDetails& details) OVERRIDE;
55 60
56 std::string from_locale_; 61 std::string from_locale_;
57 std::string to_locale_; 62 std::string to_locale_;
58 Profile* profile_; 63 Profile* profile_;
59 scoped_ptr<chromeos::SystemNotification> note_; 64 scoped_ptr<chromeos::SystemNotification> note_;
60 bool reverted_; 65 bool reverted_;
61 content::NotificationRegistrar registrar_; 66 content::NotificationRegistrar registrar_;
62 67
63 // We want to show locale change notification in previous language however 68 // We want to show locale change notification in previous language however
64 // we cannot directly load strings for non-current locale. So we cache 69 // we cannot directly load strings for non-current locale. So we cache
65 // messages before locale change. 70 // messages before locale change.
66 string16 title_text_; 71 string16 title_text_;
67 string16 message_text_; 72 string16 message_text_;
68 string16 revert_link_text_; 73 string16 revert_link_text_;
69 }; 74 };
70 75
71 } // namespace chromeos 76 } // namespace chromeos
72 77
73 #endif // CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_ 78 #endif // CHROME_BROWSER_CHROMEOS_LOCALE_CHANGE_GUARD_H_
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.cc ('k') | chrome/browser/chromeos/locale_change_guard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698