| 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 #include "chrome/browser/chromeos/status/input_method_menu.h" | 5 #include "chrome/browser/chromeos/status/input_method_menu.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/time.h" | 12 #include "base/time.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 15 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 16 #include "chrome/browser/chromeos/language_preferences.h" | 16 #include "chrome/browser/chromeos/language_preferences.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 20 #include "content/browser/user_metrics.h" | 20 #include "content/browser/user_metrics.h" |
| 21 #include "content/common/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 22 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 23 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/base/models/simple_menu_model.h" | 25 #include "ui/base/models/simple_menu_model.h" |
| 26 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
| 27 #include "views/controls/menu/menu_model_adapter.h" | 27 #include "views/controls/menu/menu_model_adapter.h" |
| 28 #include "views/controls/menu/menu_runner.h" | 28 #include "views/controls/menu/menu_runner.h" |
| 29 #include "views/controls/menu/submenu_view.h" | 29 #include "views/controls/menu/submenu_view.h" |
| 30 #include "views/widget/widget.h" | 30 #include "views/widget/widget.h" |
| 31 | 31 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 prefs::kLanguageCurrentInputMethod, pref_service, this); | 158 prefs::kLanguageCurrentInputMethod, pref_service, this); |
| 159 } | 159 } |
| 160 | 160 |
| 161 InputMethodManager* manager = InputMethodManager::GetInstance(); | 161 InputMethodManager* manager = InputMethodManager::GetInstance(); |
| 162 if (screen_mode_ == StatusAreaHost::kViewsLoginMode || | 162 if (screen_mode_ == StatusAreaHost::kViewsLoginMode || |
| 163 screen_mode_ == StatusAreaHost::kWebUILoginMode) { | 163 screen_mode_ == StatusAreaHost::kWebUILoginMode) { |
| 164 // This button is for the login screen. | 164 // This button is for the login screen. |
| 165 manager->AddPreLoginPreferenceObserver(this); | 165 manager->AddPreLoginPreferenceObserver(this); |
| 166 registrar_.Add(this, | 166 registrar_.Add(this, |
| 167 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 167 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 168 NotificationService::AllSources()); | 168 content::NotificationService::AllSources()); |
| 169 } else if (screen_mode_ == StatusAreaHost::kBrowserMode) { | 169 } else if (screen_mode_ == StatusAreaHost::kBrowserMode) { |
| 170 manager->AddPostLoginPreferenceObserver(this); | 170 manager->AddPostLoginPreferenceObserver(this); |
| 171 } | 171 } |
| 172 | 172 |
| 173 // AddObserver() should be called after AddXXXLoginPreferenceObserver. This is | 173 // AddObserver() should be called after AddXXXLoginPreferenceObserver. This is |
| 174 // because when the function is called FirstObserverIsAdded might be called | 174 // because when the function is called FirstObserverIsAdded might be called |
| 175 // back, and FirstObserverIsAdded might then might call ChangeInputMethod() in | 175 // back, and FirstObserverIsAdded might then might call ChangeInputMethod() in |
| 176 // InputMethodManager. We have to prevent the manager function from calling | 176 // InputMethodManager. We have to prevent the manager function from calling |
| 177 // callback functions like InputMethodChanged since they touch (yet | 177 // callback functions like InputMethodChanged since they touch (yet |
| 178 // uninitialized) UI elements. | 178 // uninitialized) UI elements. |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 if (screen_mode_ == StatusAreaHost::kViewsLoginMode || | 719 if (screen_mode_ == StatusAreaHost::kViewsLoginMode || |
| 720 screen_mode_ == StatusAreaHost::kWebUILoginMode) { | 720 screen_mode_ == StatusAreaHost::kWebUILoginMode) { |
| 721 manager->RemovePreLoginPreferenceObserver(this); | 721 manager->RemovePreLoginPreferenceObserver(this); |
| 722 } else if (screen_mode_ == StatusAreaHost::kBrowserMode) { | 722 } else if (screen_mode_ == StatusAreaHost::kBrowserMode) { |
| 723 manager->RemovePostLoginPreferenceObserver(this); | 723 manager->RemovePostLoginPreferenceObserver(this); |
| 724 } | 724 } |
| 725 manager->RemoveObserver(this); | 725 manager->RemoveObserver(this); |
| 726 } | 726 } |
| 727 | 727 |
| 728 } // namespace chromeos | 728 } // namespace chromeos |
| OLD | NEW |