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

Side by Side Diff: chrome/browser/chromeos/gdata/operations_base.cc

Issue 10836125: Add GetChangelist operation for Drive V2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove SetURL() and specify url in the constructor. Created 8 years, 4 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/chromeos/gdata/mock_gdata_documents_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/chromeos/gdata/operations_base.h" 5 #include "chrome/browser/chromeos/gdata/operations_base.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 // OAuth scope for the documents API. 44 // OAuth scope for the documents API.
45 const char kDocsListScope[] = "https://docs.google.com/feeds/"; 45 const char kDocsListScope[] = "https://docs.google.com/feeds/";
46 const char kSpreadsheetsScope[] = "https://spreadsheets.google.com/feeds/"; 46 const char kSpreadsheetsScope[] = "https://spreadsheets.google.com/feeds/";
47 const char kUserContentScope[] = "https://docs.googleusercontent.com/"; 47 const char kUserContentScope[] = "https://docs.googleusercontent.com/";
48 48
49 // OAuth scope for the Contacts API. 49 // OAuth scope for the Contacts API.
50 const char kContactsScope[] = "https://www.google.com/m8/feeds/"; 50 const char kContactsScope[] = "https://www.google.com/m8/feeds/";
51 51
52 // OAuth scope for Drive API. 52 // OAuth scope for Drive API.
53 const char kDriveScope[] = "https://www.googleapis.com/auth/drive.file";
53 const char kDriveAppsScope[] = "https://www.googleapis.com/auth/drive.apps"; 54 const char kDriveAppsScope[] = "https://www.googleapis.com/auth/drive.apps";
55 const char kDriveAppsReadonlyScope[] =
56 "https://www.googleapis.com/auth/drive.apps.readonly";
54 57
55 // Parse JSON string to base::Value object. 58 // Parse JSON string to base::Value object.
56 void ParseJsonOnBlockingPool(const std::string& data, 59 void ParseJsonOnBlockingPool(const std::string& data,
57 scoped_ptr<base::Value>* value) { 60 scoped_ptr<base::Value>* value) {
58 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); 61 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
59 62
60 int error_code = -1; 63 int error_code = -1;
61 std::string error_message; 64 std::string error_message;
62 value->reset(base::JSONReader::ReadAndReturnError(data, 65 value->reset(base::JSONReader::ReadAndReturnError(data,
63 base::JSON_PARSE_RFC, 66 base::JSON_PARSE_RFC,
(...skipping 21 matching lines...) Expand all
85 const std::string& refresh_token) 88 const std::string& refresh_token)
86 : GDataOperationRegistry::Operation(registry), 89 : GDataOperationRegistry::Operation(registry),
87 refresh_token_(refresh_token), callback_(callback) { 90 refresh_token_(refresh_token), callback_(callback) {
88 } 91 }
89 92
90 AuthOperation::~AuthOperation() {} 93 AuthOperation::~AuthOperation() {}
91 94
92 void AuthOperation::Start() { 95 void AuthOperation::Start() {
93 DCHECK(!refresh_token_.empty()); 96 DCHECK(!refresh_token_.empty());
94 std::vector<std::string> scopes; 97 std::vector<std::string> scopes;
95 scopes.push_back(kDocsListScope); 98 if (gdata::util::IsDriveV2ApiEnabled()) {
96 scopes.push_back(kSpreadsheetsScope); 99 scopes.push_back(kDriveScope);
97 scopes.push_back(kUserContentScope); 100 scopes.push_back(kDriveAppsReadonlyScope);
98 scopes.push_back(kContactsScope); 101 } else {
99 // Drive App scope is required for even WAPI v3 apps access. 102 scopes.push_back(kDocsListScope);
100 scopes.push_back(kDriveAppsScope); 103 scopes.push_back(kSpreadsheetsScope);
104 scopes.push_back(kUserContentScope);
105 scopes.push_back(kContactsScope);
106 // Drive App scope is required for even WAPI v3 apps access.
107 scopes.push_back(kDriveAppsScope);
108 }
101 oauth2_access_token_fetcher_.reset(new OAuth2AccessTokenFetcher( 109 oauth2_access_token_fetcher_.reset(new OAuth2AccessTokenFetcher(
102 this, g_browser_process->system_request_context())); 110 this, g_browser_process->system_request_context()));
103 NotifyStart(); 111 NotifyStart();
104 oauth2_access_token_fetcher_->Start( 112 oauth2_access_token_fetcher_->Start(
105 GaiaUrls::GetInstance()->oauth2_chrome_client_id(), 113 GaiaUrls::GetInstance()->oauth2_chrome_client_id(),
106 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), 114 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(),
107 refresh_token_, 115 refresh_token_,
108 scopes); 116 scopes);
109 } 117 }
110 118
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } 441 }
434 442
435 void GetDataOperation::RunCallback(GDataErrorCode fetch_error_code, 443 void GetDataOperation::RunCallback(GDataErrorCode fetch_error_code,
436 scoped_ptr<base::Value> value) { 444 scoped_ptr<base::Value> value) {
437 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 445 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
438 if (!callback_.is_null()) 446 if (!callback_.is_null())
439 callback_.Run(fetch_error_code, value.Pass()); 447 callback_.Run(fetch_error_code, value.Pass());
440 } 448 }
441 449
442 } // namespace gdata 450 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/mock_gdata_documents_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698