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/register_page_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/register_page_ui.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 | 55 |
56 // Utility function that returns string corresponding to currently active | 56 // Utility function that returns string corresponding to currently active |
57 // connection type |kConnectionEthernet|kConnectionWifi|kConnection3g|. | 57 // connection type |kConnectionEthernet|kConnectionWifi|kConnection3g|. |
58 // If multiple interfaces are connected, result is based on the | 58 // If multiple interfaces are connected, result is based on the |
59 // priority Ethernet-Wifi-Cellular. | 59 // priority Ethernet-Wifi-Cellular. |
60 // If there's no interface that's connected, interface that's in connecting | 60 // If there's no interface that's connected, interface that's in connecting |
61 // state is considered as the active one. | 61 // state is considered as the active one. |
62 // Otherwise |kUndefinedValue| is returned. | 62 // Otherwise |kUndefinedValue| is returned. |
63 #if defined(OS_CHROMEOS) | 63 #if defined(OS_CHROMEOS) |
64 static std::string GetConnectionType() { | 64 static std::string GetConnectionType() { |
65 if (!chromeos::CrosLibrary::Get()->EnsureLoaded()) { | |
66 LOG(ERROR) << "CrosLibrary is not loaded."; | |
67 return kUndefinedValue; | |
68 } | |
69 | |
70 chromeos::NetworkLibrary* network_lib = | 65 chromeos::NetworkLibrary* network_lib = |
71 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 66 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
72 if (network_lib->ethernet_connected()) | 67 if (network_lib->ethernet_connected()) |
73 return kConnectionEthernet; | 68 return kConnectionEthernet; |
74 else if (network_lib->wifi_connected()) | 69 else if (network_lib->wifi_connected()) |
75 return kConnectionWifi; | 70 return kConnectionWifi; |
76 else if (network_lib->cellular_connected()) | 71 else if (network_lib->cellular_connected()) |
77 return kConnection3g; | 72 return kConnection3g; |
78 // Connection might have been lost and is in reconnecting state at this point. | 73 // Connection might have been lost and is in reconnecting state at this point. |
79 else if (network_lib->ethernet_connecting()) | 74 else if (network_lib->ethernet_connecting()) |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 StringValue url_value(url); | 225 StringValue url_value(url); |
231 web_ui_->CallJavascriptFunction(kJsApiSetRegistrationUrl, url_value); | 226 web_ui_->CallJavascriptFunction(kJsApiSetRegistrationUrl, url_value); |
232 } else { | 227 } else { |
233 SkipRegistration("Startup manifest not defined."); | 228 SkipRegistration("Startup manifest not defined."); |
234 } | 229 } |
235 #endif | 230 #endif |
236 } | 231 } |
237 | 232 |
238 void RegisterPageHandler::HandleGetUserInfo(const ListValue* args) { | 233 void RegisterPageHandler::HandleGetUserInfo(const ListValue* args) { |
239 #if defined(OS_CHROMEOS) | 234 #if defined(OS_CHROMEOS) |
240 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) { | 235 if (chromeos::CrosLibrary::Get()->libcros_loaded()) { |
satorux1
2011/11/16 23:51:34
IsRunningOnChromeOS()?
stevenjb
2011/11/17 00:23:33
Done.
| |
241 version_loader_.GetVersion( | 236 version_loader_.GetVersion( |
242 &version_consumer_, | 237 &version_consumer_, |
243 base::Bind(&RegisterPageHandler::OnVersion, base::Unretained(this)), | 238 base::Bind(&RegisterPageHandler::OnVersion, base::Unretained(this)), |
244 chromeos::VersionLoader::VERSION_FULL); | 239 chromeos::VersionLoader::VERSION_FULL); |
245 } else { | 240 } else { |
246 SkipRegistration("CrosLibrary is not loaded."); | 241 SkipRegistration("CrosLibrary is not loaded."); |
satorux1
2011/11/16 23:51:34
"Not running on Chrome OS" ?
stevenjb
2011/11/17 00:23:33
Done.
| |
247 } | 242 } |
248 #endif | 243 #endif |
249 } | 244 } |
250 | 245 |
251 #if defined(OS_CHROMEOS) | 246 #if defined(OS_CHROMEOS) |
252 void RegisterPageHandler::OnVersion(chromeos::VersionLoader::Handle handle, | 247 void RegisterPageHandler::OnVersion(chromeos::VersionLoader::Handle handle, |
253 std::string version) { | 248 std::string version) { |
254 version_ = version; | 249 version_ = version; |
255 SendUserInfo(); | 250 SendUserInfo(); |
256 } | 251 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 RegisterPageUI::RegisterPageUI(TabContents* contents) : ChromeWebUI(contents) { | 303 RegisterPageUI::RegisterPageUI(TabContents* contents) : ChromeWebUI(contents) { |
309 RegisterPageHandler* handler = new RegisterPageHandler(); | 304 RegisterPageHandler* handler = new RegisterPageHandler(); |
310 AddMessageHandler((handler)->Attach(this)); | 305 AddMessageHandler((handler)->Attach(this)); |
311 handler->Init(); | 306 handler->Init(); |
312 RegisterPageUIHTMLSource* html_source = new RegisterPageUIHTMLSource(); | 307 RegisterPageUIHTMLSource* html_source = new RegisterPageUIHTMLSource(); |
313 | 308 |
314 // Set up the chrome://register/ source. | 309 // Set up the chrome://register/ source. |
315 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); | 310 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); |
316 profile->GetChromeURLDataManager()->AddDataSource(html_source); | 311 profile->GetChromeURLDataManager()->AddDataSource(html_source); |
317 } | 312 } |
OLD | NEW |