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

Side by Side Diff: chrome/browser/chromeos/system/ash_system_tray_delegate.cc

Issue 11280287: Magnifier: Prevent useless operation in enabling/disabling magnifier. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: review fix (#2 & #3) Created 8 years 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
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/system/ash_system_tray_delegate.h" 5 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/system/audio/audio_observer.h" 9 #include "ash/system/audio/audio_observer.h"
10 #include "ash/system/bluetooth/bluetooth_observer.h" 10 #include "ash/system/bluetooth/bluetooth_observer.h"
(...skipping 14 matching lines...) Expand all
25 #include "ash/volume_control_delegate.h" 25 #include "ash/volume_control_delegate.h"
26 #include "ash/wm/session_state_controller.h" 26 #include "ash/wm/session_state_controller.h"
27 #include "base/bind_helpers.h" 27 #include "base/bind_helpers.h"
28 #include "base/callback.h" 28 #include "base/callback.h"
29 #include "base/chromeos/chromeos_version.h" 29 #include "base/chromeos/chromeos_version.h"
30 #include "base/logging.h" 30 #include "base/logging.h"
31 #include "base/memory/weak_ptr.h" 31 #include "base/memory/weak_ptr.h"
32 #include "base/utf_string_conversions.h" 32 #include "base/utf_string_conversions.h"
33 #include "chrome/browser/browser_process.h" 33 #include "chrome/browser/browser_process.h"
34 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 34 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
35 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
35 #include "chrome/browser/chromeos/audio/audio_handler.h" 36 #include "chrome/browser/chromeos/audio/audio_handler.h"
36 #include "chrome/browser/chromeos/cros/cros_library.h" 37 #include "chrome/browser/chromeos/cros/cros_library.h"
37 #include "chrome/browser/chromeos/cros/network_library.h" 38 #include "chrome/browser/chromeos/cros/network_library.h"
38 #include "chrome/browser/chromeos/drive/drive_system_service.h" 39 #include "chrome/browser/chromeos/drive/drive_system_service.h"
39 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 40 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
40 #include "chrome/browser/chromeos/input_method/input_method_util.h" 41 #include "chrome/browser/chromeos/input_method/input_method_util.h"
41 #include "chrome/browser/chromeos/input_method/xkeyboard.h" 42 #include "chrome/browser/chromeos/input_method/xkeyboard.h"
42 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" 43 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
43 #include "chrome/browser/chromeos/login/base_login_display_host.h" 44 #include "chrome/browser/chromeos/login/base_login_display_host.h"
44 #include "chrome/browser/chromeos/login/login_display_host.h" 45 #include "chrome/browser/chromeos/login/login_display_host.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 public NetworkMenuIcon::Delegate, 157 public NetworkMenuIcon::Delegate,
157 public NetworkMenu::Delegate, 158 public NetworkMenu::Delegate,
158 public NetworkLibrary::NetworkManagerObserver, 159 public NetworkLibrary::NetworkManagerObserver,
159 public NetworkLibrary::NetworkObserver, 160 public NetworkLibrary::NetworkObserver,
160 public google_apis::DriveServiceObserver, 161 public google_apis::DriveServiceObserver,
161 public content::NotificationObserver, 162 public content::NotificationObserver,
162 public input_method::InputMethodManager::Observer, 163 public input_method::InputMethodManager::Observer,
163 public system::TimezoneSettings::Observer, 164 public system::TimezoneSettings::Observer,
164 public device::BluetoothAdapter::Observer, 165 public device::BluetoothAdapter::Observer,
165 public SystemKeyEventListener::CapsLockObserver, 166 public SystemKeyEventListener::CapsLockObserver,
166 public ash::NetworkTrayDelegate { 167 public ash::NetworkTrayDelegate,
168 public MagnificationObserver {
167 public: 169 public:
168 SystemTrayDelegate() 170 SystemTrayDelegate()
169 : ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST( 171 : ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(
170 new base::WeakPtrFactory<SystemTrayDelegate>(this))), 172 new base::WeakPtrFactory<SystemTrayDelegate>(this))),
171 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST( 173 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST(
172 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), 174 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
173 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST( 175 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST(
174 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), 176 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
175 network_menu_(ALLOW_THIS_IN_INITIALIZER_LIST(new NetworkMenu(this))), 177 network_menu_(ALLOW_THIS_IN_INITIALIZER_LIST(new NetworkMenu(this))),
176 clock_type_(base::k24HourClock), 178 clock_type_(base::k24HourClock),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 crosnet->AddNetworkManagerObserver(this); 214 crosnet->AddNetworkManagerObserver(this);
213 OnNetworkManagerChanged(crosnet); 215 OnNetworkManagerChanged(crosnet);
214 216
215 input_method::InputMethodManager::GetInstance()->AddObserver(this); 217 input_method::InputMethodManager::GetInstance()->AddObserver(this);
216 218
217 system::TimezoneSettings::GetInstance()->AddObserver(this); 219 system::TimezoneSettings::GetInstance()->AddObserver(this);
218 220
219 if (SystemKeyEventListener::GetInstance()) 221 if (SystemKeyEventListener::GetInstance())
220 SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this); 222 SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this);
221 223
224 if (chromeos::MagnificationManager::Get())
225 chromeos::MagnificationManager::Get()->AddObserver(this);
226
222 spoken_feedback_enabled_.Init( 227 spoken_feedback_enabled_.Init(
223 prefs::kSpokenFeedbackEnabled, 228 prefs::kSpokenFeedbackEnabled,
224 g_browser_process->local_state(), 229 g_browser_process->local_state(),
225 base::Bind(&SystemTrayDelegate::OnAccessibilityModeChanged, 230 base::Bind(&SystemTrayDelegate::OnAccessibilityModeChanged,
226 base::Unretained(this))); 231 base::Unretained(this)));
227 232
228 high_contrast_enabled_.Init( 233 high_contrast_enabled_.Init(
229 prefs::kHighContrastEnabled, 234 prefs::kHighContrastEnabled,
230 g_browser_process->local_state(), 235 g_browser_process->local_state(),
231 base::Bind(&SystemTrayDelegate::OnAccessibilityModeChanged, 236 base::Bind(&SystemTrayDelegate::OnAccessibilityModeChanged,
(...skipping 15 matching lines...) Expand all
247 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); 252 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this);
248 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); 253 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
249 if (crosnet) 254 if (crosnet)
250 crosnet->RemoveNetworkManagerObserver(this); 255 crosnet->RemoveNetworkManagerObserver(this);
251 input_method::InputMethodManager::GetInstance()->RemoveObserver(this); 256 input_method::InputMethodManager::GetInstance()->RemoveObserver(this);
252 system::TimezoneSettings::GetInstance()->RemoveObserver(this); 257 system::TimezoneSettings::GetInstance()->RemoveObserver(this);
253 if (SystemKeyEventListener::GetInstance()) 258 if (SystemKeyEventListener::GetInstance())
254 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this); 259 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this);
255 bluetooth_adapter_->RemoveObserver(this); 260 bluetooth_adapter_->RemoveObserver(this);
256 261
262 if (chromeos::MagnificationManager::Get())
263 chromeos::MagnificationManager::Get()->RemoveObserver(this);
264
257 // Stop observing gdata operations. 265 // Stop observing gdata operations.
258 DriveSystemService* system_service = FindDriveSystemService(); 266 DriveSystemService* system_service = FindDriveSystemService();
259 if (system_service) { 267 if (system_service) {
260 system_service->drive_service()->RemoveObserver(this); 268 system_service->drive_service()->RemoveObserver(this);
261 } 269 }
262 } 270 }
263 271
264 // Overridden from ash::SystemTrayDelegate: 272 // Overridden from ash::SystemTrayDelegate:
265 virtual bool GetTrayVisibilityOnStartup() OVERRIDE { 273 virtual bool GetTrayVisibilityOnStartup() OVERRIDE {
266 // In case of OOBE / sign in screen tray will be shown later. 274 // In case of OOBE / sign in screen tray will be shown later.
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 base::Unretained(this))); 789 base::Unretained(this)));
782 pref_registrar_->Add( 790 pref_registrar_->Add(
783 prefs::kLanguageRemapSearchKeyTo, 791 prefs::kLanguageRemapSearchKeyTo,
784 base::Bind(&SystemTrayDelegate::OnLanguageRemapSearchKeyToChanged, 792 base::Bind(&SystemTrayDelegate::OnLanguageRemapSearchKeyToChanged,
785 base::Unretained(this))); 793 base::Unretained(this)));
786 pref_registrar_->Add( 794 pref_registrar_->Add(
787 prefs::kShowLogoutButtonInTray, 795 prefs::kShowLogoutButtonInTray,
788 base::Bind(&SystemTrayDelegate::UpdateShowLogoutButtonInTray, 796 base::Bind(&SystemTrayDelegate::UpdateShowLogoutButtonInTray,
789 base::Unretained(this))); 797 base::Unretained(this)));
790 pref_registrar_->Add( 798 pref_registrar_->Add(
791 prefs::kMagnifierType,
792 base::Bind(&SystemTrayDelegate::OnAccessibilityModeChanged,
793 base::Unretained(this)));
794 pref_registrar_->Add(
795 prefs::kShouldAlwaysShowAccessibilityMenu, 799 prefs::kShouldAlwaysShowAccessibilityMenu,
796 base::Bind(&SystemTrayDelegate::OnAccessibilityModeChanged, 800 base::Bind(&SystemTrayDelegate::OnAccessibilityModeChanged,
797 base::Unretained(this))); 801 base::Unretained(this)));
798 802
799 UpdateClockType(); 803 UpdateClockType();
800 UpdateShowLogoutButtonInTray(); 804 UpdateShowLogoutButtonInTray();
801 search_key_mapped_to_ = 805 search_key_mapped_to_ =
802 profile->GetPrefs()->GetInteger(prefs::kLanguageRemapSearchKeyTo); 806 profile->GetPrefs()->GetInteger(prefs::kLanguageRemapSearchKeyTo);
803 } 807 }
804 808
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 } 1266 }
1263 1267
1264 if (!deal_url_to_open.empty()) { 1268 if (!deal_url_to_open.empty()) {
1265 Browser* browser = GetAppropriateBrowser(); 1269 Browser* browser = GetAppropriateBrowser();
1266 if (!browser) 1270 if (!browser)
1267 return; 1271 return;
1268 chrome::ShowSingletonTab(browser, GURL(deal_url_to_open)); 1272 chrome::ShowSingletonTab(browser, GURL(deal_url_to_open));
1269 } 1273 }
1270 } 1274 }
1271 1275
1276 // Overridden from MagnificationObserver
1277 void OnMagnifierTypeChanged(ash::MagnifierType new_type) {
1278 OnAccessibilityModeChanged();
1279 }
1280
1272 scoped_ptr<base::WeakPtrFactory<SystemTrayDelegate> > ui_weak_ptr_factory_; 1281 scoped_ptr<base::WeakPtrFactory<SystemTrayDelegate> > ui_weak_ptr_factory_;
1273 scoped_ptr<NetworkMenuIcon> network_icon_; 1282 scoped_ptr<NetworkMenuIcon> network_icon_;
1274 scoped_ptr<NetworkMenuIcon> network_icon_dark_; 1283 scoped_ptr<NetworkMenuIcon> network_icon_dark_;
1275 scoped_ptr<NetworkMenu> network_menu_; 1284 scoped_ptr<NetworkMenu> network_menu_;
1276 content::NotificationRegistrar registrar_; 1285 content::NotificationRegistrar registrar_;
1277 scoped_ptr<PrefChangeRegistrar> pref_registrar_; 1286 scoped_ptr<PrefChangeRegistrar> pref_registrar_;
1278 std::string cellular_device_path_; 1287 std::string cellular_device_path_;
1279 std::string active_network_path_; 1288 std::string active_network_path_;
1280 PowerSupplyStatus power_supply_status_; 1289 PowerSupplyStatus power_supply_status_;
1281 base::HourClockType clock_type_; 1290 base::HourClockType clock_type_;
(...skipping 16 matching lines...) Expand all
1298 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); 1307 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate);
1299 }; 1308 };
1300 1309
1301 } // namespace 1310 } // namespace
1302 1311
1303 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1312 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1304 return new chromeos::SystemTrayDelegate(); 1313 return new chromeos::SystemTrayDelegate();
1305 } 1314 }
1306 1315
1307 } // namespace chromeos 1316 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698