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

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

Issue 2882933002: Add update available icon in system tray (Closed)
Patch Set: Remove duplicate header files. Created 3 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_client.h" 5 #include "chrome/browser/ui/ash/system_tray_client.h"
6 6
7 #include "ash/login_status.h" 7 #include "ash/login_status.h"
8 #include "ash/public/cpp/shell_window_ids.h" 8 #include "ash/public/cpp/shell_window_ids.h"
9 #include "ash/public/interfaces/constants.mojom.h" 9 #include "ash/public/interfaces/constants.mojom.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "base/feature_list.h" 11 #include "base/feature_list.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/weak_ptr.h"
13 #include "base/metrics/user_metrics.h" 14 #include "base/metrics/user_metrics.h"
14 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/browser_process_platform_part.h" 16 #include "chrome/browser/browser_process_platform_part.h"
16 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 18 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
18 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" 19 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h"
19 #include "chrome/browser/chromeos/login/help_app_launcher.h" 20 #include "chrome/browser/chromeos/login/help_app_launcher.h"
20 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 21 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
21 #include "chrome/browser/chromeos/options/network_config_view.h" 22 #include "chrome/browser/chromeos/options/network_config_view.h"
22 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 23 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
23 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 24 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
24 #include "chrome/browser/chromeos/profiles/profile_helper.h" 25 #include "chrome/browser/chromeos/profiles/profile_helper.h"
25 #include "chrome/browser/chromeos/set_time_dialog.h" 26 #include "chrome/browser/chromeos/set_time_dialog.h"
26 #include "chrome/browser/chromeos/system/system_clock.h" 27 #include "chrome/browser/chromeos/system/system_clock.h"
27 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" 28 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h"
28 #include "chrome/browser/lifetime/application_lifetime.h" 29 #include "chrome/browser/lifetime/application_lifetime.h"
29 #include "chrome/browser/lifetime/termination_notification.h" 30 #include "chrome/browser/lifetime/termination_notification.h"
30 #include "chrome/browser/profiles/profile_manager.h" 31 #include "chrome/browser/profiles/profile_manager.h"
31 #include "chrome/browser/ui/ash/ash_util.h" 32 #include "chrome/browser/ui/ash/ash_util.h"
32 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" 33 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h"
33 #include "chrome/browser/ui/chrome_pages.h" 34 #include "chrome/browser/ui/chrome_pages.h"
34 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 35 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
35 #include "chrome/browser/ui/singleton_tabs.h" 36 #include "chrome/browser/ui/singleton_tabs.h"
36 #include "chrome/browser/upgrade_detector.h"
37 #include "chrome/common/chrome_features.h" 37 #include "chrome/common/chrome_features.h"
38 #include "chrome/common/url_constants.h" 38 #include "chrome/common/url_constants.h"
39 #include "chromeos/dbus/dbus_thread_manager.h" 39 #include "chromeos/dbus/dbus_thread_manager.h"
40 #include "chromeos/dbus/session_manager_client.h" 40 #include "chromeos/dbus/session_manager_client.h"
41 #include "chromeos/login/login_state.h" 41 #include "chromeos/login/login_state.h"
42 #include "chromeos/network/network_handler.h" 42 #include "chromeos/network/network_handler.h"
43 #include "chromeos/network/network_state.h" 43 #include "chromeos/network/network_state.h"
44 #include "chromeos/network/network_state_handler.h" 44 #include "chromeos/network/network_state_handler.h"
45 #include "chromeos/network/tether_constants.h" 45 #include "chromeos/network/tether_constants.h"
46 #include "components/session_manager/core/session_manager.h" 46 #include "components/session_manager/core/session_manager.h"
47 #include "components/user_manager/user_manager.h" 47 #include "components/user_manager/user_manager.h"
48 #include "content/public/browser/notification_service.h" 48 #include "content/public/browser/notification_service.h"
49 #include "content/public/common/service_manager_connection.h" 49 #include "content/public/common/service_manager_connection.h"
50 #include "device/bluetooth/bluetooth_device.h" 50 #include "device/bluetooth/bluetooth_device.h"
51 #include "extensions/browser/api/vpn_provider/vpn_service.h" 51 #include "extensions/browser/api/vpn_provider/vpn_service.h"
52 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h" 52 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h"
53 #include "net/base/escape.h" 53 #include "net/base/escape.h"
54 #include "services/service_manager/public/cpp/connector.h" 54 #include "services/service_manager/public/cpp/connector.h"
55 #include "services/ui/public/cpp/property_type_converters.h" 55 #include "services/ui/public/cpp/property_type_converters.h"
56 #include "services/ui/public/interfaces/window_manager.mojom.h" 56 #include "services/ui/public/interfaces/window_manager.mojom.h"
57 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" 57 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
58 #include "ui/views/widget/widget.h" 58 #include "ui/views/widget/widget.h"
59 #include "ui/views/window/dialog_delegate.h" 59 #include "ui/views/window/dialog_delegate.h"
60 60
61 using chromeos::BluetoothPairingDialog; 61 using chromeos::BluetoothPairingDialog;
62 using chromeos::DBusThreadManager; 62 using chromeos::DBusThreadManager;
63 using chromeos::LoginState; 63 using chromeos::LoginState;
64 using chromeos::UpdateEngineClient;
64 using device::BluetoothDevice; 65 using device::BluetoothDevice;
65 using views::Widget; 66 using views::Widget;
66 67
67 namespace { 68 namespace {
68 69
69 SystemTrayClient* g_instance = nullptr; 70 SystemTrayClient* g_instance = nullptr;
70 71
71 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { 72 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) {
72 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), 73 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(),
73 sub_page); 74 sub_page);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 policy::BrowserPolicyConnectorChromeOS* policy_connector = 118 policy::BrowserPolicyConnectorChromeOS* policy_connector =
118 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 119 g_browser_process->platform_part()->browser_policy_connector_chromeos();
119 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 120 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
120 policy_connector->GetDeviceCloudPolicyManager(); 121 policy_connector->GetDeviceCloudPolicyManager();
121 if (policy_manager) 122 if (policy_manager)
122 policy_manager->core()->store()->AddObserver(this); 123 policy_manager->core()->store()->AddObserver(this);
123 UpdateEnterpriseDomain(); 124 UpdateEnterpriseDomain();
124 125
125 DCHECK(!g_instance); 126 DCHECK(!g_instance);
126 g_instance = this; 127 g_instance = this;
128 UpgradeDetector::GetInstance()->AddObserver(this);
127 } 129 }
128 130
129 SystemTrayClient::~SystemTrayClient() { 131 SystemTrayClient::~SystemTrayClient() {
130 DCHECK_EQ(this, g_instance); 132 DCHECK_EQ(this, g_instance);
131 g_instance = nullptr; 133 g_instance = nullptr;
132 134
133 policy::BrowserPolicyConnectorChromeOS* connector = 135 policy::BrowserPolicyConnectorChromeOS* connector =
134 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 136 g_browser_process->platform_part()->browser_policy_connector_chromeos();
135 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 137 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
136 connector->GetDeviceCloudPolicyManager(); 138 connector->GetDeviceCloudPolicyManager();
137 if (policy_manager) 139 if (policy_manager)
138 policy_manager->core()->store()->RemoveObserver(this); 140 policy_manager->core()->store()->RemoveObserver(this);
139 141
140 g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this); 142 g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this);
143 UpgradeDetector::GetInstance()->RemoveObserver(this);
141 } 144 }
142 145
143 // static 146 // static
144 SystemTrayClient* SystemTrayClient::Get() { 147 SystemTrayClient* SystemTrayClient::Get() {
145 return g_instance; 148 return g_instance;
146 } 149 }
147 150
148 // static 151 // static
149 ash::LoginStatus SystemTrayClient::GetUserLoginStatus() { 152 ash::LoginStatus SystemTrayClient::GetUserLoginStatus() {
150 if (!LoginState::Get()->IsUserLoggedIn()) 153 if (!LoginState::Get()->IsUserLoggedIn())
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 chrome::ScopedTabbedBrowserDisplayer displayer( 290 chrome::ScopedTabbedBrowserDisplayer displayer(
288 ProfileManager::GetPrimaryUserProfile()); 291 ProfileManager::GetPrimaryUserProfile());
289 chrome::ShowSlow(displayer.browser()); 292 chrome::ShowSlow(displayer.browser());
290 } 293 }
291 294
292 void SystemTrayClient::ShowIMESettings() { 295 void SystemTrayClient::ShowIMESettings() {
293 base::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); 296 base::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog"));
294 ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage); 297 ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage);
295 } 298 }
296 299
300 void SystemTrayClient::ShowAboutChromeOS() {
301 // We always want to check for updates when showing the about page from the
302 // Ash UI.
303 ShowSettingsSubPageForActiveUser(std::string(chrome::kHelpSubPage) +
304 "?checkForUpdate=true");
305 }
306
297 void SystemTrayClient::ShowHelp() { 307 void SystemTrayClient::ShowHelp() {
298 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(), 308 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(),
299 chrome::HELP_SOURCE_MENU); 309 chrome::HELP_SOURCE_MENU);
300 } 310 }
301 311
302 void SystemTrayClient::ShowAccessibilityHelp() { 312 void SystemTrayClient::ShowAccessibilityHelp() {
303 chrome::ScopedTabbedBrowserDisplayer displayer( 313 chrome::ScopedTabbedBrowserDisplayer displayer(
304 ProfileManager::GetActiveUserProfile()); 314 ProfileManager::GetActiveUserProfile());
305 chromeos::accessibility::ShowAccessibilityHelp(displayer.browser()); 315 chromeos::accessibility::ShowAccessibilityHelp(displayer.browser());
306 } 316 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 // Show a string specific to updating flash player if there is no system 463 // Show a string specific to updating flash player if there is no system
454 // update. 464 // update.
455 ash::mojom::UpdateType update_type = detector->notify_upgrade() 465 ash::mojom::UpdateType update_type = detector->notify_upgrade()
456 ? ash::mojom::UpdateType::SYSTEM 466 ? ash::mojom::UpdateType::SYSTEM
457 : ash::mojom::UpdateType::FLASH; 467 : ash::mojom::UpdateType::FLASH;
458 468
459 system_tray_->ShowUpdateIcon(severity, detector->is_factory_reset_required(), 469 system_tray_->ShowUpdateIcon(severity, detector->is_factory_reset_required(),
460 update_type); 470 update_type);
461 } 471 }
462 472
473 void SystemTrayClient::HandleUpdateOverCellularAvailable() {
474 system_tray_->ShowUpdateOverCellularAvailableIcon();
475 }
476
463 //////////////////////////////////////////////////////////////////////////////// 477 ////////////////////////////////////////////////////////////////////////////////
464 // chromeos::system::SystemClockObserver: 478 // chromeos::system::SystemClockObserver:
465 479
466 void SystemTrayClient::OnSystemClockChanged( 480 void SystemTrayClient::OnSystemClockChanged(
467 chromeos::system::SystemClock* clock) { 481 chromeos::system::SystemClock* clock) {
468 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); 482 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock());
469 } 483 }
470 484
471 void SystemTrayClient::Observe(int type, 485 void SystemTrayClient::Observe(int type,
472 const content::NotificationSource& source, 486 const content::NotificationSource& source,
473 const content::NotificationDetails& details) { 487 const content::NotificationDetails& details) {
474 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); 488 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type);
475 HandleUpdateAvailable(); 489 HandleUpdateAvailable();
476 } 490 }
477 491
478 //////////////////////////////////////////////////////////////////////////////// 492 ////////////////////////////////////////////////////////////////////////////////
493 // UpgradeDetector::UpgradeObserver:
494 void SystemTrayClient::OnUpdateOverCellularAvailable() {
495 HandleUpdateOverCellularAvailable();
496 }
497
498 ////////////////////////////////////////////////////////////////////////////////
479 // policy::CloudPolicyStore::Observer 499 // policy::CloudPolicyStore::Observer
480 void SystemTrayClient::OnStoreLoaded(policy::CloudPolicyStore* store) { 500 void SystemTrayClient::OnStoreLoaded(policy::CloudPolicyStore* store) {
481 UpdateEnterpriseDomain(); 501 UpdateEnterpriseDomain();
482 } 502 }
483 503
484 void SystemTrayClient::OnStoreError(policy::CloudPolicyStore* store) { 504 void SystemTrayClient::OnStoreError(policy::CloudPolicyStore* store) {
485 UpdateEnterpriseDomain(); 505 UpdateEnterpriseDomain();
486 } 506 }
487 507
488 void SystemTrayClient::UpdateEnterpriseDomain() { 508 void SystemTrayClient::UpdateEnterpriseDomain() {
489 policy::BrowserPolicyConnectorChromeOS* connector = 509 policy::BrowserPolicyConnectorChromeOS* connector =
490 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 510 g_browser_process->platform_part()->browser_policy_connector_chromeos();
491 const std::string enterprise_domain = connector->GetEnterpriseDomain(); 511 const std::string enterprise_domain = connector->GetEnterpriseDomain();
492 const bool active_directory_managed = connector->IsActiveDirectoryManaged(); 512 const bool active_directory_managed = connector->IsActiveDirectoryManaged();
493 if (enterprise_domain == last_enterprise_domain_ && 513 if (enterprise_domain == last_enterprise_domain_ &&
494 active_directory_managed == last_active_directory_managed_) { 514 active_directory_managed == last_active_directory_managed_) {
495 return; 515 return;
496 } 516 }
497 // Send to ash, which will add an item to the system tray. 517 // Send to ash, which will add an item to the system tray.
498 system_tray_->SetEnterpriseDomain(enterprise_domain, 518 system_tray_->SetEnterpriseDomain(enterprise_domain,
499 active_directory_managed); 519 active_directory_managed);
500 last_enterprise_domain_ = enterprise_domain; 520 last_enterprise_domain_ = enterprise_domain;
501 last_active_directory_managed_ = active_directory_managed; 521 last_active_directory_managed_ = active_directory_managed;
502 } 522 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698