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

Side by Side Diff: chrome/browser/ui/webui/sync_setup_handler.cc

Issue 7554008: Removal of Profile from content part 6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Profile helper function, rebase Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/sessions_ui.cc ('k') | chrome/browser/ui/webui/tracing_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/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/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 NewCallback(this, &SyncSetupHandler::HandleShowErrorUI)); 294 NewCallback(this, &SyncSetupHandler::HandleShowErrorUI));
295 web_ui_->RegisterMessageCallback("SyncSetupShowSetupUI", 295 web_ui_->RegisterMessageCallback("SyncSetupShowSetupUI",
296 NewCallback(this, &SyncSetupHandler::HandleShowSetupUI)); 296 NewCallback(this, &SyncSetupHandler::HandleShowSetupUI));
297 } 297 }
298 298
299 // Ideal(?) solution here would be to mimic the ClientLogin overlay. Since 299 // Ideal(?) solution here would be to mimic the ClientLogin overlay. Since
300 // this UI must render an external URL, that overlay cannot be used directly. 300 // this UI must render an external URL, that overlay cannot be used directly.
301 // The current implementation is functional, but fails asthetically. 301 // The current implementation is functional, but fails asthetically.
302 // TODO(rickcam): Bug 90711: Update UI for OAuth sign-in flow 302 // TODO(rickcam): Bug 90711: Update UI for OAuth sign-in flow
303 void SyncSetupHandler::ShowOAuthLogin() { 303 void SyncSetupHandler::ShowOAuthLogin() {
304 web_ui_->GetProfile()->GetProfileSyncService()->signin()->StartOAuthSignIn(); 304 Profile* profile = Profile::FromWebUI(web_ui_);
305 profile->GetProfileSyncService()->signin()->StartOAuthSignIn();
305 } 306 }
306 307
307 void SyncSetupHandler::ShowGaiaLogin(const DictionaryValue& args) { 308 void SyncSetupHandler::ShowGaiaLogin(const DictionaryValue& args) {
308 StringValue page("login"); 309 StringValue page("login");
309 web_ui_->CallJavascriptFunction( 310 web_ui_->CallJavascriptFunction(
310 "SyncSetupOverlay.showSyncSetupPage", page, args); 311 "SyncSetupOverlay.showSyncSetupPage", page, args);
311 } 312 }
312 313
313 void SyncSetupHandler::ShowGaiaSuccessAndClose() { 314 void SyncSetupHandler::ShowGaiaSuccessAndClose() {
314 web_ui_->CallJavascriptFunction("SyncSetupOverlay.showSuccessAndClose"); 315 web_ui_->CallJavascriptFunction("SyncSetupOverlay.showSuccessAndClose");
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 flow_->OnPassphraseCancel(); 426 flow_->OnPassphraseCancel();
426 } 427 }
427 428
428 void SyncSetupHandler::HandleAttachHandler(const ListValue* args) { 429 void SyncSetupHandler::HandleAttachHandler(const ListValue* args) {
429 OpenSyncSetup(); 430 OpenSyncSetup();
430 } 431 }
431 432
432 void SyncSetupHandler::HandleShowErrorUI(const ListValue* args) { 433 void SyncSetupHandler::HandleShowErrorUI(const ListValue* args) {
433 DCHECK(!flow_); 434 DCHECK(!flow_);
434 435
435 ProfileSyncService* service = 436 Profile* profile = Profile::FromWebUI(web_ui_);
436 web_ui_->GetProfile()->GetProfileSyncService(); 437 ProfileSyncService* service = profile->GetProfileSyncService();
437 DCHECK(service); 438 DCHECK(service);
438 439
439 service->get_wizard().Step(SyncSetupWizard::NONFATAL_ERROR); 440 service->get_wizard().Step(SyncSetupWizard::NONFATAL_ERROR);
440 441
441 // Show the Sync Setup page. 442 // Show the Sync Setup page.
442 if (service->get_wizard().IsVisible()) { 443 if (service->get_wizard().IsVisible()) {
443 service->get_wizard().Focus(); 444 service->get_wizard().Focus();
444 } else { 445 } else {
445 StringValue page("syncSetup"); 446 StringValue page("syncSetup");
446 web_ui_->CallJavascriptFunction("OptionsPage.navigateToPage", page); 447 web_ui_->CallJavascriptFunction("OptionsPage.navigateToPage", page);
447 } 448 }
448 } 449 }
449 450
450 void SyncSetupHandler::HandleShowSetupUI(const ListValue* args) { 451 void SyncSetupHandler::HandleShowSetupUI(const ListValue* args) {
451 DCHECK(!flow_); 452 DCHECK(!flow_);
452 ShowSetupUI(); 453 ShowSetupUI();
453 } 454 }
454 455
455 void SyncSetupHandler::CloseSyncSetup() { 456 void SyncSetupHandler::CloseSyncSetup() {
456 if (flow_) { 457 if (flow_) {
457 flow_->OnDialogClosed(std::string()); 458 flow_->OnDialogClosed(std::string());
458 flow_ = NULL; 459 flow_ = NULL;
459 } 460 }
460 } 461 }
461 462
462 void SyncSetupHandler::OpenSyncSetup() { 463 void SyncSetupHandler::OpenSyncSetup() {
463 DCHECK(web_ui_); 464 DCHECK(web_ui_);
464 DCHECK(!flow_); 465 DCHECK(!flow_);
465 466
466 ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService(); 467 Profile* profile = Profile::FromWebUI(web_ui_);
468 ProfileSyncService* service = profile->GetProfileSyncService();
467 if (!service) { 469 if (!service) {
468 // If there's no sync service, the user tried to manually invoke a syncSetup 470 // If there's no sync service, the user tried to manually invoke a syncSetup
469 // URL, but sync features are disabled. We need to close the overlay for 471 // URL, but sync features are disabled. We need to close the overlay for
470 // this (rare) case. 472 // this (rare) case.
471 web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay"); 473 web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay");
472 return; 474 return;
473 } 475 }
474 476
475 // If the wizard is not visible, step into the appropriate UI state. 477 // If the wizard is not visible, step into the appropriate UI state.
476 if (!service->get_wizard().IsVisible()) 478 if (!service->get_wizard().IsVisible())
477 ShowSetupUI(); 479 ShowSetupUI();
478 480
479 // The SyncSetupFlow will set itself as the |flow_|. 481 // The SyncSetupFlow will set itself as the |flow_|.
480 if (!service->get_wizard().AttachSyncSetupHandler(this)) { 482 if (!service->get_wizard().AttachSyncSetupHandler(this)) {
481 // If attach fails, a wizard is already activated and attached to a flow 483 // If attach fails, a wizard is already activated and attached to a flow
482 // handler. 484 // handler.
483 web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay"); 485 web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay");
484 service->get_wizard().Focus(); 486 service->get_wizard().Focus();
485 } 487 }
486 } 488 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sessions_ui.cc ('k') | chrome/browser/ui/webui/tracing_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698