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

Side by Side Diff: chrome/browser/sync/sync_setup_flow.cc

Issue 6309002: Further tweaks to the passphrase UI to deal with passphrase entry.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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/sync/sync_setup_flow.h ('k') | chrome/browser/sync/sync_setup_wizard.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) 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/sync/sync_setup_flow.h" 5 #include "chrome/browser/sync/sync_setup_flow.h"
6 6
7 #include "app/gfx/font_util.h" 7 #include "app/gfx/font_util.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get()); 62 DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get());
63 if (!result->GetString("user", username) || 63 if (!result->GetString("user", username) ||
64 !result->GetString("pass", password) || 64 !result->GetString("pass", password) ||
65 !result->GetString("captcha", captcha) || 65 !result->GetString("captcha", captcha) ||
66 !result->GetString("access_code", access_code)) { 66 !result->GetString("access_code", access_code)) {
67 return false; 67 return false;
68 } 68 }
69 return true; 69 return true;
70 } 70 }
71 71
72 bool GetPassphrase(const std::string& json, std::string* passphrase, 72 bool GetPassphrase(const std::string& json, std::string* passphrase) {
73 std::string* mode) {
74 scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); 73 scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false));
75 if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) 74 if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY))
76 return false; 75 return false;
77 76
78 DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get()); 77 DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get());
79 return result->GetString("passphrase", passphrase) && 78 return result->GetString("passphrase", passphrase);
80 result->GetString("mode", mode);
81 } 79 }
82 80
83 bool GetFirstPassphrase(const std::string& json, 81 bool GetFirstPassphrase(const std::string& json,
84 std::string* option, 82 std::string* option,
85 std::string* passphrase) { 83 std::string* passphrase) {
86 scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); 84 scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false));
87 if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) 85 if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY))
88 return false; 86 return false;
89 87
90 DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get()); 88 DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get());
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 return; 203 return;
206 } 204 }
207 205
208 void FlowHandler::HandlePassphraseEntry(const ListValue* args) { 206 void FlowHandler::HandlePassphraseEntry(const ListValue* args) {
209 std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(args)); 207 std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(args));
210 208
211 if (json.empty()) 209 if (json.empty())
212 return; 210 return;
213 211
214 std::string passphrase; 212 std::string passphrase;
215 std::string mode; 213 if (!GetPassphrase(json, &passphrase)) {
216 if (!GetPassphrase(json, &passphrase, &mode)) {
217 // Couldn't understand what the page sent. Indicates a programming error. 214 // Couldn't understand what the page sent. Indicates a programming error.
218 NOTREACHED(); 215 NOTREACHED();
219 return; 216 return;
220 } 217 }
221 218
222 DCHECK(flow_); 219 DCHECK(flow_);
223 flow_->OnPassphraseEntry(passphrase, mode); 220 flow_->OnPassphraseEntry(passphrase);
224 } 221 }
225 222
226 void FlowHandler::HandleFirstPassphrase(const ListValue* args) { 223 void FlowHandler::HandleFirstPassphrase(const ListValue* args) {
227 std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(args)); 224 std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(args));
228 225
229 if (json.empty()) 226 if (json.empty())
230 return; 227 return;
231 228
232 std::string option; 229 std::string option;
233 std::string passphrase; 230 std::string passphrase;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 args->SetBoolean("editable_user", user.empty()); 470 args->SetBoolean("editable_user", user.empty());
474 } 471 }
475 472
476 args->SetString("captchaUrl", error.captcha().image_url.spec()); 473 args->SetString("captchaUrl", error.captcha().image_url.spec());
477 } 474 }
478 475
479 // static 476 // static
480 void SyncSetupFlow::GetArgsForEnterPassphrase( 477 void SyncSetupFlow::GetArgsForEnterPassphrase(
481 const ProfileSyncService* service, DictionaryValue* args) { 478 const ProfileSyncService* service, DictionaryValue* args) {
482 args->SetString("iframeToShow", "passphrase"); 479 args->SetString("iframeToShow", "passphrase");
483 if (service->IsUsingSecondaryPassphrase()) 480 args->SetBoolean("passphrase_creation_rejected",
484 args->SetString("mode", "enter"); 481 service->tried_creating_explicit_passphrase());
485 else 482 args->SetBoolean("passphrase_setting_rejected",
486 args->SetString("mode", "gaia"); 483 service->tried_setting_explicit_passphrase());
487 } 484 }
488 485
489 // static 486 // static
490 void SyncSetupFlow::GetArgsForConfigure(ProfileSyncService* service, 487 void SyncSetupFlow::GetArgsForConfigure(ProfileSyncService* service,
491 DictionaryValue* args) { 488 DictionaryValue* args) {
492 args->SetString("iframeToShow", "configure"); 489 args->SetString("iframeToShow", "configure");
493 490
494 // By default start on the data types tab. 491 // By default start on the data types tab.
495 args->SetString("initialTab", "data-type"); 492 args->SetString("initialTab", "data-type");
496 493
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 // Go to the "loading..." screen." 716 // Go to the "loading..." screen."
720 Advance(SyncSetupWizard::SETTING_UP); 717 Advance(SyncSetupWizard::SETTING_UP);
721 718
722 // If we are activating the passphrase, we need to have one supplied. 719 // If we are activating the passphrase, we need to have one supplied.
723 DCHECK(service_->IsUsingSecondaryPassphrase() || 720 DCHECK(service_->IsUsingSecondaryPassphrase() ||
724 !configuration.use_secondary_passphrase || 721 !configuration.use_secondary_passphrase ||
725 configuration.secondary_passphrase.length() > 0); 722 configuration.secondary_passphrase.length() > 0);
726 723
727 if (configuration.use_secondary_passphrase && 724 if (configuration.use_secondary_passphrase &&
728 !service_->IsUsingSecondaryPassphrase()) { 725 !service_->IsUsingSecondaryPassphrase()) {
729 service_->SetPassphrase(configuration.secondary_passphrase, true); 726 service_->SetPassphrase(configuration.secondary_passphrase, true, true);
730 } 727 }
731 728
732 service_->OnUserChoseDatatypes(configuration.sync_everything, 729 service_->OnUserChoseDatatypes(configuration.sync_everything,
733 configuration.data_types); 730 configuration.data_types);
734 } 731 }
735 732
736 void SyncSetupFlow::OnPassphraseEntry(const std::string& passphrase, 733 void SyncSetupFlow::OnPassphraseEntry(const std::string& passphrase) {
737 const std::string& mode) {
738 Advance(SyncSetupWizard::SETTING_UP); 734 Advance(SyncSetupWizard::SETTING_UP);
739 service_->SetPassphrase(passphrase, true); 735 service_->SetPassphrase(passphrase, true, false);
740 } 736 }
741 737
742 void SyncSetupFlow::OnFirstPassphraseEntry(const std::string& option, 738 void SyncSetupFlow::OnFirstPassphraseEntry(const std::string& option,
743 const std::string& passphrase) { 739 const std::string& passphrase) {
744 Advance(SyncSetupWizard::SETTING_UP); 740 Advance(SyncSetupWizard::SETTING_UP);
745 if (option == "explicit") { 741 if (option == "explicit") {
746 service_->SetPassphrase(passphrase, true); 742 service_->SetPassphrase(passphrase, true, true);
747 } else if (option == "nothanks") { 743 } else if (option == "nothanks") {
748 // User opted out of encrypted sync, need to turn off encrypted 744 // User opted out of encrypted sync, need to turn off encrypted
749 // data types. 745 // data types.
750 syncable::ModelTypeSet registered_types; 746 syncable::ModelTypeSet registered_types;
751 service_->GetRegisteredDataTypes(&registered_types); 747 service_->GetRegisteredDataTypes(&registered_types);
752 registered_types.erase(syncable::PASSWORDS); 748 registered_types.erase(syncable::PASSWORDS);
753 service_->OnUserChoseDatatypes(false, registered_types); 749 service_->OnUserChoseDatatypes(false, registered_types);
754 } else if (option == "google") { 750 } else if (option == "google") {
755 // Implicit passphrase already set up. 751 // Implicit passphrase already set up.
756 Advance(SyncSetupWizard::DONE); 752 Advance(SyncSetupWizard::DONE);
757 } 753 }
758 } 754 }
759 755
760 void SyncSetupFlow::OnGoToDashboard() { 756 void SyncSetupFlow::OnGoToDashboard() {
761 BrowserList::GetLastActive()->OpenPrivacyDashboardTabAndActivate(); 757 BrowserList::GetLastActive()->OpenPrivacyDashboardTabAndActivate();
762 } 758 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/sync_setup_flow.h ('k') | chrome/browser/sync/sync_setup_wizard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698