Commit 2385272b authored by kochi@chromium.org's avatar kochi@chromium.org

Add Drive API specific operations.

Future CLs will use these operations.

BUG=chromium:127728
TEST=none
TBR=ben@chromium.org

Review URL: https://chromiumcodereview.appspot.com/10821065

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148727 0039d316-1c4b-4281-b951-d872f2087c98
parent 542f8ce7
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/gdata/drive_api_operations.h"
namespace {
const char kDriveV2AboutURL[] = "https://www.googleapis.com/drive/v2/about";
const char kDriveV2ApplistURL[] = "https://www.googleapis.com/drive/v2/apps";
} // namespace
// TODO(kochi): Rename to namespace drive. http://crbug.com/136371
namespace gdata {
//============================== GetAboutOperation =============================
GetAboutOperation::GetAboutOperation(
GDataOperationRegistry* registry,
Profile* profile,
const GetDataCallback& callback)
: GetDataOperation(registry, profile, callback) {}
GetAboutOperation::~GetAboutOperation() {}
GURL GetAboutOperation::GetURL() const {
return GURL(kDriveV2AboutURL);
}
//============================== GetApplistOperation ===========================
GetApplistOperation::GetApplistOperation(
GDataOperationRegistry* registry,
Profile* profile,
const GetDataCallback& callback)
: GetDataOperation(registry, profile, callback) {}
GetApplistOperation::~GetApplistOperation() {}
GURL GetApplistOperation::GetURL() const {
return GURL(kDriveV2ApplistURL);
}
} // namespace gdata
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_OPERATIONS_H_
#define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_OPERATIONS_H_
#include <string>
#include <vector>
#include "chrome/browser/chromeos/gdata/operations_base.h"
// TODO(kochi): Rename to namespace drive. http://crbug.com/136371
namespace gdata {
//============================== GetAboutOperation =============================
// This class performs the operation for fetching About data.
class GetAboutOperation : public GetDataOperation {
public:
GetAboutOperation(GDataOperationRegistry* registry,
Profile* profile,
const GetDataCallback& callback);
virtual ~GetAboutOperation();
protected:
// Overridden from GetDataOperation.
virtual GURL GetURL() const OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(GetAboutOperation);
};
//============================= GetApplistOperation ============================
// This class performs the operation for fetching Applist.
class GetApplistOperation : public GetDataOperation {
public:
GetApplistOperation(GDataOperationRegistry* registry,
Profile* profile,
const GetDataCallback& callback);
virtual ~GetApplistOperation();
protected:
// Overridden from GetDataOperation.
virtual GURL GetURL() const OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(GetApplistOperation);
};
} // namespace gdata
#endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_OPERATIONS_H_
......@@ -8,8 +8,10 @@
#include "base/bind.h"
#include "base/message_loop_proxy.h"
#include "chrome/browser/chromeos/gdata/drive_api_operations.h"
#include "chrome/browser/chromeos/gdata/gdata_operation_runner.h"
#include "chrome/browser/chromeos/gdata/gdata_operations.h"
#include "chrome/browser/chromeos/gdata/gdata_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/net/url_util.h"
#include "content/public/browser/browser_thread.h"
......@@ -133,6 +135,22 @@ void DocumentsService::GetAccountMetadata(const GetDataCallback& callback) {
runner_->StartOperationWithRetry(operation);
}
void DocumentsService::GetAboutResource(const GetDataCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
GetAboutOperation* operation =
new GetAboutOperation(operation_registry(), profile_, callback);
runner_->StartOperationWithRetry(operation);
}
void DocumentsService::GetApplicationList(const GetDataCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
GetApplistOperation* operation =
new GetApplistOperation(operation_registry(), profile_, callback);
runner_->StartOperationWithRetry(operation);
}
void DocumentsService::DownloadDocument(
const FilePath& virtual_path,
const FilePath& local_cache_path,
......
......@@ -103,6 +103,14 @@ class DocumentsServiceInterface {
// calling thread.
virtual void GetAccountMetadata(const GetDataCallback& callback) = 0;
// Gets the About resource from the server for the current account.
// Upon completion, invokes |callback| with results on the calling thread.
// (For Drive V2 API only)
virtual void GetAboutResource(const GetDataCallback& callback) = 0;
// Gets the application list (For Drive V2 API only).
virtual void GetApplicationList(const GetDataCallback& callback) = 0;
// Deletes a document identified by its 'self' |url| and |etag|.
// Upon completion, invokes |callback| with results on the calling thread.
virtual void DeleteDocument(const GURL& document_url,
......@@ -215,6 +223,8 @@ class DocumentsService : public DocumentsServiceInterface {
const GetDataCallback& callback) OVERRIDE;
virtual void GetAccountMetadata(const GetDataCallback& callback) OVERRIDE;
virtual void GetAboutResource(const GetDataCallback& callback) OVERRIDE;
virtual void GetApplicationList(const GetDataCallback& callback) OVERRIDE;
virtual void DeleteDocument(const GURL& document_url,
const EntryActionCallback& callback) OVERRIDE;
virtual void DownloadDocument(
......
......@@ -37,6 +37,8 @@ class MockDocumentsService : public DocumentsServiceInterface {
MOCK_METHOD2(GetDocumentEntry, void(const std::string& resource_id,
const GetDataCallback& callback));
MOCK_METHOD1(GetAccountMetadata, void(const GetDataCallback& callback));
MOCK_METHOD1(GetAboutResource, void(const GetDataCallback& callback));
MOCK_METHOD1(GetApplicationList, void(const GetDataCallback& callback));
MOCK_METHOD2(DeleteDocument, void(const GURL& document_url,
const EntryActionCallback& callback));
MOCK_METHOD5(DownloadDocument, void(const FilePath& virtual_path,
......
......@@ -10,6 +10,7 @@
#include "base/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/gdata/gdata_util.h"
#include "chrome/common/net/gaia/gaia_urls.h"
#include "chrome/common/net/gaia/google_service_auth_error.h"
#include "chrome/common/net/gaia/oauth2_access_token_fetcher.h"
......@@ -45,6 +46,9 @@ const char kDocsListScope[] = "https://docs.google.com/feeds/";
const char kSpreadsheetsScope[] = "https://spreadsheets.google.com/feeds/";
const char kUserContentScope[] = "https://docs.googleusercontent.com/";
// OAuth scope for Drive API.
const char kDriveAppsScope[] = "https://www.googleapis.com/auth/drive.apps";
} // namespace
namespace gdata {
......@@ -67,6 +71,8 @@ void AuthOperation::Start() {
scopes.push_back(kDocsListScope);
scopes.push_back(kSpreadsheetsScope);
scopes.push_back(kUserContentScope);
if (gdata::util::IsDriveV2ApiEnabled())
scopes.push_back(kDriveAppsScope);
oauth2_access_token_fetcher_.reset(new OAuth2AccessTokenFetcher(
this, g_browser_process->system_request_context()));
NotifyStart();
......
......@@ -536,6 +536,8 @@
'browser/chromeos/external_metrics.h',
'browser/chromeos/external_protocol_dialog.cc',
'browser/chromeos/external_protocol_dialog.h',
'browser/chromeos/gdata/drive_api_operations.cc',
'browser/chromeos/gdata/drive_api_operations.h',
'browser/chromeos/gdata/drive_api_parser.cc',
'browser/chromeos/gdata/drive_api_parser.h',
'browser/chromeos/gdata/drive_task_executor.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment