| 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 #include "chrome/browser/chromeos/locale_change_guard.h" | 5 #include "chrome/browser/chromeos/locale_change_guard.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chromeos/login/user_manager.h" | 15 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 16 #include "chrome/browser/notifications/notification_delegate.h" | 16 #include "chrome/browser/notifications/notification_delegate.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_commands.h" | 20 #include "chrome/browser/ui/browser_commands.h" |
| 21 #include "chrome/browser/ui/browser_finder.h" | 21 #include "chrome/browser/ui/browser_finder.h" |
| 22 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 53 chromeos::LocaleChangeGuard* master_; | 53 chromeos::LocaleChangeGuard* master_; |
| 54 | 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(Delegate); | 55 DISALLOW_COPY_AND_ASSIGN(Delegate); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 LocaleChangeGuard::LocaleChangeGuard(Profile* profile) | 58 LocaleChangeGuard::LocaleChangeGuard(Profile* profile) |
| 59 : profile_(profile), | 59 : profile_(profile), |
| 60 note_(NULL), | 60 note_(NULL), |
| 61 reverted_(false) { | 61 reverted_(false) { |
| 62 DCHECK(profile_); | 62 DCHECK(profile_); |
| 63 registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_CHECKED, | 63 registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, |
| 64 content::NotificationService::AllSources()); | 64 content::NotificationService::AllSources()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 LocaleChangeGuard::~LocaleChangeGuard() {} | 67 LocaleChangeGuard::~LocaleChangeGuard() {} |
| 68 | 68 |
| 69 void LocaleChangeGuard::OnLogin() { | 69 void LocaleChangeGuard::OnLogin() { |
| 70 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 70 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 71 content::NotificationService::AllBrowserContextsAndSources()); | 71 content::NotificationService::AllBrowserContextsAndSources()); |
| 72 } | 72 } |
| 73 | 73 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { | 105 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { |
| 106 if (profile_ == | 106 if (profile_ == |
| 107 content::Source<WebContents>(source)->GetBrowserContext()) { | 107 content::Source<WebContents>(source)->GetBrowserContext()) { |
| 108 // We need to perform locale change check only once, so unsubscribe. | 108 // We need to perform locale change check only once, so unsubscribe. |
| 109 registrar_.Remove(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 109 registrar_.Remove(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 110 content::NotificationService::AllSources()); | 110 content::NotificationService::AllSources()); |
| 111 Check(); | 111 Check(); |
| 112 } | 112 } |
| 113 break; | 113 break; |
| 114 } | 114 } |
| 115 case chrome::NOTIFICATION_OWNERSHIP_CHECKED: { | 115 case chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED: { |
| 116 if (UserManager::Get()->IsCurrentUserOwner()) { | 116 if (DeviceSettingsService::Get()->HasPrivateOwnerKey()) { |
| 117 PrefService* local_state = g_browser_process->local_state(); | 117 PrefService* local_state = g_browser_process->local_state(); |
| 118 if (local_state) { | 118 if (local_state) { |
| 119 PrefService* prefs = profile_->GetPrefs(); | 119 PrefService* prefs = profile_->GetPrefs(); |
| 120 if (prefs == NULL) { | 120 if (prefs == NULL) { |
| 121 NOTREACHED(); | 121 NOTREACHED(); |
| 122 return; | 122 return; |
| 123 } | 123 } |
| 124 std::string owner_locale = | 124 std::string owner_locale = |
| 125 prefs->GetString(prefs::kApplicationLocale); | 125 prefs->GetString(prefs::kApplicationLocale); |
| 126 if (!owner_locale.empty()) | 126 if (!owner_locale.empty()) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 if (by_user) | 248 if (by_user) |
| 249 master_->AcceptLocaleChange(); | 249 master_->AcceptLocaleChange(); |
| 250 } | 250 } |
| 251 | 251 |
| 252 std::string LocaleChangeGuard::Delegate::id() const { | 252 std::string LocaleChangeGuard::Delegate::id() const { |
| 253 // Arbitrary unique Id. | 253 // Arbitrary unique Id. |
| 254 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5"; | 254 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5"; |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace chromeos | 257 } // namespace chromeos |
| OLD | NEW |