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

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

Issue 22796014: Eliminate c/b/chromeos/options/network_connect.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 4 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/system/ash_system_tray_delegate.h" 5 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "ash/ash_switches.h" 12 #include "ash/ash_switches.h"
13 #include "ash/desktop_background/desktop_background_controller.h" 13 #include "ash/desktop_background/desktop_background_controller.h"
14 #include "ash/session_state_delegate.h" 14 #include "ash/session_state_delegate.h"
15 #include "ash/session_state_observer.h" 15 #include "ash/session_state_observer.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ash/shell_delegate.h" 17 #include "ash/shell_delegate.h"
18 #include "ash/shell_window_ids.h" 18 #include "ash/shell_window_ids.h"
19 #include "ash/system/bluetooth/bluetooth_observer.h" 19 #include "ash/system/bluetooth/bluetooth_observer.h"
20 #include "ash/system/brightness/brightness_observer.h" 20 #include "ash/system/brightness/brightness_observer.h"
21 #include "ash/system/chromeos/network/network_connect.h"
21 #include "ash/system/chromeos/network/network_observer.h" 22 #include "ash/system/chromeos/network/network_observer.h"
22 #include "ash/system/date/clock_observer.h" 23 #include "ash/system/date/clock_observer.h"
23 #include "ash/system/drive/drive_observer.h" 24 #include "ash/system/drive/drive_observer.h"
24 #include "ash/system/ime/ime_observer.h" 25 #include "ash/system/ime/ime_observer.h"
25 #include "ash/system/logout_button/logout_button_observer.h" 26 #include "ash/system/logout_button/logout_button_observer.h"
26 #include "ash/system/tray/system_tray.h" 27 #include "ash/system/tray/system_tray.h"
27 #include "ash/system/tray/system_tray_delegate.h" 28 #include "ash/system/tray/system_tray_delegate.h"
28 #include "ash/system/tray/system_tray_notifier.h" 29 #include "ash/system/tray/system_tray_notifier.h"
29 #include "ash/system/tray_accessibility.h" 30 #include "ash/system/tray_accessibility.h"
30 #include "ash/system/tray_caps_lock.h" 31 #include "ash/system/tray_caps_lock.h"
(...skipping 12 matching lines...) Expand all
43 #include "base/strings/utf_string_conversions.h" 44 #include "base/strings/utf_string_conversions.h"
44 #include "base/time/time.h" 45 #include "base/time/time.h"
45 #include "chrome/browser/browser_process.h" 46 #include "chrome/browser/browser_process.h"
46 #include "chrome/browser/chrome_notification_types.h" 47 #include "chrome/browser/chrome_notification_types.h"
47 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 48 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
48 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 49 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
49 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" 50 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h"
50 #include "chrome/browser/chromeos/choose_mobile_network_dialog.h" 51 #include "chrome/browser/chromeos/choose_mobile_network_dialog.h"
51 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 52 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
52 #include "chrome/browser/chromeos/drive/job_list.h" 53 #include "chrome/browser/chromeos/drive/job_list.h"
54 #include "chrome/browser/chromeos/enrollment_dialog_view.h"
53 #include "chrome/browser/chromeos/input_method/input_method_util.h" 55 #include "chrome/browser/chromeos/input_method/input_method_util.h"
54 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" 56 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
55 #include "chrome/browser/chromeos/login/help_app_launcher.h" 57 #include "chrome/browser/chromeos/login/help_app_launcher.h"
56 #include "chrome/browser/chromeos/login/login_display_host.h" 58 #include "chrome/browser/chromeos/login/login_display_host.h"
57 #include "chrome/browser/chromeos/login/login_display_host_impl.h" 59 #include "chrome/browser/chromeos/login/login_display_host_impl.h"
58 #include "chrome/browser/chromeos/login/login_wizard.h" 60 #include "chrome/browser/chromeos/login/login_wizard.h"
59 #include "chrome/browser/chromeos/login/startup_utils.h" 61 #include "chrome/browser/chromeos/login/startup_utils.h"
60 #include "chrome/browser/chromeos/login/user.h" 62 #include "chrome/browser/chromeos/login/user.h"
61 #include "chrome/browser/chromeos/login/user_adding_screen.h" 63 #include "chrome/browser/chromeos/login/user_adding_screen.h"
62 #include "chrome/browser/chromeos/login/user_manager.h" 64 #include "chrome/browser/chromeos/login/user_manager.h"
63 #include "chrome/browser/chromeos/options/network_config_view.h" 65 #include "chrome/browser/chromeos/options/network_config_view.h"
64 #include "chrome/browser/chromeos/options/network_connect.h"
65 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 66 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
66 #include "chrome/browser/chromeos/settings/cros_settings.h" 67 #include "chrome/browser/chromeos/settings/cros_settings.h"
67 #include "chrome/browser/chromeos/sim_dialog_delegate.h" 68 #include "chrome/browser/chromeos/sim_dialog_delegate.h"
68 #include "chrome/browser/chromeos/status/data_promo_notification.h" 69 #include "chrome/browser/chromeos/status/data_promo_notification.h"
69 #include "chrome/browser/chromeos/system/timezone_settings.h" 70 #include "chrome/browser/chromeos/system/timezone_settings.h"
70 #include "chrome/browser/chromeos/system_key_event_listener.h" 71 #include "chrome/browser/chromeos/system_key_event_listener.h"
71 #include "chrome/browser/drive/drive_service_interface.h" 72 #include "chrome/browser/drive/drive_service_interface.h"
72 #include "chrome/browser/feedback/tracing_manager.h" 73 #include "chrome/browser/feedback/tracing_manager.h"
73 #include "chrome/browser/google/google_util.h" 74 #include "chrome/browser/google/google_util.h"
74 #include "chrome/browser/lifetime/application_lifetime.h" 75 #include "chrome/browser/lifetime/application_lifetime.h"
75 #include "chrome/browser/policy/browser_policy_connector.h" 76 #include "chrome/browser/policy/browser_policy_connector.h"
76 #include "chrome/browser/policy/cloud/cloud_policy_store.h" 77 #include "chrome/browser/policy/cloud/cloud_policy_store.h"
77 #include "chrome/browser/profiles/profile_manager.h" 78 #include "chrome/browser/profiles/profile_manager.h"
78 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" 79 #include "chrome/browser/ui/ash/volume_controller_chromeos.h"
79 #include "chrome/browser/ui/browser.h" 80 #include "chrome/browser/ui/browser.h"
80 #include "chrome/browser/ui/browser_finder.h" 81 #include "chrome/browser/ui/browser_finder.h"
81 #include "chrome/browser/ui/chrome_pages.h" 82 #include "chrome/browser/ui/chrome_pages.h"
82 #include "chrome/browser/ui/host_desktop.h" 83 #include "chrome/browser/ui/host_desktop.h"
83 #include "chrome/browser/ui/singleton_tabs.h" 84 #include "chrome/browser/ui/singleton_tabs.h"
84 #include "chrome/browser/ui/tabs/tab_strip_model.h" 85 #include "chrome/browser/ui/tabs/tab_strip_model.h"
86 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
85 #include "chrome/browser/upgrade_detector.h" 87 #include "chrome/browser/upgrade_detector.h"
86 #include "chrome/common/pref_names.h" 88 #include "chrome/common/pref_names.h"
87 #include "chrome/common/url_constants.h" 89 #include "chrome/common/url_constants.h"
88 #include "chromeos/chromeos_switches.h" 90 #include "chromeos/chromeos_switches.h"
89 #include "chromeos/dbus/dbus_thread_manager.h" 91 #include "chromeos/dbus/dbus_thread_manager.h"
90 #include "chromeos/dbus/power_manager_client.h" 92 #include "chromeos/dbus/power_manager_client.h"
91 #include "chromeos/dbus/session_manager_client.h" 93 #include "chromeos/dbus/session_manager_client.h"
92 #include "chromeos/dbus/system_clock_client.h" 94 #include "chromeos/dbus/system_clock_client.h"
93 #include "chromeos/ime/extension_ime_util.h" 95 #include "chromeos/ime/extension_ime_util.h"
94 #include "chromeos/ime/input_method_manager.h" 96 #include "chromeos/ime/input_method_manager.h"
95 #include "chromeos/ime/xkeyboard.h" 97 #include "chromeos/ime/xkeyboard.h"
96 #include "chromeos/login/login_state.h" 98 #include "chromeos/login/login_state.h"
99 #include "chromeos/network/network_event_log.h"
97 #include "chromeos/network/network_state.h" 100 #include "chromeos/network/network_state.h"
98 #include "chromeos/network/network_state_handler.h" 101 #include "chromeos/network/network_state_handler.h"
99 #include "content/public/browser/browser_thread.h" 102 #include "content/public/browser/browser_thread.h"
100 #include "content/public/browser/notification_observer.h" 103 #include "content/public/browser/notification_observer.h"
101 #include "content/public/browser/notification_service.h" 104 #include "content/public/browser/notification_service.h"
102 #include "content/public/browser/user_metrics.h" 105 #include "content/public/browser/user_metrics.h"
103 #include "content/public/browser/web_contents.h" 106 #include "content/public/browser/web_contents.h"
104 #include "device/bluetooth/bluetooth_adapter.h" 107 #include "device/bluetooth/bluetooth_adapter.h"
105 #include "device/bluetooth/bluetooth_adapter_factory.h" 108 #include "device/bluetooth/bluetooth_adapter_factory.h"
106 #include "device/bluetooth/bluetooth_device.h" 109 #include "device/bluetooth/bluetooth_device.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 214
212 void BluetoothSetDiscoveringError() { 215 void BluetoothSetDiscoveringError() {
213 LOG(ERROR) << "BluetoothSetDiscovering failed."; 216 LOG(ERROR) << "BluetoothSetDiscovering failed.";
214 } 217 }
215 218
216 void BluetoothDeviceConnectError( 219 void BluetoothDeviceConnectError(
217 device::BluetoothDevice::ConnectErrorCode error_code) { 220 device::BluetoothDevice::ConnectErrorCode error_code) {
218 // TODO(sad): Do something? 221 // TODO(sad): Do something?
219 } 222 }
220 223
224 void ShowNetworkSettingsPage(const std::string& service_path) {
225 std::string page = chrome::kInternetOptionsSubPage;
226 const NetworkState* network = service_path.empty() ? NULL :
227 NetworkHandler::Get()->network_state_handler()->GetNetworkState(
228 service_path);
229 if (network) {
230 std::string name(network->name());
231 if (name.empty() && network->type() == flimflam::kTypeEthernet)
232 name = l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
233 page += base::StringPrintf(
234 "?servicePath=%s&networkType=%s&networkName=%s",
235 net::EscapeUrlEncodedData(service_path, true).c_str(),
236 net::EscapeUrlEncodedData(network->type(), true).c_str(),
237 net::EscapeUrlEncodedData(name, false).c_str());
238 }
239 content::RecordAction(
240 content::UserMetricsAction("OpenInternetOptionsDialog"));
241 Browser* browser = chrome::FindOrCreateTabbedBrowser(
242 ProfileManager::GetDefaultProfileOrOffTheRecord(),
243 chrome::HOST_DESKTOP_TYPE_ASH);
244 chrome::ShowSettingsSubPage(browser, page);
245 }
246
247 void HandleUnconfiguredNetwork(const std::string& service_path,
248 gfx::NativeWindow parent_window) {
249 const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
250 GetNetworkState(service_path);
251 if (!network) {
252 NET_LOG_ERROR("Configuring unknown network", service_path);
253 return;
254 }
255
256 if (network->type() == flimflam::kTypeWifi) {
257 // Only show the config view for secure networks, otherwise do nothing.
258 if (network->security() != flimflam::kSecurityNone)
259 NetworkConfigView::Show(service_path, parent_window);
260 return;
261 }
262
263 if (network->type() == flimflam::kTypeWimax ||
264 network->type() == flimflam::kTypeVPN) {
265 NetworkConfigView::Show(service_path, parent_window);
266 return;
267 }
268
269 if (network->type() == flimflam::kTypeCellular) {
270 if (network->activation_state() != flimflam::kActivationStateActivated) {
271 ash::network_connect::ActivateCellular(service_path);
272 return;
273 }
274 if (network->cellular_out_of_credits()) {
275 ash::network_connect::ShowMobileSetup(service_path);
276 return;
277 }
278 // No special configure or setup for |network|, show the settings UI.
279 ShowNetworkSettingsPage(service_path);
280 return;
281 }
282 NOTREACHED();
283 }
284
285 void EnrollmentComplete(const std::string& service_path) {
286 NET_LOG_USER("Enrollment Complete", service_path);
287 }
288
289 bool EnrollNetwork(const std::string& service_path,
290 gfx::NativeWindow parent_window) {
291 const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
292 GetNetworkState(service_path);
293 if (!network) {
294 NET_LOG_ERROR("Enrolling Unknown network", service_path);
295 return false;
296 }
297 // We skip certificate patterns for device policy ONC so that an unmanaged
298 // user can't get to the place where a cert is presented for them
299 // involuntarily.
300 if (network->ui_data().onc_source() == onc::ONC_SOURCE_DEVICE_POLICY)
301 return false;
302
303 const CertificatePattern& certificate_pattern =
304 network->ui_data().certificate_pattern();
305 if (certificate_pattern.Empty())
306 return false;
307
308 NET_LOG_USER("Enrolling", service_path);
309
310 EnrollmentDelegate* enrollment = CreateEnrollmentDelegate(
311 parent_window, network->name(), ProfileManager::GetDefaultProfile());
312 return enrollment->Enroll(certificate_pattern.enrollment_uri_list(),
313 base::Bind(&EnrollmentComplete, service_path));
314 }
315
221 class SystemTrayDelegate : public ash::SystemTrayDelegate, 316 class SystemTrayDelegate : public ash::SystemTrayDelegate,
222 public PowerManagerClient::Observer, 317 public PowerManagerClient::Observer,
223 public SessionManagerClient::Observer, 318 public SessionManagerClient::Observer,
224 public drive::JobListObserver, 319 public drive::JobListObserver,
225 public content::NotificationObserver, 320 public content::NotificationObserver,
226 public input_method::InputMethodManager::Observer, 321 public input_method::InputMethodManager::Observer,
227 public system::TimezoneSettings::Observer, 322 public system::TimezoneSettings::Observer,
228 public chromeos::SystemClockClient::Observer, 323 public chromeos::SystemClockClient::Observer,
229 public device::BluetoothAdapter::Observer, 324 public device::BluetoothAdapter::Observer,
230 public SystemKeyEventListener::CapsLockObserver, 325 public SystemKeyEventListener::CapsLockObserver,
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 virtual void ShowDateSettings() OVERRIDE { 561 virtual void ShowDateSettings() OVERRIDE {
467 content::RecordAction(content::UserMetricsAction("ShowDateOptions")); 562 content::RecordAction(content::UserMetricsAction("ShowDateOptions"));
468 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" + 563 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" +
469 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); 564 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME);
470 chrome::ShowSettingsSubPage(GetAppropriateBrowser(), sub_page); 565 chrome::ShowSettingsSubPage(GetAppropriateBrowser(), sub_page);
471 } 566 }
472 567
473 virtual void ShowNetworkSettings(const std::string& service_path) OVERRIDE { 568 virtual void ShowNetworkSettings(const std::string& service_path) OVERRIDE {
474 if (!LoginState::Get()->IsUserLoggedIn()) 569 if (!LoginState::Get()->IsUserLoggedIn())
475 return; 570 return;
476 network_connect::ShowNetworkSettings(service_path); 571 ShowNetworkSettingsPage(service_path);
477 } 572 }
478 573
479 virtual void ShowBluetoothSettings() OVERRIDE { 574 virtual void ShowBluetoothSettings() OVERRIDE {
480 // TODO(sad): Make this work. 575 // TODO(sad): Make this work.
481 } 576 }
482 577
483 virtual void ShowDisplaySettings() OVERRIDE { 578 virtual void ShowDisplaySettings() OVERRIDE {
484 content::RecordAction(content::UserMetricsAction("ShowDisplayOptions")); 579 content::RecordAction(content::UserMetricsAction("ShowDisplayOptions"));
485 chrome::ShowSettingsSubPage(GetAppropriateBrowser(), 580 chrome::ShowSettingsSubPage(GetAppropriateBrowser(),
486 kDisplaySettingsSubPageName); 581 kDisplaySettingsSubPageName);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 DriveIntegrationService* integration_service = 823 DriveIntegrationService* integration_service =
729 FindDriveIntegrationService(); 824 FindDriveIntegrationService();
730 if (!integration_service) 825 if (!integration_service)
731 return; 826 return;
732 827
733 *list = ConvertToDriveStatusList( 828 *list = ConvertToDriveStatusList(
734 integration_service->job_list()->GetJobInfoList()); 829 integration_service->job_list()->GetJobInfoList());
735 } 830 }
736 831
737 virtual void ConfigureNetwork(const std::string& network_id) OVERRIDE { 832 virtual void ConfigureNetwork(const std::string& network_id) OVERRIDE {
738 network_connect::HandleUnconfiguredNetwork(network_id, GetNativeWindow()); 833 HandleUnconfiguredNetwork(network_id, GetNativeWindow());
739 } 834 }
740 835
741 virtual void EnrollOrConfigureNetwork( 836 virtual void EnrollOrConfigureNetwork(
742 const std::string& network_id, 837 const std::string& network_id,
743 gfx::NativeWindow parent_window) OVERRIDE { 838 gfx::NativeWindow parent_window) OVERRIDE {
744 if (network_connect::EnrollNetwork(network_id, parent_window)) 839 if (EnrollNetwork(network_id, parent_window))
745 return; 840 return;
746 network_connect::HandleUnconfiguredNetwork(network_id, parent_window); 841 HandleUnconfiguredNetwork(network_id, parent_window);
747 } 842 }
748 843
749 virtual void ManageBluetoothDevices() OVERRIDE { 844 virtual void ManageBluetoothDevices() OVERRIDE {
750 content::RecordAction( 845 content::RecordAction(
751 content::UserMetricsAction("ShowBluetoothSettingsPage")); 846 content::UserMetricsAction("ShowBluetoothSettingsPage"));
752 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" + 847 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" +
753 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH); 848 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH);
754 chrome::ShowSettingsSubPage(GetAppropriateBrowser(), sub_page); 849 chrome::ShowSettingsSubPage(GetAppropriateBrowser(), sub_page);
755 } 850 }
756 851
757 virtual void ToggleBluetooth() OVERRIDE { 852 virtual void ToggleBluetooth() OVERRIDE {
758 bluetooth_adapter_->SetPowered(!bluetooth_adapter_->IsPowered(), 853 bluetooth_adapter_->SetPowered(!bluetooth_adapter_->IsPowered(),
759 base::Bind(&base::DoNothing), 854 base::Bind(&base::DoNothing),
760 base::Bind(&BluetoothPowerFailure)); 855 base::Bind(&BluetoothPowerFailure));
761 } 856 }
762 857
763 virtual void ShowMobileSimDialog() OVERRIDE { 858 virtual void ShowMobileSimDialog() OVERRIDE {
764 SimDialogDelegate::ShowDialog(GetNativeWindow(), 859 SimDialogDelegate::ShowDialog(GetNativeWindow(),
765 SimDialogDelegate::SIM_DIALOG_UNLOCK); 860 SimDialogDelegate::SIM_DIALOG_UNLOCK);
766 } 861 }
767 862
768 virtual void ShowMobileSetup(const std::string& network_id) OVERRIDE { 863 virtual void ShowMobileSetupDialog(const std::string& service_path) OVERRIDE {
769 network_connect::ShowMobileSetup(network_id); 864 MobileSetupDialog::Show(service_path);
770 } 865 }
771 866
772 virtual void ShowOtherWifi() OVERRIDE { 867 virtual void ShowOtherWifi() OVERRIDE {
773 NetworkConfigView::ShowForType(flimflam::kTypeWifi, GetNativeWindow()); 868 NetworkConfigView::ShowForType(flimflam::kTypeWifi, GetNativeWindow());
774 } 869 }
775 870
776 virtual void ShowOtherVPN() OVERRIDE { 871 virtual void ShowOtherVPN() OVERRIDE {
777 NetworkConfigView::ShowForType(flimflam::kTypeVPN, GetNativeWindow()); 872 NetworkConfigView::ShowForType(flimflam::kTypeVPN, GetNativeWindow());
778 } 873 }
779 874
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); 1326 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate);
1232 }; 1327 };
1233 1328
1234 } // namespace 1329 } // namespace
1235 1330
1236 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1331 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1237 return new chromeos::SystemTrayDelegate(); 1332 return new chromeos::SystemTrayDelegate();
1238 } 1333 }
1239 1334
1240 } // namespace chromeos 1335 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698