summaryrefslogtreecommitdiffstats
path: root/chrome/browser/drive
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-05 02:12:46 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-05 02:12:46 +0000
commit63049bbbeeebdeaf7eced730f8b247d5c8e6928e (patch)
tree585b477fd56779dce255d103cadf4bf335396581 /chrome/browser/drive
parentf6d2cba2529f2e4d828bd0e516eec7ab8169fdd6 (diff)
downloadchromium_src-63049bbbeeebdeaf7eced730f8b247d5c8e6928e.zip
chromium_src-63049bbbeeebdeaf7eced730f8b247d5c8e6928e.tar.gz
chromium_src-63049bbbeeebdeaf7eced730f8b247d5c8e6928e.tar.bz2
Parse "removable" and "productId" fields from apps.list response.
BUG=334966 R=hashimoto@chromium.org Review URL: https://codereview.chromium.org/132333006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248831 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/drive')
-rw-r--r--chrome/browser/drive/drive_api_service.cc4
-rw-r--r--chrome/browser/drive/drive_api_util.cc1
-rw-r--r--chrome/browser/drive/drive_api_util_unittest.cc1
-rw-r--r--chrome/browser/drive/drive_app_registry.cc12
-rw-r--r--chrome/browser/drive/drive_app_registry.h12
-rw-r--r--chrome/browser/drive/drive_app_registry_unittest.cc16
6 files changed, 39 insertions, 7 deletions
diff --git a/chrome/browser/drive/drive_api_service.cc b/chrome/browser/drive/drive_api_service.cc
index cf57a46..d4dd0c0 100644
--- a/chrome/browser/drive/drive_api_service.cc
+++ b/chrome/browser/drive/drive_api_service.cc
@@ -533,7 +533,9 @@ CancelCallback DriveAPIService::GetAppList(const AppListCallback& callback) {
DCHECK(!callback.is_null());
return sender_->StartRequestWithRetry(
- new AppsListRequest(sender_.get(), url_generator_, callback));
+ new AppsListRequest(sender_.get(), url_generator_,
+ google_apis::IsGoogleChromeAPIKeyUsed(),
+ callback));
}
CancelCallback DriveAPIService::DownloadFile(
diff --git a/chrome/browser/drive/drive_api_util.cc b/chrome/browser/drive/drive_api_util.cc
index ef4d128..8a2569d 100644
--- a/chrome/browser/drive/drive_api_util.cc
+++ b/chrome/browser/drive/drive_api_util.cc
@@ -104,7 +104,6 @@ ConvertInstalledAppToAppResource(
resource->set_name(installed_app.app_name());
resource->set_object_type(installed_app.object_type());
resource->set_supports_create(installed_app.supports_create());
- resource->set_product_url(installed_app.GetProductUrl());
{
ScopedVector<std::string> primary_mimetypes(
diff --git a/chrome/browser/drive/drive_api_util_unittest.cc b/chrome/browser/drive/drive_api_util_unittest.cc
index 570f9e9..afb4a13 100644
--- a/chrome/browser/drive/drive_api_util_unittest.cc
+++ b/chrome/browser/drive/drive_api_util_unittest.cc
@@ -169,7 +169,6 @@ TEST(FileSystemUtilTest, ConvertAccountMetadataToAppList) {
EXPECT_EQ("name", app_resource.name());
EXPECT_EQ("object_type", app_resource.object_type());
EXPECT_TRUE(app_resource.supports_create());
- EXPECT_EQ("http://product/url", app_resource.product_url().spec());
const ScopedVector<std::string>& primary_mimetypes =
app_resource.primary_mimetypes();
ASSERT_EQ(1U, primary_mimetypes.size());
diff --git a/chrome/browser/drive/drive_app_registry.cc b/chrome/browser/drive/drive_app_registry.cc
index 5b31a77..ec23d70 100644
--- a/chrome/browser/drive/drive_app_registry.cc
+++ b/chrome/browser/drive/drive_app_registry.cc
@@ -56,15 +56,19 @@ DriveAppInfo::DriveAppInfo() {
DriveAppInfo::DriveAppInfo(
const std::string& app_id,
+ const std::string& product_id,
const google_apis::InstalledApp::IconList& app_icons,
const google_apis::InstalledApp::IconList& document_icons,
const std::string& app_name,
- const GURL& create_url)
+ const GURL& create_url,
+ bool is_removable)
: app_id(app_id),
+ product_id(product_id),
app_icons(app_icons),
document_icons(document_icons),
app_name(app_name),
- create_url(create_url) {
+ create_url(create_url),
+ is_removable(is_removable) {
}
DriveAppInfo::~DriveAppInfo() {
@@ -169,10 +173,12 @@ void DriveAppRegistry::UpdateFromAppList(const google_apis::AppList& app_list) {
}
all_apps_[id] = DriveAppInfo(app.application_id(),
+ app.product_id(),
app_icons,
document_icons,
app.name(),
- app.create_url());
+ app.create_url(),
+ app.is_removable());
// TODO(kinaba): consider taking primary/secondary distinction into account.
AddAppSelectorList(app.primary_mimetypes(), id, &mimetype_map_);
diff --git a/chrome/browser/drive/drive_app_registry.h b/chrome/browser/drive/drive_app_registry.h
index 26bf3c1..c86de92 100644
--- a/chrome/browser/drive/drive_app_registry.h
+++ b/chrome/browser/drive/drive_app_registry.h
@@ -31,14 +31,21 @@ class DriveServiceInterface;
struct DriveAppInfo {
DriveAppInfo();
DriveAppInfo(const std::string& app_id,
+ const std::string& product_id,
const google_apis::InstalledApp::IconList& app_icons,
const google_apis::InstalledApp::IconList& document_icons,
const std::string& app_name,
- const GURL& create_url);
+ const GURL& create_url,
+ bool is_removable);
~DriveAppInfo();
// Drive app id.
std::string app_id;
+ // Drive app's product id. This is different from app id that is used inside
+ // Drive. Product id is an id for the app in webstore; hence, it can be used
+ // for identifying the same app install as Chrome extension and as Drive app
+ // at the same time.
+ std::string product_id;
// Drive application icon URLs for this app, paired with their size (length of
// a side in pixels).
google_apis::InstalledApp::IconList app_icons;
@@ -50,6 +57,9 @@ struct DriveAppInfo {
// URL for opening a new file in the app. Empty if the app does not support
// new file creation.
GURL create_url;
+ // Returns if UninstallApp() is allowed for the app. Built-in apps have this
+ // field set false.
+ bool is_removable;
};
// Callback type for UninstallApp().
diff --git a/chrome/browser/drive/drive_app_registry_unittest.cc b/chrome/browser/drive/drive_app_registry_unittest.cc
index 6e04fd0..630720b 100644
--- a/chrome/browser/drive/drive_app_registry_unittest.cc
+++ b/chrome/browser/drive/drive_app_registry_unittest.cc
@@ -45,6 +45,22 @@ class DriveAppRegistryTest : public testing::Test {
scoped_ptr<DriveAppRegistry> apps_registry_;
};
+TEST_F(DriveAppRegistryTest, BasicParse) {
+ apps_registry_->Update();
+ base::RunLoop().RunUntilIdle();
+
+ std::vector<DriveAppInfo> apps;
+ apps_registry_->GetAppList(&apps);
+
+ ASSERT_EQ(2u, apps.size());
+ EXPECT_EQ("123456788192", apps[0].app_id);
+ EXPECT_EQ("Drive app 1", apps[0].app_name);
+ EXPECT_EQ("https://www.example.com/createForApp1",
+ apps[0].create_url.spec());
+ EXPECT_EQ("abcdefghabcdefghabcdefghabcdefgh", apps[0].product_id);
+ EXPECT_TRUE(apps[0].is_removable);
+}
+
TEST_F(DriveAppRegistryTest, LoadAndFindDriveApps) {
apps_registry_->Update();
base::RunLoop().RunUntilIdle();