| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/local_discovery/local_discovery_ui_handler.h" | 5 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" | 10 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 | 159 |
| 160 GURL automated_claim_url(base::StringPrintf( | 160 GURL automated_claim_url(base::StringPrintf( |
| 161 kPrivetAutomatedClaimURLFormat, | 161 kPrivetAutomatedClaimURLFormat, |
| 162 device_descriptions_[current_http_client_->GetName()].url.c_str(), | 162 device_descriptions_[current_http_client_->GetName()].url.c_str(), |
| 163 token.c_str())); | 163 token.c_str())); |
| 164 | 164 |
| 165 Profile* profile = Profile::FromWebUI(web_ui()); | 165 Profile* profile = Profile::FromWebUI(web_ui()); |
| 166 | 166 |
| 167 OAuth2TokenService* token_service = | 167 ProfileOAuth2TokenService* token_service = |
| 168 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 168 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 169 | 169 |
| 170 if (!token_service) { | 170 if (!token_service) { |
| 171 LogRegisterErrorToWeb("Could not get token service"); | 171 LogRegisterErrorToWeb("Could not get token service"); |
| 172 return; | 172 return; |
| 173 } | 173 } |
| 174 | 174 |
| 175 confirm_api_call_flow_.reset(new PrivetConfirmApiCallFlow( | 175 confirm_api_call_flow_.reset(new PrivetConfirmApiCallFlow( |
| 176 profile->GetRequestContext(), | 176 profile->GetRequestContext(), |
| 177 token_service, | 177 token_service, |
| 178 token_service->GetPrimaryAccountId(), |
| 178 automated_claim_url, | 179 automated_claim_url, |
| 179 base::Bind(&LocalDiscoveryUIHandler::OnConfirmDone, | 180 base::Bind(&LocalDiscoveryUIHandler::OnConfirmDone, |
| 180 base::Unretained(this)))); | 181 base::Unretained(this)))); |
| 181 | 182 |
| 182 confirm_api_call_flow_->Start(); | 183 confirm_api_call_flow_->Start(); |
| 183 } | 184 } |
| 184 | 185 |
| 185 void LocalDiscoveryUIHandler::OnPrivetRegisterError( | 186 void LocalDiscoveryUIHandler::OnPrivetRegisterError( |
| 186 PrivetRegisterOperation* operation, | 187 PrivetRegisterOperation* operation, |
| 187 const std::string& action, | 188 const std::string& action, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 const base::DictionaryValue* json_value) { | 271 const base::DictionaryValue* json_value) { |
| 271 if (http_code != net::HTTP_OK || !json_value) { | 272 if (http_code != net::HTTP_OK || !json_value) { |
| 272 LogInfoErrorToWeb(base::StringPrintf("HTTP error %d", http_code)); | 273 LogInfoErrorToWeb(base::StringPrintf("HTTP error %d", http_code)); |
| 273 return; | 274 return; |
| 274 } | 275 } |
| 275 | 276 |
| 276 web_ui()->CallJavascriptFunction("local_discovery.renderInfo", *json_value); | 277 web_ui()->CallJavascriptFunction("local_discovery.renderInfo", *json_value); |
| 277 } | 278 } |
| 278 | 279 |
| 279 } // namespace local_discovery | 280 } // namespace local_discovery |
| OLD | NEW |