| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/drive/gdata_wapi_service.h" | 5 #include "chrome/browser/drive/gdata_wapi_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 app_list = AppList::CreateFromAccountMetadata(*account_metadata); | 120 app_list = AppList::CreateFromAccountMetadata(*account_metadata); |
| 121 } | 121 } |
| 122 | 122 |
| 123 callback.Run(error, app_list.Pass()); | 123 callback.Run(error, app_list.Pass()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace | 126 } // namespace |
| 127 | 127 |
| 128 GDataWapiService::GDataWapiService( | 128 GDataWapiService::GDataWapiService( |
| 129 OAuth2TokenService* oauth2_token_service, | 129 OAuth2TokenService* oauth2_token_service, |
| 130 const std::string& account_id, |
| 130 net::URLRequestContextGetter* url_request_context_getter, | 131 net::URLRequestContextGetter* url_request_context_getter, |
| 131 base::TaskRunner* blocking_task_runner, | 132 base::TaskRunner* blocking_task_runner, |
| 132 const GURL& base_url, | 133 const GURL& base_url, |
| 133 const GURL& base_download_url, | 134 const GURL& base_download_url, |
| 134 const std::string& custom_user_agent) | 135 const std::string& custom_user_agent) |
| 135 : oauth2_token_service_(oauth2_token_service), | 136 : oauth2_token_service_(oauth2_token_service), |
| 137 account_id_(account_id), |
| 136 url_request_context_getter_(url_request_context_getter), | 138 url_request_context_getter_(url_request_context_getter), |
| 137 blocking_task_runner_(blocking_task_runner), | 139 blocking_task_runner_(blocking_task_runner), |
| 138 url_generator_(base_url, base_download_url), | 140 url_generator_(base_url, base_download_url), |
| 139 custom_user_agent_(custom_user_agent) { | 141 custom_user_agent_(custom_user_agent) { |
| 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 141 } | 143 } |
| 142 | 144 |
| 143 GDataWapiService::~GDataWapiService() { | 145 GDataWapiService::~GDataWapiService() { |
| 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 145 if (sender_.get()) | 147 if (sender_.get()) |
| 146 sender_->auth_service()->RemoveObserver(this); | 148 sender_->auth_service()->RemoveObserver(this); |
| 147 } | 149 } |
| 148 | 150 |
| 149 void GDataWapiService::Initialize() { | 151 void GDataWapiService::Initialize() { |
| 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 151 | 153 |
| 152 std::vector<std::string> scopes; | 154 std::vector<std::string> scopes; |
| 153 scopes.push_back(util::kDocsListScope); | 155 scopes.push_back(util::kDocsListScope); |
| 154 scopes.push_back(kSpreadsheetsScope); | 156 scopes.push_back(kSpreadsheetsScope); |
| 155 scopes.push_back(kUserContentScope); | 157 scopes.push_back(kUserContentScope); |
| 156 // Drive App scope is required for even WAPI v3 apps access. | 158 // Drive App scope is required for even WAPI v3 apps access. |
| 157 scopes.push_back(util::kDriveAppsScope); | 159 scopes.push_back(util::kDriveAppsScope); |
| 158 sender_.reset(new RequestSender( | 160 sender_.reset(new RequestSender( |
| 159 new AuthService( | 161 new AuthService(oauth2_token_service_, |
| 160 oauth2_token_service_, url_request_context_getter_, scopes), | 162 account_id_, |
| 163 url_request_context_getter_, |
| 164 scopes), |
| 161 url_request_context_getter_, | 165 url_request_context_getter_, |
| 162 blocking_task_runner_.get(), | 166 blocking_task_runner_.get(), |
| 163 custom_user_agent_)); | 167 custom_user_agent_)); |
| 164 | 168 |
| 165 sender_->auth_service()->AddObserver(this); | 169 sender_->auth_service()->AddObserver(this); |
| 166 } | 170 } |
| 167 | 171 |
| 168 void GDataWapiService::AddObserver(DriveServiceObserver* observer) { | 172 void GDataWapiService::AddObserver(DriveServiceObserver* observer) { |
| 169 observers_.AddObserver(observer); | 173 observers_.AddObserver(observer); |
| 170 } | 174 } |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 if (CanSendRequest()) { | 670 if (CanSendRequest()) { |
| 667 FOR_EACH_OBSERVER( | 671 FOR_EACH_OBSERVER( |
| 668 DriveServiceObserver, observers_, OnReadyToSendRequests()); | 672 DriveServiceObserver, observers_, OnReadyToSendRequests()); |
| 669 } else if (!HasRefreshToken()) { | 673 } else if (!HasRefreshToken()) { |
| 670 FOR_EACH_OBSERVER( | 674 FOR_EACH_OBSERVER( |
| 671 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); | 675 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); |
| 672 } | 676 } |
| 673 } | 677 } |
| 674 | 678 |
| 675 } // namespace drive | 679 } // namespace drive |
| OLD | NEW |