summaryrefslogtreecommitdiffstats
path: root/google_apis/drive
diff options
context:
space:
mode:
Diffstat (limited to 'google_apis/drive')
-rw-r--r--google_apis/drive/drive_api_requests.cc20
-rw-r--r--google_apis/drive/drive_api_requests.h28
-rw-r--r--google_apis/drive/drive_api_url_generator.cc8
-rw-r--r--google_apis/drive/drive_api_url_generator.h3
-rw-r--r--google_apis/drive/drive_api_url_generator_unittest.cc7
5 files changed, 66 insertions, 0 deletions
diff --git a/google_apis/drive/drive_api_requests.cc b/google_apis/drive/drive_api_requests.cc
index f0960e6..79ef01a 100644
--- a/google_apis/drive/drive_api_requests.cc
+++ b/google_apis/drive/drive_api_requests.cc
@@ -505,6 +505,26 @@ GURL AppsListRequest::GetURLInternal() const {
return url_generator_.GetAppsListUrl();
}
+//============================== AppsDeleteRequest ===========================
+
+AppsDeleteRequest::AppsDeleteRequest(RequestSender* sender,
+ const DriveApiUrlGenerator& url_generator,
+ const EntryActionCallback& callback)
+ : EntryActionRequest(sender, callback),
+ url_generator_(url_generator) {
+ DCHECK(!callback.is_null());
+}
+
+AppsDeleteRequest::~AppsDeleteRequest() {}
+
+net::URLFetcher::RequestType AppsDeleteRequest::GetRequestType() const {
+ return net::URLFetcher::DELETE_REQUEST;
+}
+
+GURL AppsDeleteRequest::GetURL() const {
+ return url_generator_.GetAppsDeleteUrl(app_id_);
+}
+
//========================== ChildrenInsertRequest ============================
ChildrenInsertRequest::ChildrenInsertRequest(
diff --git a/google_apis/drive/drive_api_requests.h b/google_apis/drive/drive_api_requests.h
index 6f10aa6..eabfb62 100644
--- a/google_apis/drive/drive_api_requests.h
+++ b/google_apis/drive/drive_api_requests.h
@@ -504,6 +504,34 @@ class AppsListRequest : public DriveApiDataRequest {
DISALLOW_COPY_AND_ASSIGN(AppsListRequest);
};
+//============================= AppsDeleteRequest ==============================
+
+// This class performs the request for deleting a Drive app.
+// This request is mapped to
+// https://developers.google.com/drive/v2/reference/files/trash
+class AppsDeleteRequest : public EntryActionRequest {
+ public:
+ AppsDeleteRequest(RequestSender* sender,
+ const DriveApiUrlGenerator& url_generator,
+ const EntryActionCallback& callback);
+ virtual ~AppsDeleteRequest();
+
+ // Required parameter.
+ const std::string& app_id() const { return app_id_; }
+ void set_app_id(const std::string& app_id) { app_id_ = app_id; }
+
+ protected:
+ // Overridden from UrlFetchRequestBase.
+ virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE;
+ virtual GURL GetURL() const OVERRIDE;
+
+ private:
+ const DriveApiUrlGenerator url_generator_;
+ std::string app_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppsDeleteRequest);
+};
+
//========================== ChildrenInsertRequest ============================
// This class performs the request for inserting a resource to a directory.
diff --git a/google_apis/drive/drive_api_url_generator.cc b/google_apis/drive/drive_api_url_generator.cc
index c12b947..e9d89d2 100644
--- a/google_apis/drive/drive_api_url_generator.cc
+++ b/google_apis/drive/drive_api_url_generator.cc
@@ -17,6 +17,9 @@ namespace {
// Hard coded URLs for communication with a google drive server.
const char kDriveV2AboutUrl[] = "/drive/v2/about";
const char kDriveV2AppsUrl[] = "/drive/v2/apps";
+// apps.delete API is exposed through a special endpoint v2internal that
+// is accessible only by the official API key for Chrome.
+const char kDriveV2AppsDeleteUrlFormat[] = "/drive/v2internal/apps/%s";
const char kDriveV2ChangelistUrl[] = "/drive/v2/changes";
const char kDriveV2FilesUrl[] = "/drive/v2/files";
const char kDriveV2FileUrlPrefix[] = "/drive/v2/files/";
@@ -60,6 +63,11 @@ GURL DriveApiUrlGenerator::GetAppsListUrl() const {
return base_url_.Resolve(kDriveV2AppsUrl);
}
+GURL DriveApiUrlGenerator::GetAppsDeleteUrl(const std::string& app_id) const {
+ return base_url_.Resolve(base::StringPrintf(
+ kDriveV2AppsDeleteUrlFormat, net::EscapePath(app_id).c_str()));
+}
+
GURL DriveApiUrlGenerator::GetFilesGetUrl(const std::string& file_id) const {
return base_url_.Resolve(kDriveV2FileUrlPrefix + net::EscapePath(file_id));
}
diff --git a/google_apis/drive/drive_api_url_generator.h b/google_apis/drive/drive_api_url_generator.h
index cf93edd..44b64c7 100644
--- a/google_apis/drive/drive_api_url_generator.h
+++ b/google_apis/drive/drive_api_url_generator.h
@@ -32,6 +32,9 @@ class DriveApiUrlGenerator {
// Returns a URL to invoke "Apps: list" method.
GURL GetAppsListUrl() const;
+ // Returns a URL to uninstall an app with the give |app_id|.
+ GURL GetAppsDeleteUrl(const std::string& app_id) const;
+
// Returns a URL to fetch a file metadata.
GURL GetFilesGetUrl(const std::string& file_id) const;
diff --git a/google_apis/drive/drive_api_url_generator_unittest.cc b/google_apis/drive/drive_api_url_generator_unittest.cc
index 343b279..a7e0c9a 100644
--- a/google_apis/drive/drive_api_url_generator_unittest.cc
+++ b/google_apis/drive/drive_api_url_generator_unittest.cc
@@ -41,6 +41,13 @@ TEST_F(DriveApiUrlGeneratorTest, GetAppsListUrl) {
test_url_generator_.GetAppsListUrl().spec());
}
+TEST_F(DriveApiUrlGeneratorTest, GetAppsDeleteUrl) {
+ EXPECT_EQ("https://www.googleapis.com/drive/v2internal/apps/0ADK06pfg",
+ url_generator_.GetAppsDeleteUrl("0ADK06pfg").spec());
+ EXPECT_EQ("http://127.0.0.1:12345/drive/v2internal/apps/0ADK06pfg",
+ test_url_generator_.GetAppsDeleteUrl("0ADK06pfg").spec());
+}
+
TEST_F(DriveApiUrlGeneratorTest, GetFilesGetUrl) {
// |file_id| should be embedded into the url.
EXPECT_EQ("https://www.googleapis.com/drive/v2/files/0ADK06pfg",