OLD | NEW |
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/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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 // WebUIMessageHandler implementation. | 124 // WebUIMessageHandler implementation. |
125 virtual void RegisterMessages() OVERRIDE; | 125 virtual void RegisterMessages() OVERRIDE; |
126 | 126 |
127 private: | 127 private: |
128 // Handlers for JS WebUI messages. | 128 // Handlers for JS WebUI messages. |
129 void HandleGetRegistrationUrl(const ListValue* args); | 129 void HandleGetRegistrationUrl(const ListValue* args); |
130 void HandleGetUserInfo(const ListValue* args); | 130 void HandleGetUserInfo(const ListValue* args); |
131 | 131 |
132 // Callback from chromeos::VersionLoader giving the version. | 132 // Callback from chromeos::VersionLoader giving the version. |
133 void OnVersion(chromeos::VersionLoader::Handle handle, std::string version); | 133 void OnVersion(chromeos::VersionLoader::Handle handle, |
| 134 const std::string& version); |
134 | 135 |
135 // Skips registration logging |error_msg| with log type ERROR. | 136 // Skips registration logging |error_msg| with log type ERROR. |
136 void SkipRegistration(const std::string& error_msg); | 137 void SkipRegistration(const std::string& error_msg); |
137 | 138 |
138 // Sends message to host registration page with system/user info data. | 139 // Sends message to host registration page with system/user info data. |
139 void SendUserInfo(); | 140 void SendUserInfo(); |
140 | 141 |
141 // Handles asynchronously loading the version. | 142 // Handles asynchronously loading the version. |
142 chromeos::VersionLoader version_loader_; | 143 chromeos::VersionLoader version_loader_; |
143 | 144 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 version_loader_.GetVersion( | 224 version_loader_.GetVersion( |
224 &version_consumer_, | 225 &version_consumer_, |
225 base::Bind(&RegisterPageHandler::OnVersion, base::Unretained(this)), | 226 base::Bind(&RegisterPageHandler::OnVersion, base::Unretained(this)), |
226 chromeos::VersionLoader::VERSION_FULL); | 227 chromeos::VersionLoader::VERSION_FULL); |
227 } else { | 228 } else { |
228 SkipRegistration("Not running on ChromeOS."); | 229 SkipRegistration("Not running on ChromeOS."); |
229 } | 230 } |
230 } | 231 } |
231 | 232 |
232 void RegisterPageHandler::OnVersion(chromeos::VersionLoader::Handle handle, | 233 void RegisterPageHandler::OnVersion(chromeos::VersionLoader::Handle handle, |
233 std::string version) { | 234 const std::string& version) { |
234 version_ = version; | 235 version_ = version; |
235 SendUserInfo(); | 236 SendUserInfo(); |
236 } | 237 } |
237 | 238 |
238 void RegisterPageHandler::SkipRegistration(const std::string& error_msg) { | 239 void RegisterPageHandler::SkipRegistration(const std::string& error_msg) { |
239 LOG(ERROR) << error_msg; | 240 LOG(ERROR) << error_msg; |
240 if (chromeos::WizardController::default_controller()) | 241 if (chromeos::WizardController::default_controller()) |
241 chromeos::WizardController::default_controller()->SkipRegistration(); | 242 chromeos::WizardController::default_controller()->SkipRegistration(); |
242 else | 243 else |
243 web_ui()->CallJavascriptFunction(kJsApiSkipRegistration); | 244 web_ui()->CallJavascriptFunction(kJsApiSkipRegistration); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 RegisterPageUI::RegisterPageUI(content::WebUI* web_ui) | 284 RegisterPageUI::RegisterPageUI(content::WebUI* web_ui) |
284 : WebUIController(web_ui) { | 285 : WebUIController(web_ui) { |
285 RegisterPageHandler* handler = new RegisterPageHandler(); | 286 RegisterPageHandler* handler = new RegisterPageHandler(); |
286 web_ui->AddMessageHandler(handler); | 287 web_ui->AddMessageHandler(handler); |
287 RegisterPageUIHTMLSource* html_source = new RegisterPageUIHTMLSource(); | 288 RegisterPageUIHTMLSource* html_source = new RegisterPageUIHTMLSource(); |
288 | 289 |
289 // Set up the chrome://register/ source. | 290 // Set up the chrome://register/ source. |
290 Profile* profile = Profile::FromWebUI(web_ui); | 291 Profile* profile = Profile::FromWebUI(web_ui); |
291 ChromeURLDataManager::AddDataSource(profile, html_source); | 292 ChromeURLDataManager::AddDataSource(profile, html_source); |
292 } | 293 } |
OLD | NEW |