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

Unified Diff: chrome/browser/drive/drive_api_service.cc

Issue 140783006: drive: Support authorizing third-party Drive apps for opening files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/drive/drive_app_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/drive/drive_api_service.cc
diff --git a/chrome/browser/drive/drive_api_service.cc b/chrome/browser/drive/drive_api_service.cc
index 46f4e9fe90bc824243e7454dcaff1da2e521ba3a..05081706cb228ebafb6b9900cede5496ab890bae 100644
--- a/chrome/browser/drive/drive_api_service.cc
+++ b/chrome/browser/drive/drive_api_service.cc
@@ -21,6 +21,7 @@
#include "google_apis/drive/gdata_wapi_parser.h"
#include "google_apis/drive/gdata_wapi_requests.h"
#include "google_apis/drive/request_sender.h"
+#include "google_apis/google_api_keys.h"
#include "net/url_request/url_request_context_getter.h"
using content::BrowserThread;
@@ -784,12 +785,28 @@ CancelCallback DriveAPIService::AuthorizeApp(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
- FilesGetRequest* request = new FilesGetRequest(
- sender_.get(), url_generator_,
- base::Bind(&ExtractOpenUrlAndRun, app_id, callback));
- request->set_file_id(resource_id);
- request->set_fields(kFileResourceOpenWithLinksFields);
- return sender_->StartRequestWithRetry(request);
+ // Files.Authorize is only available for whitelisted clients like official
+ // Google Chrome. In other cases, we fall back to Files.Get that returns the
+ // same value as Files.Authorize without doing authorization. In that case,
+ // the app can open if it was authorized by other means (from whitelisted
+ // clients or drive.google.com web UI.)
+ if (google_apis::IsGoogleChromeAPIKeyUsed()) {
+ google_apis::drive::FilesAuthorizeRequest* request =
+ new google_apis::drive::FilesAuthorizeRequest(
+ sender_.get(), url_generator_,
+ base::Bind(&ExtractOpenUrlAndRun, app_id, callback));
+ request->set_app_id(app_id);
+ request->set_file_id(resource_id);
+ request->set_fields(kFileResourceOpenWithLinksFields);
+ return sender_->StartRequestWithRetry(request);
+ } else {
+ FilesGetRequest* request = new FilesGetRequest(
+ sender_.get(), url_generator_,
+ base::Bind(&ExtractOpenUrlAndRun, app_id, callback));
+ request->set_file_id(resource_id);
+ request->set_fields(kFileResourceOpenWithLinksFields);
+ return sender_->StartRequestWithRetry(request);
+ }
}
CancelCallback DriveAPIService::UninstallApp(
« no previous file with comments | « no previous file | chrome/browser/drive/drive_app_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698