| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 133 } |
| 134 | 134 |
| 135 void LocalDiscoveryUIHandler::HandleCancelRegistration( | 135 void LocalDiscoveryUIHandler::HandleCancelRegistration( |
| 136 const base::ListValue* args) { | 136 const base::ListValue* args) { |
| 137 ResetCurrentRegistration(); | 137 ResetCurrentRegistration(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void LocalDiscoveryUIHandler::HandleRequestPrinterList( | 140 void LocalDiscoveryUIHandler::HandleRequestPrinterList( |
| 141 const base::ListValue* args) { | 141 const base::ListValue* args) { |
| 142 Profile* profile = Profile::FromWebUI(web_ui()); | 142 Profile* profile = Profile::FromWebUI(web_ui()); |
| 143 OAuth2TokenService* token_service = | 143 ProfileOAuth2TokenService* token_service = |
| 144 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 144 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 145 | 145 |
| 146 cloud_print_printer_list_.reset(new CloudPrintPrinterList( | 146 cloud_print_printer_list_.reset(new CloudPrintPrinterList( |
| 147 profile->GetRequestContext(), | 147 profile->GetRequestContext(), |
| 148 GetCloudPrintBaseUrl(), | 148 GetCloudPrintBaseUrl(), |
| 149 token_service, | 149 token_service, |
| 150 token_service->GetPrimaryAccountId(), |
| 150 this)); | 151 this)); |
| 151 cloud_print_printer_list_->Start(); | 152 cloud_print_printer_list_->Start(); |
| 152 } | 153 } |
| 153 | 154 |
| 154 void LocalDiscoveryUIHandler::HandleOpenCloudPrintURL( | 155 void LocalDiscoveryUIHandler::HandleOpenCloudPrintURL( |
| 155 const base::ListValue* args) { | 156 const base::ListValue* args) { |
| 156 std::string url; | 157 std::string url; |
| 157 bool rv = args->GetString(0, &url); | 158 bool rv = args->GetString(0, &url); |
| 158 DCHECK(rv); | 159 DCHECK(rv); |
| 159 | 160 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 198 |
| 198 std::string base_url = GetCloudPrintBaseUrl(); | 199 std::string base_url = GetCloudPrintBaseUrl(); |
| 199 | 200 |
| 200 GURL automated_claim_url(base::StringPrintf( | 201 GURL automated_claim_url(base::StringPrintf( |
| 201 kPrivetAutomatedClaimURLFormat, | 202 kPrivetAutomatedClaimURLFormat, |
| 202 base_url.c_str(), | 203 base_url.c_str(), |
| 203 token.c_str())); | 204 token.c_str())); |
| 204 | 205 |
| 205 Profile* profile = Profile::FromWebUI(web_ui()); | 206 Profile* profile = Profile::FromWebUI(web_ui()); |
| 206 | 207 |
| 207 OAuth2TokenService* token_service = | 208 ProfileOAuth2TokenService* token_service = |
| 208 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 209 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 209 | 210 |
| 210 if (!token_service) { | 211 if (!token_service) { |
| 211 SendRegisterError(); | 212 SendRegisterError(); |
| 212 return; | 213 return; |
| 213 } | 214 } |
| 214 | 215 |
| 215 confirm_api_call_flow_.reset(new PrivetConfirmApiCallFlow( | 216 confirm_api_call_flow_.reset(new PrivetConfirmApiCallFlow( |
| 216 profile->GetRequestContext(), | 217 profile->GetRequestContext(), |
| 217 token_service, | 218 token_service, |
| 219 token_service->GetPrimaryAccountId(), |
| 218 automated_claim_url, | 220 automated_claim_url, |
| 219 base::Bind(&LocalDiscoveryUIHandler::OnConfirmDone, | 221 base::Bind(&LocalDiscoveryUIHandler::OnConfirmDone, |
| 220 base::Unretained(this)))); | 222 base::Unretained(this)))); |
| 221 confirm_api_call_flow_->Start(); | 223 confirm_api_call_flow_->Start(); |
| 222 } | 224 } |
| 223 | 225 |
| 224 void LocalDiscoveryUIHandler::OnPrivetRegisterError( | 226 void LocalDiscoveryUIHandler::OnPrivetRegisterError( |
| 225 PrivetRegisterOperation* operation, | 227 PrivetRegisterOperation* operation, |
| 226 const std::string& action, | 228 const std::string& action, |
| 227 PrivetRegisterOperation::FailureReason reason, | 229 PrivetRegisterOperation::FailureReason reason, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); | 403 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 402 | 404 |
| 403 return_value->SetString("id", description.id); | 405 return_value->SetString("id", description.id); |
| 404 return_value->SetString("display_name", description.display_name); | 406 return_value->SetString("display_name", description.display_name); |
| 405 return_value->SetString("description", description.description); | 407 return_value->SetString("description", description.description); |
| 406 | 408 |
| 407 return return_value.Pass(); | 409 return return_value.Pass(); |
| 408 } | 410 } |
| 409 | 411 |
| 410 } // namespace local_discovery | 412 } // namespace local_discovery |
| OLD | NEW |