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

Side by Side Diff: chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc

Issue 298883012: Added GetURL, GetOAuthScope, GetExtraRequestHeaders into GCDBaseApiFlow::Delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/local_discovery/privet_confirm_api_flow_unittest.cc ('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 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/command_line.h" 10 #include "base/command_line.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 #endif // defined(ENABLE_FULL_PRINTING) 158 #endif // defined(ENABLE_FULL_PRINTING)
159 } 159 }
160 160
161 void LocalDiscoveryUIHandler::HandleStart(const base::ListValue* args) { 161 void LocalDiscoveryUIHandler::HandleStart(const base::ListValue* args) {
162 Profile* profile = Profile::FromWebUI(web_ui()); 162 Profile* profile = Profile::FromWebUI(web_ui());
163 163
164 // If privet_lister_ is already set, it is a mock used for tests or the result 164 // If privet_lister_ is already set, it is a mock used for tests or the result
165 // of a reload. 165 // of a reload.
166 if (!privet_lister_) { 166 if (!privet_lister_) {
167 service_discovery_client_ = ServiceDiscoverySharedClient::GetInstance(); 167 service_discovery_client_ = ServiceDiscoverySharedClient::GetInstance();
168 privet_lister_.reset(new PrivetDeviceListerImpl( 168 privet_lister_.reset(
169 service_discovery_client_.get(), this)); 169 new PrivetDeviceListerImpl(service_discovery_client_.get(), this));
170 privet_http_factory_ = 170 privet_http_factory_ =
171 PrivetHTTPAsynchronousFactory::CreateInstance( 171 PrivetHTTPAsynchronousFactory::CreateInstance(
172 service_discovery_client_.get(), profile->GetRequestContext()); 172 service_discovery_client_.get(), profile->GetRequestContext());
173 173
174 SigninManagerBase* signin_manager = 174 SigninManagerBase* signin_manager =
175 SigninManagerFactory::GetInstance()->GetForProfile(profile); 175 SigninManagerFactory::GetInstance()->GetForProfile(profile);
176 if (signin_manager) 176 if (signin_manager)
177 signin_manager->AddObserver(this); 177 signin_manager->AddObserver(this);
178 } 178 }
179 179
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 PrivetRegisterOperation* operation, 294 PrivetRegisterOperation* operation,
295 const std::string& token, 295 const std::string& token,
296 const GURL& url) { 296 const GURL& url) {
297 web_ui()->CallJavascriptFunction( 297 web_ui()->CallJavascriptFunction(
298 "local_discovery.onRegistrationConfirmedOnPrinter"); 298 "local_discovery.onRegistrationConfirmedOnPrinter");
299 if (device_descriptions_.count(current_http_client_->GetName()) == 0) { 299 if (device_descriptions_.count(current_http_client_->GetName()) == 0) {
300 SendRegisterError(); 300 SendRegisterError();
301 return; 301 return;
302 } 302 }
303 303
304 bool is_cloud_print =
305 device_descriptions_[current_http_client_->GetName()].type ==
306 kDeviceTypePrinter;
307
308 Profile* profile = Profile::FromWebUI(web_ui()); 304 Profile* profile = Profile::FromWebUI(web_ui());
309 305
310 ProfileOAuth2TokenService* token_service = 306 ProfileOAuth2TokenService* token_service =
311 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 307 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
312 308
313 if (!token_service) { 309 if (!token_service) {
314 SendRegisterError(); 310 SendRegisterError();
315 return; 311 return;
316 } 312 }
317 313
318 SigninManagerBase* signin_manager = 314 SigninManagerBase* signin_manager =
319 SigninManagerFactory::GetInstance()->GetForProfile(profile); 315 SigninManagerFactory::GetInstance()->GetForProfile(profile);
320 if (!signin_manager) { 316 if (!signin_manager) {
321 SendRegisterError(); 317 SendRegisterError();
322 return; 318 return;
323 } 319 }
324 320
325 confirm_api_call_flow_.reset(new PrivetConfirmApiCallFlow( 321 confirm_api_call_flow_.reset(new PrivetConfirmApiCallFlow(
326 profile->GetRequestContext(), 322 profile->GetRequestContext(),
327 token_service, 323 token_service,
328 signin_manager->GetAuthenticatedAccountId(), 324 signin_manager->GetAuthenticatedAccountId(),
329 is_cloud_print,
330 token, 325 token,
331 base::Bind(&LocalDiscoveryUIHandler::OnConfirmDone, 326 base::Bind(&LocalDiscoveryUIHandler::OnConfirmDone,
332 base::Unretained(this)))); 327 base::Unretained(this))));
333 confirm_api_call_flow_->Start(); 328 confirm_api_call_flow_->Start();
334 } 329 }
335 330
336 void LocalDiscoveryUIHandler::OnPrivetRegisterError( 331 void LocalDiscoveryUIHandler::OnPrivetRegisterError(
337 PrivetRegisterOperation* operation, 332 PrivetRegisterOperation* operation,
338 const std::string& action, 333 const std::string& action,
339 PrivetRegisterOperation::FailureReason reason, 334 PrivetRegisterOperation::FailureReason reason,
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 } 640 }
646 641
647 void LocalDiscoveryUIHandler::RefreshCloudPrintStatusFromService() { 642 void LocalDiscoveryUIHandler::RefreshCloudPrintStatusFromService() {
648 if (cloud_print_connector_ui_enabled_) 643 if (cloud_print_connector_ui_enabled_)
649 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> 644 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))->
650 RefreshStatusFromService(); 645 RefreshStatusFromService();
651 } 646 }
652 #endif // cloud print connector option stuff 647 #endif // cloud print connector option stuff
653 648
654 } // namespace local_discovery 649 } // namespace local_discovery
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/privet_confirm_api_flow_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698