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/options/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/options/sync_setup_handler.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/google/google_util.h" | 10 #include "chrome/browser/google/google_util.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX }, | 246 IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX }, |
247 }; | 247 }; |
248 | 248 |
249 RegisterStrings(localized_strings, resources, arraysize(resources)); | 249 RegisterStrings(localized_strings, resources, arraysize(resources)); |
250 } | 250 } |
251 | 251 |
252 void SyncSetupHandler::Initialize() { | 252 void SyncSetupHandler::Initialize() { |
253 } | 253 } |
254 | 254 |
255 void SyncSetupHandler::RegisterMessages() { | 255 void SyncSetupHandler::RegisterMessages() { |
256 web_ui_->RegisterMessageCallback("didShowPage", | 256 web_ui_->RegisterMessageCallback("SyncSetupDidClosePage", |
257 NewCallback(this, &SyncSetupHandler::OnDidShowPage)); | |
258 web_ui_->RegisterMessageCallback("didClosePage", | |
259 NewCallback(this, &SyncSetupHandler::OnDidClosePage)); | 257 NewCallback(this, &SyncSetupHandler::OnDidClosePage)); |
260 web_ui_->RegisterMessageCallback("SubmitAuth", | 258 web_ui_->RegisterMessageCallback("SyncSetupSubmitAuth", |
261 NewCallback(this, &SyncSetupHandler::HandleSubmitAuth)); | 259 NewCallback(this, &SyncSetupHandler::HandleSubmitAuth)); |
262 web_ui_->RegisterMessageCallback("Configure", | 260 web_ui_->RegisterMessageCallback("SyncSetupConfigure", |
263 NewCallback(this, &SyncSetupHandler::HandleConfigure)); | 261 NewCallback(this, &SyncSetupHandler::HandleConfigure)); |
264 web_ui_->RegisterMessageCallback("Passphrase", | 262 web_ui_->RegisterMessageCallback("SyncSetupPassphrase", |
265 NewCallback(this, &SyncSetupHandler::HandlePassphraseEntry)); | 263 NewCallback(this, &SyncSetupHandler::HandlePassphraseEntry)); |
266 web_ui_->RegisterMessageCallback("PassphraseCancel", | 264 web_ui_->RegisterMessageCallback("SyncSetupPassphraseCancel", |
267 NewCallback(this, &SyncSetupHandler::HandlePassphraseCancel)); | 265 NewCallback(this, &SyncSetupHandler::HandlePassphraseCancel)); |
| 266 web_ui_->RegisterMessageCallback("SyncSetupAttachHandler", |
| 267 NewCallback(this, &SyncSetupHandler::HandleAttachHandler)); |
268 } | 268 } |
269 | 269 |
270 void SyncSetupHandler::ShowGaiaLogin(const DictionaryValue& args) { | 270 void SyncSetupHandler::ShowGaiaLogin(const DictionaryValue& args) { |
271 StringValue page("login"); | 271 StringValue page("login"); |
272 web_ui_->CallJavascriptFunction( | 272 web_ui_->CallJavascriptFunction( |
273 "SyncSetupOverlay.showSyncSetupPage", page, args); | 273 "SyncSetupOverlay.showSyncSetupPage", page, args); |
274 } | 274 } |
275 | 275 |
276 void SyncSetupHandler::ShowGaiaSuccessAndClose() { | 276 void SyncSetupHandler::ShowGaiaSuccessAndClose() { |
277 web_ui_->CallJavascriptFunction("SyncSetupOverlay.showSuccessAndClose"); | 277 web_ui_->CallJavascriptFunction("SyncSetupOverlay.showSuccessAndClose"); |
(...skipping 24 matching lines...) Expand all Loading... |
302 void SyncSetupHandler::ShowSetupDone(const std::wstring& user) { | 302 void SyncSetupHandler::ShowSetupDone(const std::wstring& user) { |
303 StringValue page("done"); | 303 StringValue page("done"); |
304 web_ui_->CallJavascriptFunction( | 304 web_ui_->CallJavascriptFunction( |
305 "SyncSetupOverlay.showSyncSetupPage", page); | 305 "SyncSetupOverlay.showSyncSetupPage", page); |
306 } | 306 } |
307 | 307 |
308 void SyncSetupHandler::SetFlow(SyncSetupFlow* flow) { | 308 void SyncSetupHandler::SetFlow(SyncSetupFlow* flow) { |
309 flow_ = flow; | 309 flow_ = flow; |
310 } | 310 } |
311 | 311 |
312 void SyncSetupHandler::OnDidShowPage(const ListValue* args) { | |
313 DCHECK(web_ui_); | |
314 | |
315 ProfileSyncService* sync_service = | |
316 web_ui_->GetProfile()->GetProfileSyncService(); | |
317 if (!sync_service) | |
318 return; | |
319 | |
320 flow_ = sync_service->get_wizard().AttachSyncSetupHandler(this); | |
321 } | |
322 | |
323 void SyncSetupHandler::OnDidClosePage(const ListValue* args) { | 312 void SyncSetupHandler::OnDidClosePage(const ListValue* args) { |
324 if (flow_) { | 313 if (flow_) { |
325 flow_->OnDialogClosed(std::string()); | 314 flow_->OnDialogClosed(std::string()); |
326 flow_ = NULL; | 315 flow_ = NULL; |
327 } | 316 } |
328 } | 317 } |
329 | 318 |
330 void SyncSetupHandler::HandleSubmitAuth(const ListValue* args) { | 319 void SyncSetupHandler::HandleSubmitAuth(const ListValue* args) { |
331 std::string json; | 320 std::string json; |
332 if (!args->GetString(0, &json)) { | 321 if (!args->GetString(0, &json)) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 } | 379 } |
391 | 380 |
392 DCHECK(flow_); | 381 DCHECK(flow_); |
393 flow_->OnPassphraseEntry(passphrase); | 382 flow_->OnPassphraseEntry(passphrase); |
394 } | 383 } |
395 | 384 |
396 void SyncSetupHandler::HandlePassphraseCancel(const ListValue* args) { | 385 void SyncSetupHandler::HandlePassphraseCancel(const ListValue* args) { |
397 DCHECK(flow_); | 386 DCHECK(flow_); |
398 flow_->OnPassphraseCancel(); | 387 flow_->OnPassphraseCancel(); |
399 } | 388 } |
| 389 |
| 390 void SyncSetupHandler::HandleAttachHandler(const ListValue* args) { |
| 391 DCHECK(web_ui_); |
| 392 |
| 393 ProfileSyncService* sync_service = |
| 394 web_ui_->GetProfile()->GetProfileSyncService(); |
| 395 if (!sync_service) |
| 396 return; |
| 397 |
| 398 if (!flow_) |
| 399 flow_ = sync_service->get_wizard().AttachSyncSetupHandler(this); |
| 400 } |
| 401 |
OLD | NEW |