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

Side by Side Diff: chrome/browser/dom_ui/register_page_ui.cc

Issue 3058006: Add API on host registration page. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: fixes Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/dom_ui/register_page_ui.h" 5 #include "chrome/browser/dom_ui/register_page_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 !WizardController::default_controller()->is_oobe()) { 112 !WizardController::default_controller()->is_oobe()) {
113 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); 113 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes);
114 SendResponse(request_id, empty_bytes); 114 SendResponse(request_id, empty_bytes);
115 return; 115 return;
116 } 116 }
117 117
118 static const base::StringPiece register_html( 118 static const base::StringPiece register_html(
119 ResourceBundle::GetSharedInstance().GetRawDataResource( 119 ResourceBundle::GetSharedInstance().GetRawDataResource(
120 IDR_HOST_REGISTRATION_PAGE_HTML)); 120 IDR_HOST_REGISTRATION_PAGE_HTML));
121 121
122 // TODO(nkostylev): Embed registration form URL from startup manifest.
123 // http://crosbug.com/4645.
124
125 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); 122 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
126 html_bytes->data.resize(register_html.size()); 123 html_bytes->data.resize(register_html.size());
127 std::copy(register_html.begin(), 124 std::copy(register_html.begin(),
128 register_html.end(), 125 register_html.end(),
129 html_bytes->data.begin()); 126 html_bytes->data.begin());
130 127
131 SendResponse(request_id, html_bytes); 128 SendResponse(request_id, html_bytes);
132 #else 129 #else
133 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); 130 scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes);
134 SendResponse(request_id, empty_bytes); 131 SendResponse(request_id, empty_bytes);
(...skipping 24 matching lines...) Expand all
159 NewCallback(this, &RegisterPageHandler::HandleGetRegistrationUrl)); 156 NewCallback(this, &RegisterPageHandler::HandleGetRegistrationUrl));
160 dom_ui_->RegisterMessageCallback("getUserInfo", 157 dom_ui_->RegisterMessageCallback("getUserInfo",
161 NewCallback(this, &RegisterPageHandler::HandleGetUserInfo)); 158 NewCallback(this, &RegisterPageHandler::HandleGetUserInfo));
162 #endif 159 #endif
163 } 160 }
164 161
165 void RegisterPageHandler::HandleGetRegistrationUrl(const Value* value) { 162 void RegisterPageHandler::HandleGetRegistrationUrl(const Value* value) {
166 #if defined(OS_CHROMEOS) 163 #if defined(OS_CHROMEOS)
167 if (WizardController::default_controller() && 164 if (WizardController::default_controller() &&
168 WizardController::default_controller()->GetCustomization()) { 165 WizardController::default_controller()->GetCustomization()) {
169 StringValue url_value(WizardController::default_controller()-> 166 const std::string& url = WizardController::default_controller()->
170 GetCustomization()->registration_url()); 167 GetCustomization()->registration_url();
168 LOG(INFO) << "Loading registration form with URL: " << url;
169 StringValue url_value(url);
171 dom_ui_->CallJavascriptFunction(L"setRegistrationUrl", url_value); 170 dom_ui_->CallJavascriptFunction(L"setRegistrationUrl", url_value);
172 } else { 171 } else {
173 LOG(ERROR) << "Startup manifest not defined."; 172 LOG(ERROR) << "Startup manifest not defined.";
174 } 173 }
175 #endif 174 #endif
176 } 175 }
177 176
178 void RegisterPageHandler::HandleGetUserInfo(const Value* value) { 177 void RegisterPageHandler::HandleGetUserInfo(const Value* value) {
179 #if defined(OS_CHROMEOS) 178 #if defined(OS_CHROMEOS)
180 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) { 179 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 UTF8ToWide(g_browser_process->GetApplicationLocale())); 217 UTF8ToWide(g_browser_process->GetApplicationLocale()));
219 value.SetString(L"os_name", kOSName); 218 value.SetString(L"os_name", kOSName);
220 value.SetString(L"os_version", UTF8ToWide(version_)); 219 value.SetString(L"os_version", UTF8ToWide(version_));
221 value.SetString(L"os_connection", L"connection type"); 220 value.SetString(L"os_connection", L"connection type");
222 value.SetString(L"user_email", L""); 221 value.SetString(L"user_email", L"");
223 222
224 // Optional info. 223 // Optional info.
225 value.SetString(L"user_first_name", L""); 224 value.SetString(L"user_first_name", L"");
226 value.SetString(L"user_last_name", L""); 225 value.SetString(L"user_last_name", L"");
227 226
227 LOG(INFO) << "Sending user info to host page";
228 dom_ui_->CallJavascriptFunction(L"setUserInfo", value); 228 dom_ui_->CallJavascriptFunction(L"setUserInfo", value);
229 #endif 229 #endif
230 } 230 }
231 231
232 //////////////////////////////////////////////////////////////////////////////// 232 ////////////////////////////////////////////////////////////////////////////////
233 // 233 //
234 // RegisterPageUI 234 // RegisterPageUI
235 // 235 //
236 //////////////////////////////////////////////////////////////////////////////// 236 ////////////////////////////////////////////////////////////////////////////////
237 237
238 RegisterPageUI::RegisterPageUI(TabContents* contents) : DOMUI(contents){ 238 RegisterPageUI::RegisterPageUI(TabContents* contents) : DOMUI(contents){
239 RegisterPageHandler* handler = new RegisterPageHandler(); 239 RegisterPageHandler* handler = new RegisterPageHandler();
240 AddMessageHandler((handler)->Attach(this)); 240 AddMessageHandler((handler)->Attach(this));
241 handler->Init(); 241 handler->Init();
242 RegisterPageUIHTMLSource* html_source = new RegisterPageUIHTMLSource(); 242 RegisterPageUIHTMLSource* html_source = new RegisterPageUIHTMLSource();
243 243
244 // Set up the chrome://register/ source. 244 // Set up the chrome://register/ source.
245 ChromeThread::PostTask( 245 ChromeThread::PostTask(
246 ChromeThread::IO, FROM_HERE, 246 ChromeThread::IO, FROM_HERE,
247 NewRunnableMethod( 247 NewRunnableMethod(
248 Singleton<ChromeURLDataManager>::get(), 248 Singleton<ChromeURLDataManager>::get(),
249 &ChromeURLDataManager::AddDataSource, 249 &ChromeURLDataManager::AddDataSource,
250 make_scoped_refptr(html_source))); 250 make_scoped_refptr(html_source)));
251 } 251 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/wizard_controller.cc ('k') | chrome/browser/resources/host_registration_page.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698