| 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/supervised_user/permission_request_creator_apiary.h" |    5 #include "chrome/browser/supervised_user/permission_request_creator_apiary.h" | 
|    6  |    6  | 
|    7 #include "base/callback.h" |    7 #include "base/callback.h" | 
|    8 #include "base/command_line.h" |    8 #include "base/command_line.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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   98 } |   98 } | 
|   99  |   99  | 
|  100 void PermissionRequestCreatorApiary::CreatePermissionRequest( |  100 void PermissionRequestCreatorApiary::CreatePermissionRequest( | 
|  101     const GURL& url_requested, |  101     const GURL& url_requested, | 
|  102     const SuccessCallback& callback) { |  102     const SuccessCallback& callback) { | 
|  103   requests_.push_back(new Request(url_requested, callback, url_fetcher_id_)); |  103   requests_.push_back(new Request(url_requested, callback, url_fetcher_id_)); | 
|  104   StartFetching(requests_.back()); |  104   StartFetching(requests_.back()); | 
|  105 } |  105 } | 
|  106  |  106  | 
|  107 GURL PermissionRequestCreatorApiary::GetApiUrl() const { |  107 GURL PermissionRequestCreatorApiary::GetApiUrl() const { | 
|  108   if (CommandLine::ForCurrentProcess()->HasSwitch( |  108   if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 
|  109           switches::kPermissionRequestApiUrl)) { |  109           switches::kPermissionRequestApiUrl)) { | 
|  110     GURL url(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |  110     GURL url(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 
|  111                  switches::kPermissionRequestApiUrl)); |  111         switches::kPermissionRequestApiUrl)); | 
|  112     LOG_IF(WARNING, !url.is_valid()) |  112     LOG_IF(WARNING, !url.is_valid()) | 
|  113         << "Got invalid URL for " << switches::kPermissionRequestApiUrl; |  113         << "Got invalid URL for " << switches::kPermissionRequestApiUrl; | 
|  114     return url; |  114     return url; | 
|  115   } else { |  115   } else { | 
|  116     return GURL(kApiUrl); |  116     return GURL(kApiUrl); | 
|  117   } |  117   } | 
|  118 } |  118 } | 
|  119  |  119  | 
|  120 std::string PermissionRequestCreatorApiary::GetApiScope() const { |  120 std::string PermissionRequestCreatorApiary::GetApiScope() const { | 
|  121   if (CommandLine::ForCurrentProcess()->HasSwitch( |  121   if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 
|  122           switches::kPermissionRequestApiScope)) { |  122           switches::kPermissionRequestApiScope)) { | 
|  123     return CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |  123     return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 
|  124         switches::kPermissionRequestApiScope); |  124         switches::kPermissionRequestApiScope); | 
|  125   } else { |  125   } else { | 
|  126     return kApiScope; |  126     return kApiScope; | 
|  127   } |  127   } | 
|  128 } |  128 } | 
|  129  |  129  | 
|  130 void PermissionRequestCreatorApiary::StartFetching(Request* request) { |  130 void PermissionRequestCreatorApiary::StartFetching(Request* request) { | 
|  131   OAuth2TokenService::ScopeSet scopes; |  131   OAuth2TokenService::ScopeSet scopes; | 
|  132   scopes.insert(GetApiScope()); |  132   scopes.insert(GetApiScope()); | 
|  133   request->access_token_request = oauth2_token_service_->StartRequest( |  133   request->access_token_request = oauth2_token_service_->StartRequest( | 
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  248       it, GoogleServiceAuthError::FromConnectionError(error_code)); |  248       it, GoogleServiceAuthError::FromConnectionError(error_code)); | 
|  249 } |  249 } | 
|  250  |  250  | 
|  251 void PermissionRequestCreatorApiary::DispatchGoogleServiceAuthError( |  251 void PermissionRequestCreatorApiary::DispatchGoogleServiceAuthError( | 
|  252     RequestIterator it, |  252     RequestIterator it, | 
|  253     const GoogleServiceAuthError& error) { |  253     const GoogleServiceAuthError& error) { | 
|  254   VLOG(1) << "GoogleServiceAuthError: " << error.ToString(); |  254   VLOG(1) << "GoogleServiceAuthError: " << error.ToString(); | 
|  255   (*it)->callback.Run(false); |  255   (*it)->callback.Run(false); | 
|  256   requests_.erase(it); |  256   requests_.erase(it); | 
|  257 } |  257 } | 
| OLD | NEW |