Chromium Code Reviews| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 void PermissionRequestCreatorApiary::CreatePermissionRequest( | 64 void PermissionRequestCreatorApiary::CreatePermissionRequest( |
| 65 const std::string& url_requested, | 65 const std::string& url_requested, |
| 66 const base::Closure& callback) { | 66 const base::Closure& callback) { |
| 67 url_requested_ = url_requested; | 67 url_requested_ = url_requested; |
| 68 callback_ = callback; | 68 callback_ = callback; |
| 69 StartFetching(); | 69 StartFetching(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void PermissionRequestCreatorApiary::StartFetching() { | 72 void PermissionRequestCreatorApiary::StartFetching() { |
| 73 OAuth2TokenService::ScopeSet scopes; | 73 OAuth2TokenService::ScopeSet scopes; |
| 74 scopes.insert(signin_wrapper_->GetSyncScopeToUse()); | 74 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 75 switches::kPermissionRequestApiScope)) { | |
|
Marc Treib
2014/08/14 11:23:31
nit: indent 4 more spaces
Bernhard Bauer
2014/08/14 12:17:06
Done.
| |
| 76 scopes.insert(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
| 77 switches::kPermissionRequestApiScope)); | |
| 78 } else { | |
| 79 scopes.insert(signin_wrapper_->GetSyncScopeToUse()); | |
| 80 } | |
| 75 access_token_request_ = oauth2_token_service_->StartRequest( | 81 access_token_request_ = oauth2_token_service_->StartRequest( |
| 76 signin_wrapper_->GetAccountIdToUse(), scopes, this); | 82 signin_wrapper_->GetAccountIdToUse(), scopes, this); |
| 77 } | 83 } |
| 78 | 84 |
| 79 void PermissionRequestCreatorApiary::OnGetTokenSuccess( | 85 void PermissionRequestCreatorApiary::OnGetTokenSuccess( |
| 80 const OAuth2TokenService::Request* request, | 86 const OAuth2TokenService::Request* request, |
| 81 const std::string& access_token, | 87 const std::string& access_token, |
| 82 const base::Time& expiration_time) { | 88 const base::Time& expiration_time) { |
| 83 DCHECK_EQ(access_token_request_.get(), request); | 89 DCHECK_EQ(access_token_request_.get(), request); |
| 84 access_token_ = access_token; | 90 access_token_ = access_token; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 void PermissionRequestCreatorApiary::DispatchNetworkError(int error_code) { | 166 void PermissionRequestCreatorApiary::DispatchNetworkError(int error_code) { |
| 161 DispatchGoogleServiceAuthError( | 167 DispatchGoogleServiceAuthError( |
| 162 GoogleServiceAuthError::FromConnectionError(error_code)); | 168 GoogleServiceAuthError::FromConnectionError(error_code)); |
| 163 } | 169 } |
| 164 | 170 |
| 165 void PermissionRequestCreatorApiary::DispatchGoogleServiceAuthError( | 171 void PermissionRequestCreatorApiary::DispatchGoogleServiceAuthError( |
| 166 const GoogleServiceAuthError& error) { | 172 const GoogleServiceAuthError& error) { |
| 167 callback_.Run(); | 173 callback_.Run(); |
| 168 callback_.Reset(); | 174 callback_.Reset(); |
| 169 } | 175 } |
| OLD | NEW |