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/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
6 | 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
7 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
9 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
10 #include "base/values.h" | 12 #include "base/values.h" |
11 #include "chrome/browser/google/google_util.h" | 13 #include "chrome/browser/google/google_util.h" |
12 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/sync/profile_sync_service.h" | 15 #include "chrome/browser/sync/profile_sync_service.h" |
14 #include "chrome/browser/sync/signin_manager.h" | 16 #include "chrome/browser/sync/signin_manager.h" |
15 #include "chrome/browser/sync/sync_setup_flow.h" | 17 #include "chrome/browser/sync/sync_setup_flow.h" |
16 #include "chrome/browser/sync/util/oauth.h" | 18 #include "chrome/browser/sync/util/oauth.h" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 319 |
318 void SyncSetupHandler::OnGetOAuthTokenSuccess(const std::string& oauth_token) { | 320 void SyncSetupHandler::OnGetOAuthTokenSuccess(const std::string& oauth_token) { |
319 flow_->OnUserSubmittedOAuth(oauth_token); | 321 flow_->OnUserSubmittedOAuth(oauth_token); |
320 } | 322 } |
321 | 323 |
322 void SyncSetupHandler::OnGetOAuthTokenFailure( | 324 void SyncSetupHandler::OnGetOAuthTokenFailure( |
323 const GoogleServiceAuthError& error) { | 325 const GoogleServiceAuthError& error) { |
324 CloseSyncSetup(); | 326 CloseSyncSetup(); |
325 } | 327 } |
326 | 328 |
327 | |
328 void SyncSetupHandler::RegisterMessages() { | 329 void SyncSetupHandler::RegisterMessages() { |
329 web_ui_->RegisterMessageCallback("SyncSetupDidClosePage", | 330 web_ui_->RegisterMessageCallback("SyncSetupDidClosePage", |
330 NewCallback(this, &SyncSetupHandler::OnDidClosePage)); | 331 base::Bind(&SyncSetupHandler::OnDidClosePage, |
| 332 base::Unretained(this))); |
331 web_ui_->RegisterMessageCallback("SyncSetupSubmitAuth", | 333 web_ui_->RegisterMessageCallback("SyncSetupSubmitAuth", |
332 NewCallback(this, &SyncSetupHandler::HandleSubmitAuth)); | 334 base::Bind(&SyncSetupHandler::HandleSubmitAuth, |
| 335 base::Unretained(this))); |
333 web_ui_->RegisterMessageCallback("SyncSetupConfigure", | 336 web_ui_->RegisterMessageCallback("SyncSetupConfigure", |
334 NewCallback(this, &SyncSetupHandler::HandleConfigure)); | 337 base::Bind(&SyncSetupHandler::HandleConfigure, |
| 338 base::Unretained(this))); |
335 web_ui_->RegisterMessageCallback("SyncSetupPassphrase", | 339 web_ui_->RegisterMessageCallback("SyncSetupPassphrase", |
336 NewCallback(this, &SyncSetupHandler::HandlePassphraseEntry)); | 340 base::Bind(&SyncSetupHandler::HandlePassphraseEntry, |
| 341 base::Unretained(this))); |
337 web_ui_->RegisterMessageCallback("SyncSetupPassphraseCancel", | 342 web_ui_->RegisterMessageCallback("SyncSetupPassphraseCancel", |
338 NewCallback(this, &SyncSetupHandler::HandlePassphraseCancel)); | 343 base::Bind(&SyncSetupHandler::HandlePassphraseCancel, |
| 344 base::Unretained(this))); |
339 web_ui_->RegisterMessageCallback("SyncSetupAttachHandler", | 345 web_ui_->RegisterMessageCallback("SyncSetupAttachHandler", |
340 NewCallback(this, &SyncSetupHandler::HandleAttachHandler)); | 346 base::Bind(&SyncSetupHandler::HandleAttachHandler, |
| 347 base::Unretained(this))); |
341 web_ui_->RegisterMessageCallback("SyncSetupShowErrorUI", | 348 web_ui_->RegisterMessageCallback("SyncSetupShowErrorUI", |
342 NewCallback(this, &SyncSetupHandler::HandleShowErrorUI)); | 349 base::Bind(&SyncSetupHandler::HandleShowErrorUI, |
| 350 base::Unretained(this))); |
343 web_ui_->RegisterMessageCallback("SyncSetupShowSetupUI", | 351 web_ui_->RegisterMessageCallback("SyncSetupShowSetupUI", |
344 NewCallback(this, &SyncSetupHandler::HandleShowSetupUI)); | 352 base::Bind(&SyncSetupHandler::HandleShowSetupUI, |
| 353 base::Unretained(this))); |
345 } | 354 } |
346 | 355 |
347 // Ideal(?) solution here would be to mimic the ClientLogin overlay. Since | 356 // Ideal(?) solution here would be to mimic the ClientLogin overlay. Since |
348 // this UI must render an external URL, that overlay cannot be used directly. | 357 // this UI must render an external URL, that overlay cannot be used directly. |
349 // The current implementation is functional, but fails asthetically. | 358 // The current implementation is functional, but fails asthetically. |
350 // TODO(rickcam): Bug 90711: Update UI for OAuth sign-in flow | 359 // TODO(rickcam): Bug 90711: Update UI for OAuth sign-in flow |
351 void SyncSetupHandler::ShowOAuthLogin() { | 360 void SyncSetupHandler::ShowOAuthLogin() { |
352 DCHECK(browser_sync::IsUsingOAuth()); | 361 DCHECK(browser_sync::IsUsingOAuth()); |
353 | 362 |
354 Profile* profile = Profile::FromWebUI(web_ui_); | 363 Profile* profile = Profile::FromWebUI(web_ui_); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 ShowSetupUI(); | 544 ShowSetupUI(); |
536 | 545 |
537 // The SyncSetupFlow will set itself as the |flow_|. | 546 // The SyncSetupFlow will set itself as the |flow_|. |
538 if (!service->get_wizard().AttachSyncSetupHandler(this)) { | 547 if (!service->get_wizard().AttachSyncSetupHandler(this)) { |
539 // If attach fails, a wizard is already activated and attached to a flow | 548 // If attach fails, a wizard is already activated and attached to a flow |
540 // handler. | 549 // handler. |
541 web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay"); | 550 web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay"); |
542 service->get_wizard().Focus(); | 551 service->get_wizard().Focus(); |
543 } | 552 } |
544 } | 553 } |
OLD | NEW |