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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/string_piece.h" | 13 #include "base/string_piece.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/chromeos/cros/cros_library.h" | 17 #include "chrome/browser/chromeos/cros/cros_library.h" |
18 #include "chrome/browser/chromeos/cros/network_library.h" | 18 #include "chrome/browser/chromeos/cros/network_library.h" |
19 #include "chrome/browser/chromeos/customization_document.h" | 19 #include "chrome/browser/chromeos/customization_document.h" |
20 #include "chrome/browser/chromeos/login/wizard_controller.h" | 20 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 21 #include "chrome/browser/chromeos/system/runtime_environment.h" |
21 #include "chrome/browser/chromeos/system/statistics_provider.h" | 22 #include "chrome/browser/chromeos/system/statistics_provider.h" |
22 #include "chrome/browser/chromeos/version_loader.h" | 23 #include "chrome/browser/chromeos/version_loader.h" |
23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 25 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
25 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
26 #include "content/browser/tab_contents/tab_contents.h" | 27 #include "content/browser/tab_contents/tab_contents.h" |
27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
28 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
29 #include "grit/browser_resources.h" | 30 #include "grit/browser_resources.h" |
30 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
(...skipping 24 matching lines...) Expand all Loading... |
55 | 56 |
56 // Utility function that returns string corresponding to currently active | 57 // Utility function that returns string corresponding to currently active |
57 // connection type |kConnectionEthernet|kConnectionWifi|kConnection3g|. | 58 // connection type |kConnectionEthernet|kConnectionWifi|kConnection3g|. |
58 // If multiple interfaces are connected, result is based on the | 59 // If multiple interfaces are connected, result is based on the |
59 // priority Ethernet-Wifi-Cellular. | 60 // priority Ethernet-Wifi-Cellular. |
60 // If there's no interface that's connected, interface that's in connecting | 61 // If there's no interface that's connected, interface that's in connecting |
61 // state is considered as the active one. | 62 // state is considered as the active one. |
62 // Otherwise |kUndefinedValue| is returned. | 63 // Otherwise |kUndefinedValue| is returned. |
63 #if defined(OS_CHROMEOS) | 64 #if defined(OS_CHROMEOS) |
64 static std::string GetConnectionType() { | 65 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 = | 66 chromeos::NetworkLibrary* network_lib = |
71 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 67 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
72 if (network_lib->ethernet_connected()) | 68 if (network_lib->ethernet_connected()) |
73 return kConnectionEthernet; | 69 return kConnectionEthernet; |
74 else if (network_lib->wifi_connected()) | 70 else if (network_lib->wifi_connected()) |
75 return kConnectionWifi; | 71 return kConnectionWifi; |
76 else if (network_lib->cellular_connected()) | 72 else if (network_lib->cellular_connected()) |
77 return kConnection3g; | 73 return kConnection3g; |
78 // Connection might have been lost and is in reconnecting state at this point. | 74 // Connection might have been lost and is in reconnecting state at this point. |
79 else if (network_lib->ethernet_connecting()) | 75 else if (network_lib->ethernet_connecting()) |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 StringValue url_value(url); | 226 StringValue url_value(url); |
231 web_ui_->CallJavascriptFunction(kJsApiSetRegistrationUrl, url_value); | 227 web_ui_->CallJavascriptFunction(kJsApiSetRegistrationUrl, url_value); |
232 } else { | 228 } else { |
233 SkipRegistration("Startup manifest not defined."); | 229 SkipRegistration("Startup manifest not defined."); |
234 } | 230 } |
235 #endif | 231 #endif |
236 } | 232 } |
237 | 233 |
238 void RegisterPageHandler::HandleGetUserInfo(const ListValue* args) { | 234 void RegisterPageHandler::HandleGetUserInfo(const ListValue* args) { |
239 #if defined(OS_CHROMEOS) | 235 #if defined(OS_CHROMEOS) |
240 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) { | 236 if (chromeos::system::runtime_environment::IsRunningOnChromeOS()) { |
241 version_loader_.GetVersion( | 237 version_loader_.GetVersion( |
242 &version_consumer_, | 238 &version_consumer_, |
243 base::Bind(&RegisterPageHandler::OnVersion, base::Unretained(this)), | 239 base::Bind(&RegisterPageHandler::OnVersion, base::Unretained(this)), |
244 chromeos::VersionLoader::VERSION_FULL); | 240 chromeos::VersionLoader::VERSION_FULL); |
245 } else { | 241 } else { |
246 SkipRegistration("CrosLibrary is not loaded."); | 242 SkipRegistration("Not running on ChromeOS."); |
247 } | 243 } |
248 #endif | 244 #endif |
249 } | 245 } |
250 | 246 |
251 #if defined(OS_CHROMEOS) | 247 #if defined(OS_CHROMEOS) |
252 void RegisterPageHandler::OnVersion(chromeos::VersionLoader::Handle handle, | 248 void RegisterPageHandler::OnVersion(chromeos::VersionLoader::Handle handle, |
253 std::string version) { | 249 std::string version) { |
254 version_ = version; | 250 version_ = version; |
255 SendUserInfo(); | 251 SendUserInfo(); |
256 } | 252 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 RegisterPageUI::RegisterPageUI(TabContents* contents) : ChromeWebUI(contents) { | 304 RegisterPageUI::RegisterPageUI(TabContents* contents) : ChromeWebUI(contents) { |
309 RegisterPageHandler* handler = new RegisterPageHandler(); | 305 RegisterPageHandler* handler = new RegisterPageHandler(); |
310 AddMessageHandler((handler)->Attach(this)); | 306 AddMessageHandler((handler)->Attach(this)); |
311 handler->Init(); | 307 handler->Init(); |
312 RegisterPageUIHTMLSource* html_source = new RegisterPageUIHTMLSource(); | 308 RegisterPageUIHTMLSource* html_source = new RegisterPageUIHTMLSource(); |
313 | 309 |
314 // Set up the chrome://register/ source. | 310 // Set up the chrome://register/ source. |
315 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); | 311 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); |
316 profile->GetChromeURLDataManager()->AddDataSource(html_source); | 312 profile->GetChromeURLDataManager()->AddDataSource(html_source); |
317 } | 313 } |
OLD | NEW |