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

Side by Side Diff: chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.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, 8 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
« no previous file with comments | « chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.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 (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/ui/webui/options2/chromeos/internet_options_handler2.h" 5 #include "chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/chromeos/cros/network_library.h" 30 #include "chrome/browser/chromeos/cros/network_library.h"
31 #include "chrome/browser/chromeos/cros/onc_constants.h" 31 #include "chrome/browser/chromeos/cros/onc_constants.h"
32 #include "chrome/browser/chromeos/cros_settings.h" 32 #include "chrome/browser/chromeos/cros_settings.h"
33 #include "chrome/browser/chromeos/mobile_config.h" 33 #include "chrome/browser/chromeos/mobile_config.h"
34 #include "chrome/browser/chromeos/options/network_config_view.h" 34 #include "chrome/browser/chromeos/options/network_config_view.h"
35 #include "chrome/browser/chromeos/proxy_config_service_impl.h" 35 #include "chrome/browser/chromeos/proxy_config_service_impl.h"
36 #include "chrome/browser/chromeos/sim_dialog_delegate.h" 36 #include "chrome/browser/chromeos/sim_dialog_delegate.h"
37 #include "chrome/browser/chromeos/status/network_menu_icon.h" 37 #include "chrome/browser/chromeos/status/network_menu_icon.h"
38 #include "chrome/browser/net/pref_proxy_config_tracker.h" 38 #include "chrome/browser/net/pref_proxy_config_tracker.h"
39 #include "chrome/browser/profiles/profile.h" 39 #include "chrome/browser/profiles/profile.h"
40 #include "chrome/browser/profiles/profile_manager.h"
40 #include "chrome/browser/ui/browser.h" 41 #include "chrome/browser/ui/browser.h"
41 #include "chrome/browser/ui/browser_list.h" 42 #include "chrome/browser/ui/browser_list.h"
42 #include "chrome/browser/ui/browser_window.h" 43 #include "chrome/browser/ui/browser_window.h"
43 #include "chrome/browser/ui/dialog_style.h" 44 #include "chrome/browser/ui/dialog_style.h"
44 #include "chrome/browser/ui/webui/web_ui_util.h" 45 #include "chrome/browser/ui/webui/web_ui_util.h"
45 #include "chrome/common/chrome_notification_types.h" 46 #include "chrome/common/chrome_notification_types.h"
46 #include "chrome/common/chrome_switches.h" 47 #include "chrome/common/chrome_switches.h"
47 #include "chrome/common/time_format.h" 48 #include "chrome/common/time_format.h"
48 #include "content/public/browser/notification_service.h" 49 #include "content/public/browser/notification_service.h"
49 #include "content/public/browser/web_ui.h" 50 #include "content/public/browser/web_ui.h"
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 495
495 void InternetOptionsHandler::EnableWifiCallback(const ListValue* args) { 496 void InternetOptionsHandler::EnableWifiCallback(const ListValue* args) {
496 cros_->EnableWifiNetworkDevice(true); 497 cros_->EnableWifiNetworkDevice(true);
497 } 498 }
498 499
499 void InternetOptionsHandler::DisableWifiCallback(const ListValue* args) { 500 void InternetOptionsHandler::DisableWifiCallback(const ListValue* args) {
500 cros_->EnableWifiNetworkDevice(false); 501 cros_->EnableWifiNetworkDevice(false);
501 } 502 }
502 503
503 void InternetOptionsHandler::EnableCellularCallback(const ListValue* args) { 504 void InternetOptionsHandler::EnableCellularCallback(const ListValue* args) {
505 // TODO(nkostylev): Code duplication, see NetworkMenu::ToggleCellular().
504 const chromeos::NetworkDevice* cellular = cros_->FindCellularDevice(); 506 const chromeos::NetworkDevice* cellular = cros_->FindCellularDevice();
505 if (!cellular) { 507 if (!cellular) {
506 LOG(ERROR) << "Didn't find cellular device, it should have been available."; 508 LOG(ERROR) << "Didn't find cellular device, it should have been available.";
507 cros_->EnableCellularNetworkDevice(true); 509 cros_->EnableCellularNetworkDevice(true);
508 } else if (cellular->sim_lock_state() == chromeos::SIM_UNLOCKED || 510 } else if (!cellular->is_sim_locked()) {
509 cellular->sim_lock_state() == chromeos::SIM_UNKNOWN) { 511 if (cellular->is_sim_absent()) {
512 std::string setup_url;
513 chromeos::MobileConfig* config = chromeos::MobileConfig::GetInstance();
514 if (config->IsReady()) {
515 const chromeos::MobileConfig::LocaleConfig* locale_config =
516 config->GetLocaleConfig();
517 if (locale_config)
518 setup_url = locale_config->setup_url();
519 }
520 if (!setup_url.empty()) {
521 GetAppropriateBrowser()->ShowSingletonTab(GURL(setup_url));
522 } else {
523 // TODO(nkostylev): Show generic error message. http://crosbug.com/15444
524 }
525 } else {
510 cros_->EnableCellularNetworkDevice(true); 526 cros_->EnableCellularNetworkDevice(true);
527 }
511 } else { 528 } else {
512 chromeos::SimDialogDelegate::ShowDialog(GetNativeWindow(), 529 chromeos::SimDialogDelegate::ShowDialog(GetNativeWindow(),
513 chromeos::SimDialogDelegate::SIM_DIALOG_UNLOCK); 530 chromeos::SimDialogDelegate::SIM_DIALOG_UNLOCK);
514 } 531 }
515 } 532 }
516 533
517 void InternetOptionsHandler::DisableCellularCallback(const ListValue* args) { 534 void InternetOptionsHandler::DisableCellularCallback(const ListValue* args) {
518 cros_->EnableCellularNetworkDevice(false); 535 cros_->EnableCellularNetworkDevice(false);
519 } 536 }
520 537
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 } 1058 }
1042 1059
1043 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { 1060 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const {
1044 // TODO(beng): This is an improper direct dependency on Browser. Route this 1061 // TODO(beng): This is an improper direct dependency on Browser. Route this
1045 // through some sort of delegate. 1062 // through some sort of delegate.
1046 Browser* browser = 1063 Browser* browser =
1047 BrowserList::FindBrowserWithProfile(Profile::FromWebUI(web_ui())); 1064 BrowserList::FindBrowserWithProfile(Profile::FromWebUI(web_ui()));
1048 return browser->window()->GetNativeHandle(); 1065 return browser->window()->GetNativeHandle();
1049 } 1066 }
1050 1067
1068 Browser* InternetOptionsHandler::GetAppropriateBrowser() {
1069 return Browser::GetOrCreateTabbedBrowser(
1070 ProfileManager::GetDefaultProfileOrOffTheRecord());
1071 }
1072
1051 void InternetOptionsHandler::ButtonClickCallback(const ListValue* args) { 1073 void InternetOptionsHandler::ButtonClickCallback(const ListValue* args) {
1052 std::string str_type; 1074 std::string str_type;
1053 std::string service_path; 1075 std::string service_path;
1054 std::string command; 1076 std::string command;
1055 if (args->GetSize() != 3 || 1077 if (args->GetSize() != 3 ||
1056 !args->GetString(0, &str_type) || 1078 !args->GetString(0, &str_type) ||
1057 !args->GetString(1, &service_path) || 1079 !args->GetString(1, &service_path) ||
1058 !args->GetString(2, &command)) { 1080 !args->GetString(2, &command)) {
1059 NOTREACHED(); 1081 NOTREACHED();
1060 return; 1082 return;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 if (default_value) 1321 if (default_value)
1300 value_dict->Set("default", default_value->DeepCopy()); 1322 value_dict->Set("default", default_value->DeepCopy());
1301 if (ui_data.managed()) 1323 if (ui_data.managed())
1302 value_dict->SetString("controlledBy", "policy"); 1324 value_dict->SetString("controlledBy", "policy");
1303 else if (ui_data.recommended()) 1325 else if (ui_data.recommended())
1304 value_dict->SetString("controlledBy", "recommended"); 1326 value_dict->SetString("controlledBy", "recommended");
1305 settings->Set(key, value_dict); 1327 settings->Set(key, value_dict);
1306 } 1328 }
1307 1329
1308 } // namespace options2 1330 } // namespace options2
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698