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

Side by Side Diff: chrome/browser/chromeos/status/network_menu.cc

Issue 10201015: [cros] Add network tray item for mobile network setup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 8 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 | 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/status/network_menu.h" 5 #include "chrome/browser/chromeos/status/network_menu.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_delegate.h" 10 #include "ash/shell_delegate.h"
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); 1057 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
1058 cros->EnableWifiNetworkDevice(!cros->wifi_enabled()); 1058 cros->EnableWifiNetworkDevice(!cros->wifi_enabled());
1059 } 1059 }
1060 1060
1061 void NetworkMenu::ToggleCellular() { 1061 void NetworkMenu::ToggleCellular() {
1062 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); 1062 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
1063 const NetworkDevice* cellular = cros->FindCellularDevice(); 1063 const NetworkDevice* cellular = cros->FindCellularDevice();
1064 if (!cellular) { 1064 if (!cellular) {
1065 LOG(ERROR) << "No cellular device found, it should be available."; 1065 LOG(ERROR) << "No cellular device found, it should be available.";
1066 cros->EnableCellularNetworkDevice(!cros->cellular_enabled()); 1066 cros->EnableCellularNetworkDevice(!cros->cellular_enabled());
1067 } else if (cellular->sim_lock_state() == SIM_UNLOCKED || 1067 } else if (!cellular->is_sim_locked()) {
1068 cellular->sim_lock_state() == SIM_UNKNOWN) { 1068 if (cellular->is_sim_absent()) {
1069 cros->EnableCellularNetworkDevice(!cros->cellular_enabled()); 1069 std::string setup_url;
1070 MobileConfig* config = MobileConfig::GetInstance();
1071 if (config->IsReady()) {
1072 const MobileConfig::LocaleConfig* locale_config =
1073 config->GetLocaleConfig();
1074 if (locale_config)
1075 setup_url = locale_config->setup_url();
1076 }
1077 if (!setup_url.empty()) {
1078 GetAppropriateBrowser()->ShowSingletonTab(GURL(setup_url));
1079 } else {
1080 // TODO(nkostylev): Show generic error message. http://crosbug.com/15444
1081 }
1082 } else {
1083 cros->EnableCellularNetworkDevice(!cros->cellular_enabled());
1084 }
1070 } else { 1085 } else {
1071 SimDialogDelegate::ShowDialog(delegate()->GetNativeWindow(), 1086 SimDialogDelegate::ShowDialog(delegate()->GetNativeWindow(),
1072 SimDialogDelegate::SIM_DIALOG_UNLOCK); 1087 SimDialogDelegate::SIM_DIALOG_UNLOCK);
1073 } 1088 }
1074 } 1089 }
1075 1090
1076 void NetworkMenu::ShowOtherWifi() { 1091 void NetworkMenu::ShowOtherWifi() {
1077 NetworkConfigView* view = new NetworkConfigView(TYPE_WIFI); 1092 NetworkConfigView* view = new NetworkConfigView(TYPE_WIFI);
1078 views::Widget* window = views::Widget::CreateWindowWithParent( 1093 views::Widget* window = views::Widget::CreateWindowWithParent(
1079 view, delegate_->GetNativeWindow()); 1094 view, delegate_->GetNativeWindow());
1080 window->SetAlwaysOnTop(true); 1095 window->SetAlwaysOnTop(true);
1081 window->Show(); 1096 window->Show();
1082 } 1097 }
1083 1098
1084 void NetworkMenu::ShowOtherCellular() { 1099 void NetworkMenu::ShowOtherCellular() {
1085 ChooseMobileNetworkDialog::ShowDialog(delegate_->GetNativeWindow()); 1100 ChooseMobileNetworkDialog::ShowDialog(delegate_->GetNativeWindow());
1086 } 1101 }
1087 1102
1088 bool NetworkMenu::ShouldHighlightNetwork(const Network* network) { 1103 bool NetworkMenu::ShouldHighlightNetwork(const Network* network) {
1089 return ::ShouldHighlightNetwork(network); 1104 return ::ShouldHighlightNetwork(network);
1090 } 1105 }
1091 1106
1107 Browser* NetworkMenu::GetAppropriateBrowser() {
1108 return Browser::GetOrCreateTabbedBrowser(
1109 ProfileManager::GetDefaultProfileOrOffTheRecord());
1110 }
1111
1092 } // namespace chromeos 1112 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/status/network_menu.h ('k') | chrome/browser/chromeos/system/ash_system_tray_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698