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

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

Issue 2925973002: Migrate upgrade notifications to observer (Closed)
Patch Set: Add DISALLOW_COPY_AND_ASSIGN 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
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/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/metrics/user_metrics.h" 13 #include "base/metrics/user_metrics.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/browser_process_platform_part.h" 15 #include "chrome/browser/browser_process_platform_part.h"
16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
18 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" 17 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h"
19 #include "chrome/browser/chromeos/login/help_app_launcher.h" 18 #include "chrome/browser/chromeos/login/help_app_launcher.h"
20 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 19 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
21 #include "chrome/browser/chromeos/options/network_config_view.h" 20 #include "chrome/browser/chromeos/options/network_config_view.h"
22 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 21 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
23 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 22 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
24 #include "chrome/browser/chromeos/profiles/profile_helper.h" 23 #include "chrome/browser/chromeos/profiles/profile_helper.h"
25 #include "chrome/browser/chromeos/set_time_dialog.h" 24 #include "chrome/browser/chromeos/set_time_dialog.h"
26 #include "chrome/browser/chromeos/system/system_clock.h" 25 #include "chrome/browser/chromeos/system/system_clock.h"
(...skipping 10 matching lines...) Expand all
37 #include "chrome/common/url_constants.h" 36 #include "chrome/common/url_constants.h"
38 #include "chromeos/dbus/dbus_thread_manager.h" 37 #include "chromeos/dbus/dbus_thread_manager.h"
39 #include "chromeos/dbus/session_manager_client.h" 38 #include "chromeos/dbus/session_manager_client.h"
40 #include "chromeos/login/login_state.h" 39 #include "chromeos/login/login_state.h"
41 #include "chromeos/network/network_handler.h" 40 #include "chromeos/network/network_handler.h"
42 #include "chromeos/network/network_state.h" 41 #include "chromeos/network/network_state.h"
43 #include "chromeos/network/network_state_handler.h" 42 #include "chromeos/network/network_state_handler.h"
44 #include "chromeos/network/tether_constants.h" 43 #include "chromeos/network/tether_constants.h"
45 #include "components/session_manager/core/session_manager.h" 44 #include "components/session_manager/core/session_manager.h"
46 #include "components/user_manager/user_manager.h" 45 #include "components/user_manager/user_manager.h"
47 #include "content/public/browser/notification_service.h"
48 #include "content/public/common/service_manager_connection.h" 46 #include "content/public/common/service_manager_connection.h"
49 #include "device/bluetooth/bluetooth_device.h" 47 #include "device/bluetooth/bluetooth_device.h"
50 #include "extensions/browser/api/vpn_provider/vpn_service.h" 48 #include "extensions/browser/api/vpn_provider/vpn_service.h"
51 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h" 49 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h"
52 #include "net/base/escape.h" 50 #include "net/base/escape.h"
53 #include "services/service_manager/public/cpp/connector.h" 51 #include "services/service_manager/public/cpp/connector.h"
54 #include "services/ui/public/cpp/property_type_converters.h" 52 #include "services/ui/public/cpp/property_type_converters.h"
55 #include "services/ui/public/interfaces/window_manager.mojom.h" 53 #include "services/ui/public/interfaces/window_manager.mojom.h"
56 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" 54 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
57 #include "ui/views/widget/widget.h" 55 #include "ui/views/widget/widget.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 ->BindInterface(ash::mojom::kServiceName, &system_tray_); 99 ->BindInterface(ash::mojom::kServiceName, &system_tray_);
102 // Register this object as the client interface implementation. 100 // Register this object as the client interface implementation.
103 ash::mojom::SystemTrayClientPtr client; 101 ash::mojom::SystemTrayClientPtr client;
104 binding_.Bind(mojo::MakeRequest(&client)); 102 binding_.Bind(mojo::MakeRequest(&client));
105 system_tray_->SetClient(std::move(client)); 103 system_tray_->SetClient(std::move(client));
106 104
107 // If this observes clock setting changes before ash comes up the IPCs will 105 // If this observes clock setting changes before ash comes up the IPCs will
108 // be queued on |system_tray_|. 106 // be queued on |system_tray_|.
109 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this); 107 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this);
110 108
111 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
112 content::NotificationService::AllSources());
113
114 // If an upgrade is available at startup then tell ash about it. 109 // If an upgrade is available at startup then tell ash about it.
115 if (UpgradeDetector::GetInstance()->notify_upgrade()) 110 if (UpgradeDetector::GetInstance()->notify_upgrade())
116 HandleUpdateAvailable(); 111 HandleUpdateAvailable();
117 112
118 // If the device is enterprise managed then send ash the enterprise domain. 113 // If the device is enterprise managed then send ash the enterprise domain.
119 policy::BrowserPolicyConnectorChromeOS* policy_connector = 114 policy::BrowserPolicyConnectorChromeOS* policy_connector =
120 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 115 g_browser_process->platform_part()->browser_policy_connector_chromeos();
121 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 116 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
122 policy_connector->GetDeviceCloudPolicyManager(); 117 policy_connector->GetDeviceCloudPolicyManager();
123 if (policy_manager) 118 if (policy_manager)
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 } 471 }
477 472
478 //////////////////////////////////////////////////////////////////////////////// 473 ////////////////////////////////////////////////////////////////////////////////
479 // chromeos::system::SystemClockObserver: 474 // chromeos::system::SystemClockObserver:
480 475
481 void SystemTrayClient::OnSystemClockChanged( 476 void SystemTrayClient::OnSystemClockChanged(
482 chromeos::system::SystemClock* clock) { 477 chromeos::system::SystemClock* clock) {
483 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); 478 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock());
484 } 479 }
485 480
486 void SystemTrayClient::Observe(int type,
487 const content::NotificationSource& source,
488 const content::NotificationDetails& details) {
489 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type);
490 HandleUpdateAvailable();
491 }
492
493 //////////////////////////////////////////////////////////////////////////////// 481 ////////////////////////////////////////////////////////////////////////////////
494 // UpgradeDetector::UpgradeObserver: 482 // UpgradeDetector::UpgradeObserver:
495 void SystemTrayClient::OnUpdateOverCellularAvailable() { 483 void SystemTrayClient::OnUpdateOverCellularAvailable() {
496 HandleUpdateOverCellularAvailable(); 484 HandleUpdateOverCellularAvailable();
497 } 485 }
498 486
487 void SystemTrayClient::OnUpgradeRecommended() {
488 HandleUpdateAvailable();
489 }
490
499 //////////////////////////////////////////////////////////////////////////////// 491 ////////////////////////////////////////////////////////////////////////////////
500 // policy::CloudPolicyStore::Observer 492 // policy::CloudPolicyStore::Observer
501 void SystemTrayClient::OnStoreLoaded(policy::CloudPolicyStore* store) { 493 void SystemTrayClient::OnStoreLoaded(policy::CloudPolicyStore* store) {
502 UpdateEnterpriseDomain(); 494 UpdateEnterpriseDomain();
503 } 495 }
504 496
505 void SystemTrayClient::OnStoreError(policy::CloudPolicyStore* store) { 497 void SystemTrayClient::OnStoreError(policy::CloudPolicyStore* store) {
506 UpdateEnterpriseDomain(); 498 UpdateEnterpriseDomain();
507 } 499 }
508 500
509 void SystemTrayClient::UpdateEnterpriseDomain() { 501 void SystemTrayClient::UpdateEnterpriseDomain() {
510 policy::BrowserPolicyConnectorChromeOS* connector = 502 policy::BrowserPolicyConnectorChromeOS* connector =
511 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 503 g_browser_process->platform_part()->browser_policy_connector_chromeos();
512 const std::string enterprise_domain = connector->GetEnterpriseDomain(); 504 const std::string enterprise_domain = connector->GetEnterpriseDomain();
513 const bool active_directory_managed = connector->IsActiveDirectoryManaged(); 505 const bool active_directory_managed = connector->IsActiveDirectoryManaged();
514 if (enterprise_domain == last_enterprise_domain_ && 506 if (enterprise_domain == last_enterprise_domain_ &&
515 active_directory_managed == last_active_directory_managed_) { 507 active_directory_managed == last_active_directory_managed_) {
516 return; 508 return;
517 } 509 }
518 // Send to ash, which will add an item to the system tray. 510 // Send to ash, which will add an item to the system tray.
519 system_tray_->SetEnterpriseDomain(enterprise_domain, 511 system_tray_->SetEnterpriseDomain(enterprise_domain,
520 active_directory_managed); 512 active_directory_managed);
521 last_enterprise_domain_ = enterprise_domain; 513 last_enterprise_domain_ = enterprise_domain;
522 last_active_directory_managed_ = active_directory_managed; 514 last_active_directory_managed_ = active_directory_managed;
523 } 515 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/system_tray_client.h ('k') | chrome/browser/ui/ash/system_tray_client_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698