| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 custom_user_agent_(custom_user_agent) { | 141 custom_user_agent_(custom_user_agent) { |
| 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 143 } | 143 } |
| 144 | 144 |
| 145 GDataWapiService::~GDataWapiService() { | 145 GDataWapiService::~GDataWapiService() { |
| 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 147 if (sender_.get()) | 147 if (sender_.get()) |
| 148 sender_->auth_service()->RemoveObserver(this); | 148 sender_->auth_service()->RemoveObserver(this); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void GDataWapiService::Initialize() { | 151 void GDataWapiService::Initialize(const std::string& account_id) { |
| 152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 153 | 153 |
| 154 std::vector<std::string> scopes; | 154 std::vector<std::string> scopes; |
| 155 scopes.push_back(util::kDocsListScope); | 155 scopes.push_back(util::kDocsListScope); |
| 156 scopes.push_back(kSpreadsheetsScope); | 156 scopes.push_back(kSpreadsheetsScope); |
| 157 scopes.push_back(kUserContentScope); | 157 scopes.push_back(kUserContentScope); |
| 158 // Drive App scope is required for even WAPI v3 apps access. | 158 // Drive App scope is required for even WAPI v3 apps access. |
| 159 scopes.push_back(util::kDriveAppsScope); | 159 scopes.push_back(util::kDriveAppsScope); |
| 160 sender_.reset(new RequestSender( | 160 sender_.reset(new RequestSender( |
| 161 new AuthService( | 161 new AuthService(oauth2_token_service_, |
| 162 oauth2_token_service_, url_request_context_getter_, scopes), | 162 account_id, |
| 163 url_request_context_getter_, |
| 164 scopes), |
| 163 url_request_context_getter_, | 165 url_request_context_getter_, |
| 164 blocking_task_runner_.get(), | 166 blocking_task_runner_.get(), |
| 165 custom_user_agent_)); | 167 custom_user_agent_)); |
| 166 | 168 |
| 167 sender_->auth_service()->AddObserver(this); | 169 sender_->auth_service()->AddObserver(this); |
| 168 } | 170 } |
| 169 | 171 |
| 170 void GDataWapiService::AddObserver(DriveServiceObserver* observer) { | 172 void GDataWapiService::AddObserver(DriveServiceObserver* observer) { |
| 171 observers_.AddObserver(observer); | 173 observers_.AddObserver(observer); |
| 172 } | 174 } |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 if (CanSendRequest()) { | 669 if (CanSendRequest()) { |
| 668 FOR_EACH_OBSERVER( | 670 FOR_EACH_OBSERVER( |
| 669 DriveServiceObserver, observers_, OnReadyToSendRequests()); | 671 DriveServiceObserver, observers_, OnReadyToSendRequests()); |
| 670 } else if (!HasRefreshToken()) { | 672 } else if (!HasRefreshToken()) { |
| 671 FOR_EACH_OBSERVER( | 673 FOR_EACH_OBSERVER( |
| 672 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); | 674 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); |
| 673 } | 675 } |
| 674 } | 676 } |
| 675 | 677 |
| 676 } // namespace drive | 678 } // namespace drive |
| OLD | NEW |