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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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/pref_names.h" 16 #include "chrome/common/pref_names.h"
16 #include "content/browser/tab_contents/tab_contents.h" 17 #include "content/browser/tab_contents/tab_contents.h"
17 #include "content/browser/user_metrics.h" 18 #include "content/browser/user_metrics.h"
18 #include "content/common/notification_service.h" 19 #include "content/common/notification_service.h"
19 #include "content/common/notification_source.h" 20 #include "content/common/notification_source.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
21 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
22 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
23 24
24 namespace chromeos { 25 namespace chromeos {
(...skipping 11 matching lines...) Expand all
36 chromeos::LocaleChangeGuard* master_; 37 chromeos::LocaleChangeGuard* master_;
37 38
38 DISALLOW_COPY_AND_ASSIGN(Delegate); 39 DISALLOW_COPY_AND_ASSIGN(Delegate);
39 }; 40 };
40 41
41 LocaleChangeGuard::LocaleChangeGuard(Profile* profile) 42 LocaleChangeGuard::LocaleChangeGuard(Profile* profile)
42 : profile_(profile), 43 : profile_(profile),
43 note_(NULL), 44 note_(NULL),
44 reverted_(false) { 45 reverted_(false) {
45 DCHECK(profile_); 46 DCHECK(profile_);
46 registrar_.Add(this, NotificationType::OWNERSHIP_CHECKED, 47 registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_CHECKED,
47 NotificationService::AllSources()); 48 NotificationService::AllSources());
48 } 49 }
49 50
50 LocaleChangeGuard::~LocaleChangeGuard() {} 51 LocaleChangeGuard::~LocaleChangeGuard() {}
51 52
52 void LocaleChangeGuard::OnLogin() { 53 void LocaleChangeGuard::OnLogin() {
53 registrar_.Add(this, NotificationType::LOAD_COMPLETED_MAIN_FRAME, 54 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
54 NotificationService::AllSources()); 55 NotificationService::AllSources());
55 } 56 }
56 57
57 void LocaleChangeGuard::RevertLocaleChange(const ListValue* list) { 58 void LocaleChangeGuard::RevertLocaleChange(const ListValue* list) {
58 if (note_ == NULL || 59 if (note_ == NULL ||
59 profile_ == NULL || 60 profile_ == NULL ||
60 from_locale_.empty() || 61 from_locale_.empty() ||
61 to_locale_.empty()) { 62 to_locale_.empty()) {
62 NOTREACHED(); 63 NOTREACHED();
63 return; 64 return;
64 } 65 }
65 if (reverted_) 66 if (reverted_)
66 return; 67 return;
67 reverted_ = true; 68 reverted_ = true;
68 UserMetrics::RecordAction(UserMetricsAction("LanguageChange_Revert")); 69 UserMetrics::RecordAction(UserMetricsAction("LanguageChange_Revert"));
69 profile_->ChangeAppLocale( 70 profile_->ChangeAppLocale(
70 from_locale_, Profile::APP_LOCALE_CHANGED_VIA_REVERT); 71 from_locale_, Profile::APP_LOCALE_CHANGED_VIA_REVERT);
71 72
72 Browser* browser = Browser::GetTabbedBrowser(profile_, false); 73 Browser* browser = Browser::GetTabbedBrowser(profile_, false);
73 if (browser) 74 if (browser)
74 browser->ExecuteCommand(IDC_EXIT); 75 browser->ExecuteCommand(IDC_EXIT);
75 } 76 }
76 77
77 void LocaleChangeGuard::Observe(NotificationType type, 78 void LocaleChangeGuard::Observe(int type,
78 const NotificationSource& source, 79 const NotificationSource& source,
79 const NotificationDetails& details) { 80 const NotificationDetails& details) {
80 if (profile_ == NULL) { 81 if (profile_ == NULL) {
81 NOTREACHED(); 82 NOTREACHED();
82 return; 83 return;
83 } 84 }
84 switch (type.value) { 85 switch (type) {
85 case NotificationType::LOAD_COMPLETED_MAIN_FRAME: { 86 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: {
86 // We need to perform locale change check only once, so unsubscribe. 87 // We need to perform locale change check only once, so unsubscribe.
87 registrar_.Remove(this, NotificationType::LOAD_COMPLETED_MAIN_FRAME, 88 registrar_.Remove(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
88 NotificationService::AllSources()); 89 NotificationService::AllSources());
89 Check(); 90 Check();
90 break; 91 break;
91 } 92 }
92 case NotificationType::OWNERSHIP_CHECKED: { 93 case chrome::NOTIFICATION_OWNERSHIP_CHECKED: {
93 if (UserManager::Get()->current_user_is_owner()) { 94 if (UserManager::Get()->current_user_is_owner()) {
94 PrefService* local_state = g_browser_process->local_state(); 95 PrefService* local_state = g_browser_process->local_state();
95 if (local_state) { 96 if (local_state) {
96 PrefService* prefs = profile_->GetPrefs(); 97 PrefService* prefs = profile_->GetPrefs();
97 if (prefs == NULL) { 98 if (prefs == NULL) {
98 NOTREACHED(); 99 NOTREACHED();
99 return; 100 return;
100 } 101 }
101 std::string owner_locale = 102 std::string owner_locale =
102 prefs->GetString(prefs::kApplicationLocale); 103 prefs->GetString(prefs::kApplicationLocale);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 if (by_user) 221 if (by_user)
221 master_->AcceptLocaleChange(); 222 master_->AcceptLocaleChange();
222 } 223 }
223 224
224 std::string LocaleChangeGuard::Delegate::id() const { 225 std::string LocaleChangeGuard::Delegate::id() const {
225 // Arbitrary unique Id. 226 // Arbitrary unique Id.
226 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5"; 227 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5";
227 } 228 }
228 229
229 } // namespace chromeos 230 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/locale_change_guard.h ('k') | chrome/browser/chromeos/login/base_login_display_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698