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

Side by Side Diff: chrome/browser/google_apis/drive_api_service.cc

Issue 12924009: Use GData WAPI's third party app authorization operation for Drive API v2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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/google_apis/drive_api_service.h ('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 (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/google_apis/drive_api_service.h" 5 #include "chrome/browser/google_apis/drive_api_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"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 #include "base/task_runner_util.h" 12 #include "base/task_runner_util.h"
13 #include "base/threading/sequenced_worker_pool.h" 13 #include "base/threading/sequenced_worker_pool.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/google_apis/auth_service.h" 15 #include "chrome/browser/google_apis/auth_service.h"
16 #include "chrome/browser/google_apis/drive_api_operations.h" 16 #include "chrome/browser/google_apis/drive_api_operations.h"
17 #include "chrome/browser/google_apis/drive_api_parser.h" 17 #include "chrome/browser/google_apis/drive_api_parser.h"
18 #include "chrome/browser/google_apis/gdata_wapi_operations.h"
18 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 19 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
19 #include "chrome/browser/google_apis/operation_runner.h" 20 #include "chrome/browser/google_apis/operation_runner.h"
20 #include "chrome/browser/google_apis/time_util.h" 21 #include "chrome/browser/google_apis/time_util.h"
21 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 24
24 using content::BrowserThread; 25 using content::BrowserThread;
25 26
26 namespace google_apis { 27 namespace google_apis {
27 28
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 188
188 // The resource ID for the root directory for Drive API is defined in the spec: 189 // The resource ID for the root directory for Drive API is defined in the spec:
189 // https://developers.google.com/drive/folder 190 // https://developers.google.com/drive/folder
190 const char kDriveApiRootDirectoryResourceId[] = "root"; 191 const char kDriveApiRootDirectoryResourceId[] = "root";
191 192
192 } // namespace 193 } // namespace
193 194
194 DriveAPIService::DriveAPIService( 195 DriveAPIService::DriveAPIService(
195 net::URLRequestContextGetter* url_request_context_getter, 196 net::URLRequestContextGetter* url_request_context_getter,
196 const GURL& base_url, 197 const GURL& base_url,
198 const GURL& wapi_base_url,
197 const std::string& custom_user_agent) 199 const std::string& custom_user_agent)
198 : url_request_context_getter_(url_request_context_getter), 200 : url_request_context_getter_(url_request_context_getter),
199 profile_(NULL), 201 profile_(NULL),
200 runner_(NULL), 202 runner_(NULL),
201 url_generator_(base_url), 203 url_generator_(base_url),
204 wapi_url_generator_(wapi_base_url),
202 custom_user_agent_(custom_user_agent) { 205 custom_user_agent_(custom_user_agent) {
203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
204 } 207 }
205 208
206 DriveAPIService::~DriveAPIService() { 209 DriveAPIService::~DriveAPIService() {
207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 210 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
208 if (runner_.get()) { 211 if (runner_.get()) {
209 runner_->operation_registry()->RemoveObserver(this); 212 runner_->operation_registry()->RemoveObserver(this);
210 runner_->auth_service()->RemoveObserver(this); 213 runner_->auth_service()->RemoveObserver(this);
211 } 214 }
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 const UploadRangeCallback& callback) { 571 const UploadRangeCallback& callback) {
569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 572 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
570 DCHECK(!callback.is_null()); 573 DCHECK(!callback.is_null());
571 574
572 // TODO(hidehiko): Implement this. 575 // TODO(hidehiko): Implement this.
573 NOTREACHED(); 576 NOTREACHED();
574 } 577 }
575 578
576 void DriveAPIService::AuthorizeApp( 579 void DriveAPIService::AuthorizeApp(
577 const std::string& resource_id, 580 const std::string& resource_id,
578 const std::string& app_ids, 581 const std::string& app_id,
579 const AuthorizeAppCallback& callback) { 582 const AuthorizeAppCallback& callback) {
580 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 583 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
581 DCHECK(!callback.is_null()); 584 DCHECK(!callback.is_null());
582 585
583 // TODO(hidehiko): Unfortunately, there is no support of authorizing 586 // Unfortunately, there is no support of authorizing
584 // third party application on Drive API v2. 587 // third party application on Drive API v2.
585 // As a temporary work around, we'll use the GData WAPI's api here. 588 // As a temporary work around, we'll use the GData WAPI's api here.
586 NOTREACHED(); 589 // TODO(hidehiko): Get rid of this hack, and use the Drive API when it is
590 // supported.
591 runner_->StartOperationWithRetry(
592 new AuthorizeAppOperation(
593 operation_registry(),
594 url_request_context_getter_,
595 wapi_url_generator_,
596 callback,
597 resource_id,
598 app_id));
587 } 599 }
588 600
589 bool DriveAPIService::HasAccessToken() const { 601 bool DriveAPIService::HasAccessToken() const {
590 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 602 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
591 603
592 return runner_->auth_service()->HasAccessToken(); 604 return runner_->auth_service()->HasAccessToken();
593 } 605 }
594 606
595 bool DriveAPIService::HasRefreshToken() const { 607 bool DriveAPIService::HasRefreshToken() const {
596 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 608 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 27 matching lines...) Expand all
624 } 636 }
625 637
626 void DriveAPIService::OnProgressUpdate( 638 void DriveAPIService::OnProgressUpdate(
627 const OperationProgressStatusList& list) { 639 const OperationProgressStatusList& list) {
628 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 640 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
629 FOR_EACH_OBSERVER( 641 FOR_EACH_OBSERVER(
630 DriveServiceObserver, observers_, OnProgressUpdate(list)); 642 DriveServiceObserver, observers_, OnProgressUpdate(list));
631 } 643 }
632 644
633 } // namespace google_apis 645 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/drive_api_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698