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

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

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
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 #include "chrome/browser/chromeos/locale_change_guard.h" 5 #include "chrome/browser/chromeos/locale_change_guard.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chromeos/login/user_manager.h" 10 #include "chrome/browser/chromeos/login/user_manager.h"
11 #include "chrome/browser/notifications/notification_delegate.h" 11 #include "chrome/browser/notifications/notification_delegate.h"
12 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "content/browser/tab_contents/tab_contents.h" 17 #include "content/browser/tab_contents/tab_contents.h"
18 #include "content/browser/user_metrics.h" 18 #include "content/browser/user_metrics.h"
19 #include "content/common/notification_service.h" 19 #include "content/public/browser/notification_service.h"
20 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
21 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
22 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
23 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
24 24
25 namespace chromeos { 25 namespace chromeos {
26 26
27 class LocaleChangeGuard::Delegate : public NotificationDelegate { 27 class LocaleChangeGuard::Delegate : public NotificationDelegate {
28 public: 28 public:
29 explicit Delegate(chromeos::LocaleChangeGuard* master) : master_(master) {} 29 explicit Delegate(chromeos::LocaleChangeGuard* master) : master_(master) {}
30 void Close(bool by_user); 30 void Close(bool by_user);
31 void Display() {} 31 void Display() {}
32 void Error() {} 32 void Error() {}
33 void Click() {} 33 void Click() {}
34 std::string id() const; 34 std::string id() const;
35 35
36 private: 36 private:
37 chromeos::LocaleChangeGuard* master_; 37 chromeos::LocaleChangeGuard* master_;
38 38
39 DISALLOW_COPY_AND_ASSIGN(Delegate); 39 DISALLOW_COPY_AND_ASSIGN(Delegate);
40 }; 40 };
41 41
42 LocaleChangeGuard::LocaleChangeGuard(Profile* profile) 42 LocaleChangeGuard::LocaleChangeGuard(Profile* profile)
43 : profile_(profile), 43 : profile_(profile),
44 note_(NULL), 44 note_(NULL),
45 reverted_(false) { 45 reverted_(false) {
46 DCHECK(profile_); 46 DCHECK(profile_);
47 registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_CHECKED, 47 registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_CHECKED,
48 NotificationService::AllSources()); 48 content::NotificationService::AllSources());
49 } 49 }
50 50
51 LocaleChangeGuard::~LocaleChangeGuard() {} 51 LocaleChangeGuard::~LocaleChangeGuard() {}
52 52
53 void LocaleChangeGuard::OnLogin() { 53 void LocaleChangeGuard::OnLogin() {
54 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 54 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
55 NotificationService::AllBrowserContextsAndSources()); 55 content::NotificationService::AllBrowserContextsAndSources());
56 } 56 }
57 57
58 void LocaleChangeGuard::RevertLocaleChange(const ListValue* list) { 58 void LocaleChangeGuard::RevertLocaleChange(const ListValue* list) {
59 if (note_ == NULL || 59 if (note_ == NULL ||
60 profile_ == NULL || 60 profile_ == NULL ||
61 from_locale_.empty() || 61 from_locale_.empty() ||
62 to_locale_.empty()) { 62 to_locale_.empty()) {
63 NOTREACHED(); 63 NOTREACHED();
64 return; 64 return;
65 } 65 }
(...skipping 14 matching lines...) Expand all
80 const content::NotificationDetails& details) { 80 const content::NotificationDetails& details) {
81 if (profile_ == NULL) { 81 if (profile_ == NULL) {
82 NOTREACHED(); 82 NOTREACHED();
83 return; 83 return;
84 } 84 }
85 switch (type) { 85 switch (type) {
86 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { 86 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: {
87 if (profile_ == content::Source<TabContents>(source)->browser_context()) { 87 if (profile_ == content::Source<TabContents>(source)->browser_context()) {
88 // We need to perform locale change check only once, so unsubscribe. 88 // We need to perform locale change check only once, so unsubscribe.
89 registrar_.Remove(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 89 registrar_.Remove(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
90 NotificationService::AllSources()); 90 content::NotificationService::AllSources());
91 Check(); 91 Check();
92 } 92 }
93 break; 93 break;
94 } 94 }
95 case chrome::NOTIFICATION_OWNERSHIP_CHECKED: { 95 case chrome::NOTIFICATION_OWNERSHIP_CHECKED: {
96 if (UserManager::Get()->current_user_is_owner()) { 96 if (UserManager::Get()->current_user_is_owner()) {
97 PrefService* local_state = g_browser_process->local_state(); 97 PrefService* local_state = g_browser_process->local_state();
98 if (local_state) { 98 if (local_state) {
99 PrefService* prefs = profile_->GetPrefs(); 99 PrefService* prefs = profile_->GetPrefs();
100 if (prefs == NULL) { 100 if (prefs == NULL) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 if (by_user) 223 if (by_user)
224 master_->AcceptLocaleChange(); 224 master_->AcceptLocaleChange();
225 } 225 }
226 226
227 std::string LocaleChangeGuard::Delegate::id() const { 227 std::string LocaleChangeGuard::Delegate::id() const {
228 // Arbitrary unique Id. 228 // Arbitrary unique Id.
229 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5"; 229 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5";
230 } 230 }
231 231
232 } // namespace chromeos 232 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/input_method_manager.cc ('k') | chrome/browser/chromeos/login/base_login_display_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698