| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/choose_mobile_network_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 bool is_page_ready_; | 92 bool is_page_ready_; |
| 93 bool has_pending_results_; | 93 bool has_pending_results_; |
| 94 | 94 |
| 95 DISALLOW_COPY_AND_ASSIGN(ChooseMobileNetworkHandler); | 95 DISALLOW_COPY_AND_ASSIGN(ChooseMobileNetworkHandler); |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 // ChooseMobileNetworkHandler implementation. | 98 // ChooseMobileNetworkHandler implementation. |
| 99 | 99 |
| 100 ChooseMobileNetworkHandler::ChooseMobileNetworkHandler() | 100 ChooseMobileNetworkHandler::ChooseMobileNetworkHandler() |
| 101 : is_page_ready_(false), has_pending_results_(false) { | 101 : is_page_ready_(false), has_pending_results_(false) { |
| 102 if (!CrosLibrary::Get()->EnsureLoaded()) | |
| 103 return; | |
| 104 | |
| 105 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 102 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
| 106 if (const NetworkDevice* cellular = cros->FindCellularDevice()) { | 103 if (const NetworkDevice* cellular = cros->FindCellularDevice()) { |
| 107 device_path_ = cellular->device_path(); | 104 device_path_ = cellular->device_path(); |
| 108 cros->AddNetworkDeviceObserver(device_path_, this); | 105 cros->AddNetworkDeviceObserver(device_path_, this); |
| 109 } | 106 } |
| 110 cros->RequestCellularScan(); | 107 cros->RequestCellularScan(); |
| 111 } | 108 } |
| 112 | 109 |
| 113 ChooseMobileNetworkHandler::~ChooseMobileNetworkHandler() { | 110 ChooseMobileNetworkHandler::~ChooseMobileNetworkHandler() { |
| 114 if (!device_path_.empty()) { | 111 if (!device_path_.empty()) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 164 } |
| 168 } | 165 } |
| 169 | 166 |
| 170 void ChooseMobileNetworkHandler::HandleCancel(const ListValue* args) { | 167 void ChooseMobileNetworkHandler::HandleCancel(const ListValue* args) { |
| 171 const size_t kConnectParamCount = 0; | 168 const size_t kConnectParamCount = 0; |
| 172 if (args->GetSize() != kConnectParamCount) { | 169 if (args->GetSize() != kConnectParamCount) { |
| 173 NOTREACHED(); | 170 NOTREACHED(); |
| 174 return; | 171 return; |
| 175 } | 172 } |
| 176 | 173 |
| 177 if (!CrosLibrary::Get()->EnsureLoaded()) | |
| 178 return; | |
| 179 | |
| 180 // Switch to automatic mode. | 174 // Switch to automatic mode. |
| 181 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 175 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
| 182 cros->RequestCellularRegister(std::string()); | 176 cros->RequestCellularRegister(std::string()); |
| 183 } | 177 } |
| 184 | 178 |
| 185 void ChooseMobileNetworkHandler::HandleConnect(const ListValue* args) { | 179 void ChooseMobileNetworkHandler::HandleConnect(const ListValue* args) { |
| 186 std::string network_id; | 180 std::string network_id; |
| 187 const size_t kConnectParamCount = 1; | 181 const size_t kConnectParamCount = 1; |
| 188 if (args->GetSize() != kConnectParamCount || | 182 if (args->GetSize() != kConnectParamCount || |
| 189 !args->GetString(0, &network_id)) { | 183 !args->GetString(0, &network_id)) { |
| 190 NOTREACHED(); | 184 NOTREACHED(); |
| 191 return; | 185 return; |
| 192 } | 186 } |
| 193 | 187 |
| 194 if (!CrosLibrary::Get()->EnsureLoaded()) | |
| 195 return; | |
| 196 | |
| 197 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 188 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
| 198 cros->RequestCellularRegister(network_id); | 189 cros->RequestCellularRegister(network_id); |
| 199 } | 190 } |
| 200 | 191 |
| 201 void ChooseMobileNetworkHandler::HandlePageReady(const ListValue* args) { | 192 void ChooseMobileNetworkHandler::HandlePageReady(const ListValue* args) { |
| 202 const size_t kConnectParamCount = 0; | 193 const size_t kConnectParamCount = 0; |
| 203 if (args->GetSize() != kConnectParamCount) { | 194 if (args->GetSize() != kConnectParamCount) { |
| 204 NOTREACHED(); | 195 NOTREACHED(); |
| 205 return; | 196 return; |
| 206 } | 197 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 219 : ChromeWebUI(contents) { | 210 : ChromeWebUI(contents) { |
| 220 ChooseMobileNetworkHandler* handler = new ChooseMobileNetworkHandler(); | 211 ChooseMobileNetworkHandler* handler = new ChooseMobileNetworkHandler(); |
| 221 AddMessageHandler((handler)->Attach(this)); | 212 AddMessageHandler((handler)->Attach(this)); |
| 222 // Set up the "chrome://choose-mobile-network" source. | 213 // Set up the "chrome://choose-mobile-network" source. |
| 223 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); | 214 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); |
| 224 profile->GetChromeURLDataManager()->AddDataSource( | 215 profile->GetChromeURLDataManager()->AddDataSource( |
| 225 CreateChooseMobileNetworkUIHTMLSource()); | 216 CreateChooseMobileNetworkUIHTMLSource()); |
| 226 } | 217 } |
| 227 | 218 |
| 228 } // namespace chromeos | 219 } // namespace chromeos |
| OLD | NEW |