diff options
author | calamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-30 07:23:27 +0000 |
---|---|---|
committer | calamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-30 07:23:27 +0000 |
commit | f8bbf6bb912e0408db87846d678dc3e49fdfafbb (patch) | |
tree | 005f8ebe9e32a2c262ff83e2d20fccdcdc71cb0b | |
parent | 7ddfe7e8b52738e4f52030a9c030376d50c99a82 (diff) | |
download | chromium_src-f8bbf6bb912e0408db87846d678dc3e49fdfafbb.zip chromium_src-f8bbf6bb912e0408db87846d678dc3e49fdfafbb.tar.gz chromium_src-f8bbf6bb912e0408db87846d678dc3e49fdfafbb.tar.bz2 |
Remove unused members from WebApplicationInfo.
Many of the members from WebApplicationInfo were in place to support
crx-less hosted apps. Since crx-less apps have been removed, we can
clean up references to them and repurpose convert_web_app.cc to be
solely for generating bookmark apps.
Review URL: https://codereview.chromium.org/142993002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247870 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/convert_web_app.cc | 38 | ||||
-rw-r--r-- | chrome/browser/extensions/convert_web_app.h | 1 | ||||
-rw-r--r-- | chrome/browser/extensions/convert_web_app_unittest.cc | 25 | ||||
-rw-r--r-- | chrome/browser/extensions/tab_helper.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/webui/ntp/app_launcher_handler.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/webui/ntp/app_launcher_handler.h | 1 | ||||
-rw-r--r-- | chrome/common/extensions/extension_messages.h | 3 | ||||
-rw-r--r-- | chrome/common/web_application_info.cc | 3 | ||||
-rw-r--r-- | chrome/common/web_application_info.h | 26 |
9 files changed, 14 insertions, 87 deletions
diff --git a/chrome/browser/extensions/convert_web_app.cc b/chrome/browser/extensions/convert_web_app.cc index 99a322b..cb4a490 100644 --- a/chrome/browser/extensions/convert_web_app.cc +++ b/chrome/browser/extensions/convert_web_app.cc @@ -47,12 +47,11 @@ const char kIconsDirName[] = "icons"; // its unique identity, and we need one of those. A web app's unique identity // is its manifest URL, so we hash that to create a public key. There will be // no corresponding private key, which means that these extensions cannot be -// auto-updated using ExtensionUpdater. But Chrome does notice updates to the -// manifest and regenerates these extensions. -std::string GenerateKey(const GURL& manifest_url) { +// auto-updated using ExtensionUpdater. +std::string GenerateKey(const GURL& app_url) { char raw[crypto::kSHA256Length] = {0}; std::string key; - crypto::SHA256HashString(manifest_url.spec().c_str(), raw, + crypto::SHA256HashString(app_url.spec().c_str(), raw, crypto::kSHA256Length); base::Base64Encode(std::string(raw, crypto::kSHA256Length), &key); return key; @@ -103,22 +102,12 @@ scoped_refptr<Extension> ConvertWebAppToExtension( // Create the manifest scoped_ptr<base::DictionaryValue> root(new base::DictionaryValue); - if (!web_app.is_bookmark_app) - root->SetString(keys::kPublicKey, GenerateKey(web_app.manifest_url)); - else - root->SetString(keys::kPublicKey, GenerateKey(web_app.app_url)); - - if (web_app.is_offline_enabled) - root->SetBoolean(keys::kOfflineEnabled, true); - + root->SetString(keys::kPublicKey, GenerateKey(web_app.app_url)); root->SetString(keys::kName, base::UTF16ToUTF8(web_app.title)); root->SetString(keys::kVersion, ConvertTimeToExtensionVersion(create_time)); root->SetString(keys::kDescription, base::UTF16ToUTF8(web_app.description)); root->SetString(keys::kLaunchWebURL, web_app.app_url.spec()); - if (!web_app.launch_container.empty()) - root->SetString(keys::kLaunchContainer, web_app.launch_container); - // Add the icons. base::DictionaryValue* icons = new base::DictionaryValue(); root->Set(keys::kIcons, icons); @@ -129,20 +118,6 @@ scoped_refptr<Extension> ConvertWebAppToExtension( icons->SetString(size, icon_path); } - // Add the permissions. - base::ListValue* permissions = new base::ListValue(); - root->Set(keys::kPermissions, permissions); - for (size_t i = 0; i < web_app.permissions.size(); ++i) { - permissions->Append(new base::StringValue(web_app.permissions[i])); - } - - // Add the URLs. - base::ListValue* urls = new base::ListValue(); - root->Set(keys::kWebURLs, urls); - for (size_t i = 0; i < web_app.urls.size(); ++i) { - urls->Append(new base::StringValue(web_app.urls[i].spec())); - } - // Write the manifest. base::FilePath manifest_path = temp_dir.path().Append(kManifestFilename); JSONFileValueSerializer serializer(manifest_path); @@ -182,14 +157,11 @@ scoped_refptr<Extension> ConvertWebAppToExtension( // Finally, create the extension object to represent the unpacked directory. std::string error; - int extension_flags = Extension::NO_FLAGS; - if (web_app.is_bookmark_app) - extension_flags |= Extension::FROM_BOOKMARK; scoped_refptr<Extension> extension = Extension::Create( temp_dir.path(), Manifest::INTERNAL, *root, - extension_flags, + Extension::FROM_BOOKMARK, &error); if (!extension.get()) { LOG(ERROR) << error; diff --git a/chrome/browser/extensions/convert_web_app.h b/chrome/browser/extensions/convert_web_app.h index 77c03d5..7c9551a 100644 --- a/chrome/browser/extensions/convert_web_app.h +++ b/chrome/browser/extensions/convert_web_app.h @@ -34,6 +34,7 @@ std::string ConvertTimeToExtensionVersion(const base::Time& time); // unpacked in the system temp dir. Returns a valid extension that the caller // should take ownership on success, or NULL and |error| on failure. // +// NOTE: The app created is always marked as a bookmark app. // NOTE: This function does file IO and should not be called on the UI thread. // NOTE: The caller takes ownership of the directory at extension->path() on the // returned object. diff --git a/chrome/browser/extensions/convert_web_app_unittest.cc b/chrome/browser/extensions/convert_web_app_unittest.cc index fcf8f9f..28649bc 100644 --- a/chrome/browser/extensions/convert_web_app_unittest.cc +++ b/chrome/browser/extensions/convert_web_app_unittest.cc @@ -98,14 +98,10 @@ TEST(ExtensionFromWebApp, Basic) { ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); WebApplicationInfo web_app; - web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json"); web_app.title = base::ASCIIToUTF16("Gearpad"); web_app.description = base::ASCIIToUTF16("The best text editor in the universe!"); web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); - web_app.permissions.push_back("geolocation"); - web_app.permissions.push_back("notifications"); - web_app.urls.push_back(GURL("http://aaronboodman.com/gearpad/")); const int sizes[] = {16, 48, 128}; for (size_t i = 0; i < arraysize(sizes); ++i) { @@ -126,19 +122,15 @@ TEST(ExtensionFromWebApp, Basic) { EXPECT_TRUE(extension->is_hosted_app()); EXPECT_FALSE(extension->is_legacy_packaged_app()); - EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", + EXPECT_EQ("zVvdNZy3Mp7CFU8JVSyXNlDuHdVLbP7fDO3TGVzj/0w=", extension->public_key()); - EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); + EXPECT_EQ("oplhagaaipaimkjlbekcdjkffijdockj", extension->id()); EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); EXPECT_EQ(base::UTF16ToUTF8(web_app.title), extension->name()); EXPECT_EQ(base::UTF16ToUTF8(web_app.description), extension->description()); EXPECT_EQ(web_app.app_url, AppLaunchInfo::GetFullLaunchURL(extension.get())); - EXPECT_EQ(2u, extension->GetActivePermissions()->apis().size()); - EXPECT_TRUE(extension->HasAPIPermission("geolocation")); - EXPECT_TRUE(extension->HasAPIPermission("notifications")); - ASSERT_EQ(1u, extension->web_extent().patterns().size()); - EXPECT_EQ("http://aaronboodman.com/gearpad/*", - extension->web_extent().patterns().begin()->GetAsString()); + EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size()); + ASSERT_EQ(0u, extension->web_extent().patterns().size()); EXPECT_EQ(web_app.icons.size(), IconsInfo::GetIcons(extension.get()).map().size()); @@ -160,7 +152,6 @@ TEST(ExtensionFromWebApp, Minimal) { ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); WebApplicationInfo web_app; - web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json"); web_app.title = base::ASCIIToUTF16("Gearpad"); web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); @@ -176,18 +167,16 @@ TEST(ExtensionFromWebApp, Minimal) { EXPECT_TRUE(extension->is_hosted_app()); EXPECT_FALSE(extension->is_legacy_packaged_app()); - EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", + EXPECT_EQ("zVvdNZy3Mp7CFU8JVSyXNlDuHdVLbP7fDO3TGVzj/0w=", extension->public_key()); - EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); + EXPECT_EQ("oplhagaaipaimkjlbekcdjkffijdockj", extension->id()); EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); EXPECT_EQ(base::UTF16ToUTF8(web_app.title), extension->name()); EXPECT_EQ("", extension->description()); EXPECT_EQ(web_app.app_url, AppLaunchInfo::GetFullLaunchURL(extension.get())); EXPECT_EQ(0u, IconsInfo::GetIcons(extension.get()).map().size()); EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size()); - ASSERT_EQ(1u, extension->web_extent().patterns().size()); - EXPECT_EQ("*://aaronboodman.com/*", - extension->web_extent().patterns().begin()->GetAsString()); + ASSERT_EQ(0u, extension->web_extent().patterns().size()); } } // namespace extensions diff --git a/chrome/browser/extensions/tab_helper.cc b/chrome/browser/extensions/tab_helper.cc index 6ff8642..ffe9606 100644 --- a/chrome/browser/extensions/tab_helper.cc +++ b/chrome/browser/extensions/tab_helper.cc @@ -422,8 +422,6 @@ void TabHelper::FinishCreateHostedApp( if (install_info.title.empty()) install_info.title = base::UTF8ToUTF16(install_info.app_url.spec()); - install_info.is_bookmark_app = true; - // Add the downloaded icons. Extensions only allow certain icon sizes. First // populate icons that match the allowed sizes exactly and then downscale // remaining icons to the closest allowed size that doesn't yet have an icon. diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc index a5fed58..02a49e0 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc @@ -703,7 +703,6 @@ void AppLauncherHandler::HandleGenerateAppForLink(const base::ListValue* args) { } scoped_ptr<AppInstallInfo> install_info(new AppInstallInfo()); - install_info->is_bookmark_app = true; install_info->title = title; install_info->app_url = launch_url; install_info->page_ordinal = page_ordinal; @@ -735,7 +734,6 @@ void AppLauncherHandler::OnFaviconForApp( scoped_ptr<AppInstallInfo> install_info, const chrome::FaviconImageResult& image_result) { scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); - web_app->is_bookmark_app = install_info->is_bookmark_app; web_app->title = install_info->title; web_app->app_url = install_info->app_url; diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.h b/chrome/browser/ui/webui/ntp/app_launcher_handler.h index a3547bb..e0903e3 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.h +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.h @@ -111,7 +111,6 @@ class AppLauncherHandler : public content::WebUIMessageHandler, AppInstallInfo(); ~AppInstallInfo(); - bool is_bookmark_app; base::string16 title; GURL app_url; syncer::StringOrdinal page_ordinal; diff --git a/chrome/common/extensions/extension_messages.h b/chrome/common/extensions/extension_messages.h index 7ca82c7..6437493 100644 --- a/chrome/common/extensions/extension_messages.h +++ b/chrome/common/extensions/extension_messages.h @@ -165,9 +165,6 @@ IPC_STRUCT_TRAITS_BEGIN(WebApplicationInfo) IPC_STRUCT_TRAITS_MEMBER(description) IPC_STRUCT_TRAITS_MEMBER(app_url) IPC_STRUCT_TRAITS_MEMBER(icons) - IPC_STRUCT_TRAITS_MEMBER(permissions) - IPC_STRUCT_TRAITS_MEMBER(launch_container) - IPC_STRUCT_TRAITS_MEMBER(is_offline_enabled) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(extensions::DraggableRegion) diff --git a/chrome/common/web_application_info.cc b/chrome/common/web_application_info.cc index a2a3e9b..c1cff5a 100644 --- a/chrome/common/web_application_info.cc +++ b/chrome/common/web_application_info.cc @@ -10,8 +10,7 @@ WebApplicationInfo::IconInfo::IconInfo() : width(0), height(0) { WebApplicationInfo::IconInfo::~IconInfo() { } -WebApplicationInfo::WebApplicationInfo() - : is_bookmark_app(false), is_offline_enabled(false) { +WebApplicationInfo::WebApplicationInfo() { } WebApplicationInfo::~WebApplicationInfo() { diff --git a/chrome/common/web_application_info.h b/chrome/common/web_application_info.h index 08b9c84..1c5c103 100644 --- a/chrome/common/web_application_info.h +++ b/chrome/common/web_application_info.h @@ -28,18 +28,6 @@ struct WebApplicationInfo { WebApplicationInfo(); ~WebApplicationInfo(); - // URL to a manifest that defines the application. If specified, all other - // attributes are derived from this manifest, and the manifest is the unique - // ID of the application. - GURL manifest_url; - - // Setting indicating this application is artificially constructed. If set, - // the application was created from bookmark-style data (title, url, possibly - // icon), and not from an official manifest file. In that case, the app_url - // can be checked for the later creation of an official manifest instead of - // reloading the manifest_url. - bool is_bookmark_app; - // Title of the application. base::string16 title; @@ -51,20 +39,6 @@ struct WebApplicationInfo { // Set of available icons. std::vector<IconInfo> icons; - - // The permissions the app requests. Only supported with manifest-based apps. - std::vector<std::string> permissions; - - // Set of URLs that comprise the app. Only supported with manifest-based apps. - // All these must be of the same origin as manifest_url. - std::vector<GURL> urls; - - // The type of launch container to use with the app. Currently supported - // values are 'tab' and 'panel'. Only supported with manifest-based apps. - std::string launch_container; - - // This indicates if the app is functional in offline mode or not. - bool is_offline_enabled; }; #endif // CHROME_COMMON_WEB_APPLICATION_INFO_H_ |