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

Side by Side Diff: chrome/browser/ui/ash/system_tray_delegate_chromeos.cc

Issue 2920883002: chromeos: Make ash system tray directly observe IME state changes (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « chrome/browser/ui/ash/system_tray_delegate_chromeos.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/ash/system_tray_delegate_chromeos.h" 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "ash/login_status.h" 16 #include "ash/login_status.h"
17 #include "ash/shell.h" 17 #include "ash/shell.h"
18 #include "ash/shell_delegate.h" 18 #include "ash/shell_delegate.h"
19 #include "ash/system/date/clock_observer.h" 19 #include "ash/system/date/clock_observer.h"
20 #include "ash/system/ime/ime_observer.h"
21 #include "ash/system/power/power_status.h" 20 #include "ash/system/power/power_status.h"
22 #include "ash/system/session/logout_button_observer.h" 21 #include "ash/system/session/logout_button_observer.h"
23 #include "ash/system/tray/system_tray_notifier.h" 22 #include "ash/system/tray/system_tray_notifier.h"
24 #include "ash/system/tray_accessibility.h" 23 #include "ash/system/tray_accessibility.h"
25 #include "base/callback.h" 24 #include "base/callback.h"
26 #include "base/logging.h" 25 #include "base/logging.h"
27 #include "base/memory/ptr_util.h" 26 #include "base/memory/ptr_util.h"
28 #include "base/metrics/user_metrics.h" 27 #include "base/metrics/user_metrics.h"
29 #include "base/sys_info.h" 28 #include "base/sys_info.h"
30 #include "base/time/time.h" 29 #include "base/time/time.h"
(...skipping 18 matching lines...) Expand all
49 #include "chromeos/login/login_state.h" 48 #include "chromeos/login/login_state.h"
50 #include "chromeos/network/portal_detector/network_portal_detector.h" 49 #include "chromeos/network/portal_detector/network_portal_detector.h"
51 #include "components/google/core/browser/google_util.h" 50 #include "components/google/core/browser/google_util.h"
52 #include "components/prefs/pref_service.h" 51 #include "components/prefs/pref_service.h"
53 #include "components/session_manager/core/session_manager.h" 52 #include "components/session_manager/core/session_manager.h"
54 #include "components/user_manager/user.h" 53 #include "components/user_manager/user.h"
55 #include "components/user_manager/user_manager.h" 54 #include "components/user_manager/user_manager.h"
56 #include "components/user_manager/user_type.h" 55 #include "components/user_manager/user_type.h"
57 #include "content/public/browser/notification_observer.h" 56 #include "content/public/browser/notification_observer.h"
58 #include "content/public/browser/notification_service.h" 57 #include "content/public/browser/notification_service.h"
59 #include "ui/base/ime/chromeos/input_method_manager.h"
60 #include "ui/chromeos/events/pref_names.h" 58 #include "ui/chromeos/events/pref_names.h"
61 #include "ui/chromeos/ime/input_method_menu_manager.h"
62 59
63 namespace chromeos { 60 namespace chromeos {
64 61
65 namespace { 62 namespace {
66 63
67 // The minimum session length limit that can be set. 64 // The minimum session length limit that can be set.
68 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. 65 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds.
69 66
70 // The maximum session length limit that can be set. 67 // The maximum session length limit that can be set.
71 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours. 68 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours.
(...skipping 26 matching lines...) Expand all
98 content::NotificationService::AllSources()); 95 content::NotificationService::AllSources());
99 96
100 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); 97 AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
101 CHECK(accessibility_manager); 98 CHECK(accessibility_manager);
102 accessibility_subscription_ = accessibility_manager->RegisterCallback( 99 accessibility_subscription_ = accessibility_manager->RegisterCallback(
103 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, 100 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged,
104 base::Unretained(this))); 101 base::Unretained(this)));
105 } 102 }
106 103
107 void SystemTrayDelegateChromeOS::Initialize() { 104 void SystemTrayDelegateChromeOS::Initialize() {
108 input_method::InputMethodManager::Get()->AddObserver(this);
109 input_method::InputMethodManager::Get()->AddImeMenuObserver(this);
110 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this);
111
112 BrowserList::AddObserver(this); 105 BrowserList::AddObserver(this);
113 106
114 local_state_registrar_.reset(new PrefChangeRegistrar); 107 local_state_registrar_.reset(new PrefChangeRegistrar);
115 local_state_registrar_->Init(g_browser_process->local_state()); 108 local_state_registrar_->Init(g_browser_process->local_state());
116 109
117 UpdateSessionStartTime(); 110 UpdateSessionStartTime();
118 UpdateSessionLengthLimit(); 111 UpdateSessionLengthLimit();
119 112
120 local_state_registrar_->Add( 113 local_state_registrar_->Add(
121 prefs::kSessionStartTime, 114 prefs::kSessionStartTime,
122 base::Bind(&SystemTrayDelegateChromeOS::UpdateSessionStartTime, 115 base::Bind(&SystemTrayDelegateChromeOS::UpdateSessionStartTime,
123 base::Unretained(this))); 116 base::Unretained(this)));
124 local_state_registrar_->Add( 117 local_state_registrar_->Add(
125 prefs::kSessionLengthLimit, 118 prefs::kSessionLengthLimit,
126 base::Bind(&SystemTrayDelegateChromeOS::UpdateSessionLengthLimit, 119 base::Bind(&SystemTrayDelegateChromeOS::UpdateSessionLengthLimit,
127 base::Unretained(this))); 120 base::Unretained(this)));
128 } 121 }
129 122
130 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { 123 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() {
131 // Unregister PrefChangeRegistrars. 124 // Unregister PrefChangeRegistrars.
132 local_state_registrar_.reset(); 125 local_state_registrar_.reset();
133 user_pref_registrar_.reset(); 126 user_pref_registrar_.reset();
134 127
135 // Unregister content notifications before destroying any components. 128 // Unregister content notifications before destroying any components.
136 registrar_.reset(); 129 registrar_.reset();
137 130
138 // Unregister a11y status subscription. 131 // Unregister a11y status subscription.
139 accessibility_subscription_.reset(); 132 accessibility_subscription_.reset();
140 133
141 input_method::InputMethodManager::Get()->RemoveObserver(this);
142 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this);
143
144 BrowserList::RemoveObserver(this); 134 BrowserList::RemoveObserver(this);
145 StopObservingAppWindowRegistry(); 135 StopObservingAppWindowRegistry();
146 } 136 }
147 137
148 void SystemTrayDelegateChromeOS::ShowUserLogin() { 138 void SystemTrayDelegateChromeOS::ShowUserLogin() {
149 if (!ash::Shell::Get()->shell_delegate()->IsMultiProfilesEnabled()) 139 if (!ash::Shell::Get()->shell_delegate()->IsMultiProfilesEnabled())
150 return; 140 return;
151 141
152 // Only regular non-supervised users could add other users to current session. 142 // Only regular non-supervised users could add other users to current session.
153 if (user_manager::UserManager::Get()->GetActiveUser()->GetType() != 143 if (user_manager::UserManager::Get()->GetActiveUser()->GetType() !=
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 381 }
392 382
393 void SystemTrayDelegateChromeOS::UpdatePerformanceTracing() { 383 void SystemTrayDelegateChromeOS::UpdatePerformanceTracing() {
394 if (!user_pref_registrar_) 384 if (!user_pref_registrar_)
395 return; 385 return;
396 bool value = user_pref_registrar_->prefs()->GetBoolean( 386 bool value = user_pref_registrar_->prefs()->GetBoolean(
397 prefs::kPerformanceTracingEnabled); 387 prefs::kPerformanceTracingEnabled);
398 GetSystemTrayNotifier()->NotifyTracingModeChanged(value); 388 GetSystemTrayNotifier()->NotifyTracingModeChanged(value);
399 } 389 }
400 390
401 // Overridden from InputMethodManager::Observer.
402 void SystemTrayDelegateChromeOS::InputMethodChanged(
403 input_method::InputMethodManager* manager,
404 Profile* /* profile */,
405 bool show_message) {
406 GetSystemTrayNotifier()->NotifyRefreshIME();
407 }
408
409 // Overridden from InputMethodMenuManager::Observer.
410 void SystemTrayDelegateChromeOS::InputMethodMenuItemChanged(
411 ui::ime::InputMethodMenuManager* manager) {
412 GetSystemTrayNotifier()->NotifyRefreshIME();
413 }
414
415 // Overridden from chrome::BrowserListObserver. 391 // Overridden from chrome::BrowserListObserver.
416 void SystemTrayDelegateChromeOS::OnBrowserRemoved(Browser* browser) { 392 void SystemTrayDelegateChromeOS::OnBrowserRemoved(Browser* browser) {
417 NotifyIfLastWindowClosed(); 393 NotifyIfLastWindowClosed();
418 } 394 }
419 395
420 // Overridden from extensions::AppWindowRegistry::Observer. 396 // Overridden from extensions::AppWindowRegistry::Observer.
421 void SystemTrayDelegateChromeOS::OnAppWindowRemoved( 397 void SystemTrayDelegateChromeOS::OnAppWindowRemoved(
422 extensions::AppWindow* app_window) { 398 extensions::AppWindow* app_window) {
423 NotifyIfLastWindowClosed(); 399 NotifyIfLastWindowClosed();
424 } 400 }
425 401
426 void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged( 402 void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged(
427 const AccessibilityStatusEventDetails& details) { 403 const AccessibilityStatusEventDetails& details) {
428 if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN) 404 if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN)
429 accessibility_subscription_.reset(); 405 accessibility_subscription_.reset();
430 else 406 else
431 OnAccessibilityModeChanged(details.notify); 407 OnAccessibilityModeChanged(details.notify);
432 } 408 }
433 409
434 void SystemTrayDelegateChromeOS::ImeMenuActivationChanged(bool is_active) {
435 GetSystemTrayNotifier()->NotifyRefreshIMEMenu(is_active);
436 }
437
438 void SystemTrayDelegateChromeOS::ImeMenuListChanged() {}
439
440 void SystemTrayDelegateChromeOS::ImeMenuItemsChanged(
441 const std::string& engine_id,
442 const std::vector<input_method::InputMethodManager::MenuItem>& items) {}
443
444 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 410 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
445 return new SystemTrayDelegateChromeOS(); 411 return new SystemTrayDelegateChromeOS();
446 } 412 }
447 413
448 } // namespace chromeos 414 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/system_tray_delegate_chromeos.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698