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

Side by Side Diff: chrome/browser/chromeos/status/caps_lock_menu_button.cc

Issue 9264004: Make almost all public functions in XKeyboard pure virtual (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 11 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) 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/status/caps_lock_menu_button.h" 5 #include "chrome/browser/chromeos/status/caps_lock_menu_button.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
10 #include "chrome/browser/chromeos/input_method/xkeyboard.h" 11 #include "chrome/browser/chromeos/input_method/xkeyboard.h"
11 #include "chrome/browser/chromeos/login/screen_locker.h" 12 #include "chrome/browser/chromeos/login/screen_locker.h"
12 #include "chrome/browser/chromeos/status/status_area_bubble.h" 13 #include "chrome/browser/chromeos/status/status_area_bubble.h"
13 #include "chrome/browser/chromeos/system/runtime_environment.h" 14 #include "chrome/browser/chromeos/system/runtime_environment.h"
14 #include "chrome/browser/chromeos/view_ids.h" 15 #include "chrome/browser/chromeos/view_ids.h"
15 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/profiles/profile_manager.h" 17 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
19 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 should_show_bubble_(true), 61 should_show_bubble_(true),
61 bubble_count_(0) { 62 bubble_count_(0) {
62 set_id(VIEW_ID_STATUS_BUTTON_CAPS_LOCK); 63 set_id(VIEW_ID_STATUS_BUTTON_CAPS_LOCK);
63 if (prefs_) 64 if (prefs_)
64 remap_search_key_to_.Init( 65 remap_search_key_to_.Init(
65 prefs::kLanguageXkbRemapSearchKeyTo, prefs_, this); 66 prefs::kLanguageXkbRemapSearchKeyTo, prefs_, this);
66 67
67 SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed( 68 SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed(
68 IDR_STATUSBAR_CAPS_LOCK)); 69 IDR_STATUSBAR_CAPS_LOCK));
69 UpdateAccessibleName(); 70 UpdateAccessibleName();
70 UpdateUIFromCurrentCapsLock(input_method::XKeyboard::CapsLockIsEnabled()); 71
72 input_method::InputMethodManager* ime_manager =
73 input_method::InputMethodManager::GetInstance();
74 UpdateUIFromCurrentCapsLock(ime_manager->GetXKeyboard()->CapsLockIsEnabled());
71 75
72 // Status bar should be initialized after SystemKeyEventListener on the 76 // Status bar should be initialized after SystemKeyEventListener on the
73 // device. SystemKeyEventListener is never initialized on chrome for cros 77 // device. SystemKeyEventListener is never initialized on chrome for cros
74 // running on linux. 78 // running on linux.
75 DCHECK(SystemKeyEventListener::GetInstance() || 79 DCHECK(SystemKeyEventListener::GetInstance() ||
76 !system::runtime_environment::IsRunningOnChromeOS()); 80 !system::runtime_environment::IsRunningOnChromeOS());
77 if (SystemKeyEventListener::GetInstance()) 81 if (SystemKeyEventListener::GetInstance())
78 SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this); 82 SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this);
79 } 83 }
80 84
81 CapsLockMenuButton::~CapsLockMenuButton() { 85 CapsLockMenuButton::~CapsLockMenuButton() {
82 if (SystemKeyEventListener::GetInstance()) 86 if (SystemKeyEventListener::GetInstance())
83 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this); 87 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this);
84 } 88 }
85 89
86 //////////////////////////////////////////////////////////////////////////////// 90 ////////////////////////////////////////////////////////////////////////////////
87 // views::View implementation: 91 // views::View implementation:
88 92
89 void CapsLockMenuButton::OnLocaleChanged() { 93 void CapsLockMenuButton::OnLocaleChanged() {
90 UpdateUIFromCurrentCapsLock(input_method::XKeyboard::CapsLockIsEnabled()); 94 input_method::InputMethodManager* ime_manager =
95 input_method::InputMethodManager::GetInstance();
96 UpdateUIFromCurrentCapsLock(ime_manager->GetXKeyboard()->CapsLockIsEnabled());
91 } 97 }
92 98
93 //////////////////////////////////////////////////////////////////////////////// 99 ////////////////////////////////////////////////////////////////////////////////
94 // views::MenuDelegate implementation: 100 // views::MenuDelegate implementation:
95 101
96 string16 CapsLockMenuButton::GetLabel(int id) const { 102 string16 CapsLockMenuButton::GetLabel(int id) const {
97 return string16(); 103 return string16();
98 } 104 }
99 105
100 //////////////////////////////////////////////////////////////////////////////// 106 ////////////////////////////////////////////////////////////////////////////////
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 249 }
244 250
245 bool CapsLockMenuButton::HasCapsLock() const { 251 bool CapsLockMenuButton::HasCapsLock() const {
246 return (prefs_ && 252 return (prefs_ &&
247 (remap_search_key_to_.GetValue() == input_method::kCapsLockKey)) || 253 (remap_search_key_to_.GetValue() == input_method::kCapsLockKey)) ||
248 // A keyboard for Linux usually has Caps Lock. 254 // A keyboard for Linux usually has Caps Lock.
249 !system::runtime_environment::IsRunningOnChromeOS(); 255 !system::runtime_environment::IsRunningOnChromeOS();
250 } 256 }
251 257
252 } // namespace chromeos 258 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/webui_login_display.cc ('k') | chrome/browser/chromeos/system_key_event_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698