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

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

Issue 7399015: Sync Promo: Add a way to collapse the sync promo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Promo: Add a way to collapse the sync promo Created 9 years, 5 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/sync_setup_handler.h ('k') | no next file » | 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/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/google/google_util.h" 10 #include "chrome/browser/google/google_util.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 { "cancelWarningHeader", IDS_SYNC_PASSPHRASE_CANCEL_WARNING_HEADER }, 257 { "cancelWarningHeader", IDS_SYNC_PASSPHRASE_CANCEL_WARNING_HEADER },
258 { "cancelWarning", IDS_SYNC_PASSPHRASE_CANCEL_WARNING }, 258 { "cancelWarning", IDS_SYNC_PASSPHRASE_CANCEL_WARNING },
259 { "yes", IDS_SYNC_PASSPHRASE_CANCEL_YES }, 259 { "yes", IDS_SYNC_PASSPHRASE_CANCEL_YES },
260 { "no", IDS_SYNC_PASSPHRASE_CANCEL_NO }, 260 { "no", IDS_SYNC_PASSPHRASE_CANCEL_NO },
261 { "sectionExplicitMessagePrefix", IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_PREFIX }, 261 { "sectionExplicitMessagePrefix", IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_PREFIX },
262 { "sectionExplicitMessagePostfix", 262 { "sectionExplicitMessagePostfix",
263 IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX }, 263 IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX },
264 { "encryptedDataTypesTitle", IDS_SYNC_ENCRYPTION_DATA_TYPES_TITLE }, 264 { "encryptedDataTypesTitle", IDS_SYNC_ENCRYPTION_DATA_TYPES_TITLE },
265 { "encryptSensitiveOption", IDS_SYNC_ENCRYPT_SENSITIVE_DATA }, 265 { "encryptSensitiveOption", IDS_SYNC_ENCRYPT_SENSITIVE_DATA },
266 { "encryptAllOption", IDS_SYNC_ENCRYPT_ALL_DATA }, 266 { "encryptAllOption", IDS_SYNC_ENCRYPT_ALL_DATA },
267 { "encryptAllOption", IDS_SYNC_ENCRYPT_ALL_DATA },
268 { "statusNotConnected", IDS_SYNC_STATUS_NOT_CONNECTED }
267 }; 269 };
268 270
269 RegisterStrings(localized_strings, resources, arraysize(resources)); 271 RegisterStrings(localized_strings, resources, arraysize(resources));
270 } 272 }
271 273
272 void SyncSetupHandler::Initialize() { 274 void SyncSetupHandler::Initialize() {
273 } 275 }
274 276
275 void SyncSetupHandler::RegisterMessages() { 277 void SyncSetupHandler::RegisterMessages() {
276 web_ui_->RegisterMessageCallback("SyncSetupDidClosePage", 278 web_ui_->RegisterMessageCallback("SyncSetupDidClosePage",
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 333
332 void SyncSetupHandler::SetFlow(SyncSetupFlow* flow) { 334 void SyncSetupHandler::SetFlow(SyncSetupFlow* flow) {
333 flow_ = flow; 335 flow_ = flow;
334 } 336 }
335 337
336 void SyncSetupHandler::Focus() { 338 void SyncSetupHandler::Focus() {
337 static_cast<RenderViewHostDelegate*>(web_ui_->tab_contents())->Activate(); 339 static_cast<RenderViewHostDelegate*>(web_ui_->tab_contents())->Activate();
338 } 340 }
339 341
340 void SyncSetupHandler::OnDidClosePage(const ListValue* args) { 342 void SyncSetupHandler::OnDidClosePage(const ListValue* args) {
341 if (flow_) { 343 CloseSyncSetup();
342 flow_->OnDialogClosed(std::string());
343 flow_ = NULL;
344 }
345 } 344 }
346 345
347 void SyncSetupHandler::HandleSubmitAuth(const ListValue* args) { 346 void SyncSetupHandler::HandleSubmitAuth(const ListValue* args) {
348 std::string json; 347 std::string json;
349 if (!args->GetString(0, &json)) { 348 if (!args->GetString(0, &json)) {
350 NOTREACHED() << "Could not read JSON argument"; 349 NOTREACHED() << "Could not read JSON argument";
351 return; 350 return;
352 } 351 }
353 352
354 if (json.empty()) 353 if (json.empty())
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 DCHECK(flow_); 408 DCHECK(flow_);
410 flow_->OnPassphraseEntry(passphrase); 409 flow_->OnPassphraseEntry(passphrase);
411 } 410 }
412 411
413 void SyncSetupHandler::HandlePassphraseCancel(const ListValue* args) { 412 void SyncSetupHandler::HandlePassphraseCancel(const ListValue* args) {
414 DCHECK(flow_); 413 DCHECK(flow_);
415 flow_->OnPassphraseCancel(); 414 flow_->OnPassphraseCancel();
416 } 415 }
417 416
418 void SyncSetupHandler::HandleAttachHandler(const ListValue* args) { 417 void SyncSetupHandler::HandleAttachHandler(const ListValue* args) {
418 OpenSyncSetup();
419 }
420
421 void SyncSetupHandler::HandleShowErrorUI(const ListValue* args) {
422 DCHECK(!flow_);
423
424 ProfileSyncService* service =
425 web_ui_->GetProfile()->GetProfileSyncService();
426 DCHECK(service);
427
428 service->get_wizard().Step(SyncSetupWizard::NONFATAL_ERROR);
429
430 // Show the Sync Setup page.
431 if (service->get_wizard().IsVisible()) {
432 service->get_wizard().Focus();
433 } else {
434 StringValue page("syncSetup");
435 web_ui_->CallJavascriptFunction("OptionsPage.navigateToPage", page);
436 }
437 }
438
439 void SyncSetupHandler::HandleShowSetupUI(const ListValue* args) {
440 DCHECK(!flow_);
441 ShowSetupUI();
442 }
443
444 void SyncSetupHandler::CloseSyncSetup() {
445 if (flow_) {
446 flow_->OnDialogClosed(std::string());
447 flow_ = NULL;
448 }
449 }
450
451 void SyncSetupHandler::OpenSyncSetup() {
419 DCHECK(web_ui_); 452 DCHECK(web_ui_);
420 DCHECK(!flow_); 453 DCHECK(!flow_);
421 454
422 ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService(); 455 ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService();
423 if (!service) { 456 if (!service) {
424 // If there's no sync service, the user tried to manually invoke a syncSetup 457 // If there's no sync service, the user tried to manually invoke a syncSetup
425 // URL, but sync features are disabled. We need to close the overlay for 458 // URL, but sync features are disabled. We need to close the overlay for
426 // this (rare) case. 459 // this (rare) case.
427 web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay"); 460 web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay");
428 return; 461 return;
429 } 462 }
430 463
431 // If the wizard is not visible, step into the appropriate UI state. 464 // If the wizard is not visible, step into the appropriate UI state.
432 if (!service->get_wizard().IsVisible()) 465 if (!service->get_wizard().IsVisible())
433 ShowSetupUI(); 466 ShowSetupUI();
434 467
435 // The SyncSetupFlow will set itself as the |flow_|. 468 // The SyncSetupFlow will set itself as the |flow_|.
436 if (!service->get_wizard().AttachSyncSetupHandler(this)) { 469 if (!service->get_wizard().AttachSyncSetupHandler(this)) {
437 // If attach fails, a wizard is already activated and attached to a flow 470 // If attach fails, a wizard is already activated and attached to a flow
438 // handler. 471 // handler.
439 web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay"); 472 web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay");
440 service->get_wizard().Focus(); 473 service->get_wizard().Focus();
441 } 474 }
442 } 475 }
443
444 void SyncSetupHandler::HandleShowErrorUI(const ListValue* args) {
445 DCHECK(!flow_);
446
447 ProfileSyncService* service =
448 web_ui_->GetProfile()->GetProfileSyncService();
449 DCHECK(service);
450
451 service->get_wizard().Step(SyncSetupWizard::NONFATAL_ERROR);
452
453 // Show the Sync Setup page.
454 if (service->get_wizard().IsVisible()) {
455 service->get_wizard().Focus();
456 } else {
457 StringValue page("syncSetup");
458 web_ui_->CallJavascriptFunction("OptionsPage.navigateToPage", page);
459 }
460 }
461
462 void SyncSetupHandler::HandleShowSetupUI(const ListValue* args) {
463 DCHECK(!flow_);
464 ShowSetupUI();
465 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_setup_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698