OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signin/easy_unlock_toggle_flow.h" | 5 #include "chrome/browser/signin/easy_unlock_toggle_flow.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 | 82 |
83 EasyUnlockToggleFlow::ToggleApiCall::~ToggleApiCall() { | 83 EasyUnlockToggleFlow::ToggleApiCall::~ToggleApiCall() { |
84 } | 84 } |
85 | 85 |
86 GURL EasyUnlockToggleFlow::ToggleApiCall::CreateApiCallUrl() { | 86 GURL EasyUnlockToggleFlow::ToggleApiCall::CreateApiCallUrl() { |
87 return GURL(kEasyUnlockToggleUrl); | 87 return GURL(kEasyUnlockToggleUrl); |
88 } | 88 } |
89 | 89 |
90 std::string EasyUnlockToggleFlow::ToggleApiCall::CreateApiCallBody() { | 90 std::string EasyUnlockToggleFlow::ToggleApiCall::CreateApiCallBody() { |
91 const char kBodyFormat[] = "{\"enable\":%s,\"publicKey\":\"%s\"}"; | 91 const char kEnableBodyFormat[] = "{\"enable\": true,\"publicKey\":\"%s\"}"; |
92 return base::StringPrintf( | 92 const char kDisableBodyFormat[] = |
93 kBodyFormat, | 93 "{ \"enable\": false, \"applyToAll\": true }"; |
94 toggle_enable_ ? "true" : "false", | 94 |
95 phone_public_key_.c_str()); | 95 if (toggle_enable_) |
| 96 return base::StringPrintf(kEnableBodyFormat, phone_public_key_.c_str()); |
| 97 else |
| 98 return std::string(kDisableBodyFormat); |
96 } | 99 } |
97 | 100 |
98 std::string | 101 std::string |
99 EasyUnlockToggleFlow::ToggleApiCall::CreateApiCallBodyContentType() { | 102 EasyUnlockToggleFlow::ToggleApiCall::CreateApiCallBodyContentType() { |
100 return "application/json"; | 103 return "application/json"; |
101 } | 104 } |
102 | 105 |
103 void EasyUnlockToggleFlow::ToggleApiCall::ProcessApiCallSuccess( | 106 void EasyUnlockToggleFlow::ToggleApiCall::ProcessApiCallSuccess( |
104 const net::URLFetcher* source) { | 107 const net::URLFetcher* source) { |
105 flow_->ReportToggleApiCallResult(true); | 108 flow_->ReportToggleApiCallResult(true); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 182 } |
180 | 183 |
181 void EasyUnlockToggleFlow::OnIssueAdviceSuccess( | 184 void EasyUnlockToggleFlow::OnIssueAdviceSuccess( |
182 const IssueAdviceInfo& issue_advice) { | 185 const IssueAdviceInfo& issue_advice) { |
183 NOTREACHED(); | 186 NOTREACHED(); |
184 } | 187 } |
185 | 188 |
186 void EasyUnlockToggleFlow::ReportToggleApiCallResult(bool success) { | 189 void EasyUnlockToggleFlow::ReportToggleApiCallResult(bool success) { |
187 callback_.Run(success); | 190 callback_.Run(success); |
188 } | 191 } |
OLD | NEW |