Commit f8bbf6bb authored by calamity@chromium.org's avatar calamity@chromium.org

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
parent 7ddfe7e8
...@@ -47,12 +47,11 @@ const char kIconsDirName[] = "icons"; ...@@ -47,12 +47,11 @@ const char kIconsDirName[] = "icons";
// its unique identity, and we need one of those. A web app's unique identity // 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 // 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 // no corresponding private key, which means that these extensions cannot be
// auto-updated using ExtensionUpdater. But Chrome does notice updates to the // auto-updated using ExtensionUpdater.
// manifest and regenerates these extensions. std::string GenerateKey(const GURL& app_url) {
std::string GenerateKey(const GURL& manifest_url) {
char raw[crypto::kSHA256Length] = {0}; char raw[crypto::kSHA256Length] = {0};
std::string key; std::string key;
crypto::SHA256HashString(manifest_url.spec().c_str(), raw, crypto::SHA256HashString(app_url.spec().c_str(), raw,
crypto::kSHA256Length); crypto::kSHA256Length);
base::Base64Encode(std::string(raw, crypto::kSHA256Length), &key); base::Base64Encode(std::string(raw, crypto::kSHA256Length), &key);
return key; return key;
...@@ -103,22 +102,12 @@ scoped_refptr<Extension> ConvertWebAppToExtension( ...@@ -103,22 +102,12 @@ scoped_refptr<Extension> ConvertWebAppToExtension(
// Create the manifest // Create the manifest
scoped_ptr<base::DictionaryValue> root(new base::DictionaryValue); scoped_ptr<base::DictionaryValue> root(new base::DictionaryValue);
if (!web_app.is_bookmark_app) root->SetString(keys::kPublicKey, GenerateKey(web_app.app_url));
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::kName, base::UTF16ToUTF8(web_app.title)); root->SetString(keys::kName, base::UTF16ToUTF8(web_app.title));
root->SetString(keys::kVersion, ConvertTimeToExtensionVersion(create_time)); root->SetString(keys::kVersion, ConvertTimeToExtensionVersion(create_time));
root->SetString(keys::kDescription, base::UTF16ToUTF8(web_app.description)); root->SetString(keys::kDescription, base::UTF16ToUTF8(web_app.description));
root->SetString(keys::kLaunchWebURL, web_app.app_url.spec()); 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. // Add the icons.
base::DictionaryValue* icons = new base::DictionaryValue(); base::DictionaryValue* icons = new base::DictionaryValue();
root->Set(keys::kIcons, icons); root->Set(keys::kIcons, icons);
...@@ -129,20 +118,6 @@ scoped_refptr<Extension> ConvertWebAppToExtension( ...@@ -129,20 +118,6 @@ scoped_refptr<Extension> ConvertWebAppToExtension(
icons->SetString(size, icon_path); 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. // Write the manifest.
base::FilePath manifest_path = temp_dir.path().Append(kManifestFilename); base::FilePath manifest_path = temp_dir.path().Append(kManifestFilename);
JSONFileValueSerializer serializer(manifest_path); JSONFileValueSerializer serializer(manifest_path);
...@@ -182,14 +157,11 @@ scoped_refptr<Extension> ConvertWebAppToExtension( ...@@ -182,14 +157,11 @@ scoped_refptr<Extension> ConvertWebAppToExtension(
// Finally, create the extension object to represent the unpacked directory. // Finally, create the extension object to represent the unpacked directory.
std::string error; 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( scoped_refptr<Extension> extension = Extension::Create(
temp_dir.path(), temp_dir.path(),
Manifest::INTERNAL, Manifest::INTERNAL,
*root, *root,
extension_flags, Extension::FROM_BOOKMARK,
&error); &error);
if (!extension.get()) { if (!extension.get()) {
LOG(ERROR) << error; LOG(ERROR) << error;
......
...@@ -34,6 +34,7 @@ std::string ConvertTimeToExtensionVersion(const base::Time& time); ...@@ -34,6 +34,7 @@ std::string ConvertTimeToExtensionVersion(const base::Time& time);
// unpacked in the system temp dir. Returns a valid extension that the caller // unpacked in the system temp dir. Returns a valid extension that the caller
// should take ownership on success, or NULL and |error| on failure. // 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: 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 // NOTE: The caller takes ownership of the directory at extension->path() on the
// returned object. // returned object.
......
...@@ -98,14 +98,10 @@ TEST(ExtensionFromWebApp, Basic) { ...@@ -98,14 +98,10 @@ TEST(ExtensionFromWebApp, Basic) {
ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); ASSERT_TRUE(extensions_dir.CreateUniqueTempDir());
WebApplicationInfo web_app; WebApplicationInfo web_app;
web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json");
web_app.title = base::ASCIIToUTF16("Gearpad"); web_app.title = base::ASCIIToUTF16("Gearpad");
web_app.description = web_app.description =
base::ASCIIToUTF16("The best text editor in the universe!"); base::ASCIIToUTF16("The best text editor in the universe!");
web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); 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}; const int sizes[] = {16, 48, 128};
for (size_t i = 0; i < arraysize(sizes); ++i) { for (size_t i = 0; i < arraysize(sizes); ++i) {
...@@ -126,19 +122,15 @@ TEST(ExtensionFromWebApp, Basic) { ...@@ -126,19 +122,15 @@ TEST(ExtensionFromWebApp, Basic) {
EXPECT_TRUE(extension->is_hosted_app()); EXPECT_TRUE(extension->is_hosted_app());
EXPECT_FALSE(extension->is_legacy_packaged_app()); EXPECT_FALSE(extension->is_legacy_packaged_app());
EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", EXPECT_EQ("zVvdNZy3Mp7CFU8JVSyXNlDuHdVLbP7fDO3TGVzj/0w=",
extension->public_key()); extension->public_key());
EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); EXPECT_EQ("oplhagaaipaimkjlbekcdjkffijdockj", extension->id());
EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); EXPECT_EQ("1978.12.11.0", extension->version()->GetString());
EXPECT_EQ(base::UTF16ToUTF8(web_app.title), extension->name()); EXPECT_EQ(base::UTF16ToUTF8(web_app.title), extension->name());
EXPECT_EQ(base::UTF16ToUTF8(web_app.description), extension->description()); EXPECT_EQ(base::UTF16ToUTF8(web_app.description), extension->description());
EXPECT_EQ(web_app.app_url, AppLaunchInfo::GetFullLaunchURL(extension.get())); EXPECT_EQ(web_app.app_url, AppLaunchInfo::GetFullLaunchURL(extension.get()));
EXPECT_EQ(2u, extension->GetActivePermissions()->apis().size()); EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size());
EXPECT_TRUE(extension->HasAPIPermission("geolocation")); ASSERT_EQ(0u, extension->web_extent().patterns().size());
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(web_app.icons.size(), EXPECT_EQ(web_app.icons.size(),
IconsInfo::GetIcons(extension.get()).map().size()); IconsInfo::GetIcons(extension.get()).map().size());
...@@ -160,7 +152,6 @@ TEST(ExtensionFromWebApp, Minimal) { ...@@ -160,7 +152,6 @@ TEST(ExtensionFromWebApp, Minimal) {
ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); ASSERT_TRUE(extensions_dir.CreateUniqueTempDir());
WebApplicationInfo web_app; WebApplicationInfo web_app;
web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json");
web_app.title = base::ASCIIToUTF16("Gearpad"); web_app.title = base::ASCIIToUTF16("Gearpad");
web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); web_app.app_url = GURL("http://aaronboodman.com/gearpad/");
...@@ -176,18 +167,16 @@ TEST(ExtensionFromWebApp, Minimal) { ...@@ -176,18 +167,16 @@ TEST(ExtensionFromWebApp, Minimal) {
EXPECT_TRUE(extension->is_hosted_app()); EXPECT_TRUE(extension->is_hosted_app());
EXPECT_FALSE(extension->is_legacy_packaged_app()); EXPECT_FALSE(extension->is_legacy_packaged_app());
EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", EXPECT_EQ("zVvdNZy3Mp7CFU8JVSyXNlDuHdVLbP7fDO3TGVzj/0w=",
extension->public_key()); extension->public_key());
EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); EXPECT_EQ("oplhagaaipaimkjlbekcdjkffijdockj", extension->id());
EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); EXPECT_EQ("1978.12.11.0", extension->version()->GetString());
EXPECT_EQ(base::UTF16ToUTF8(web_app.title), extension->name()); EXPECT_EQ(base::UTF16ToUTF8(web_app.title), extension->name());
EXPECT_EQ("", extension->description()); EXPECT_EQ("", extension->description());
EXPECT_EQ(web_app.app_url, AppLaunchInfo::GetFullLaunchURL(extension.get())); EXPECT_EQ(web_app.app_url, AppLaunchInfo::GetFullLaunchURL(extension.get()));
EXPECT_EQ(0u, IconsInfo::GetIcons(extension.get()).map().size()); EXPECT_EQ(0u, IconsInfo::GetIcons(extension.get()).map().size());
EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size()); EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size());
ASSERT_EQ(1u, extension->web_extent().patterns().size()); ASSERT_EQ(0u, extension->web_extent().patterns().size());
EXPECT_EQ("*://aaronboodman.com/*",
extension->web_extent().patterns().begin()->GetAsString());
} }
} // namespace extensions } // namespace extensions
...@@ -422,8 +422,6 @@ void TabHelper::FinishCreateHostedApp( ...@@ -422,8 +422,6 @@ void TabHelper::FinishCreateHostedApp(
if (install_info.title.empty()) if (install_info.title.empty())
install_info.title = base::UTF8ToUTF16(install_info.app_url.spec()); 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 // Add the downloaded icons. Extensions only allow certain icon sizes. First
// populate icons that match the allowed sizes exactly and then downscale // 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. // remaining icons to the closest allowed size that doesn't yet have an icon.
......
...@@ -703,7 +703,6 @@ void AppLauncherHandler::HandleGenerateAppForLink(const base::ListValue* args) { ...@@ -703,7 +703,6 @@ void AppLauncherHandler::HandleGenerateAppForLink(const base::ListValue* args) {
} }
scoped_ptr<AppInstallInfo> install_info(new AppInstallInfo()); scoped_ptr<AppInstallInfo> install_info(new AppInstallInfo());
install_info->is_bookmark_app = true;
install_info->title = title; install_info->title = title;
install_info->app_url = launch_url; install_info->app_url = launch_url;
install_info->page_ordinal = page_ordinal; install_info->page_ordinal = page_ordinal;
...@@ -735,7 +734,6 @@ void AppLauncherHandler::OnFaviconForApp( ...@@ -735,7 +734,6 @@ void AppLauncherHandler::OnFaviconForApp(
scoped_ptr<AppInstallInfo> install_info, scoped_ptr<AppInstallInfo> install_info,
const chrome::FaviconImageResult& image_result) { const chrome::FaviconImageResult& image_result) {
scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); 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->title = install_info->title;
web_app->app_url = install_info->app_url; web_app->app_url = install_info->app_url;
......
...@@ -111,7 +111,6 @@ class AppLauncherHandler : public content::WebUIMessageHandler, ...@@ -111,7 +111,6 @@ class AppLauncherHandler : public content::WebUIMessageHandler,
AppInstallInfo(); AppInstallInfo();
~AppInstallInfo(); ~AppInstallInfo();
bool is_bookmark_app;
base::string16 title; base::string16 title;
GURL app_url; GURL app_url;
syncer::StringOrdinal page_ordinal; syncer::StringOrdinal page_ordinal;
......
...@@ -165,9 +165,6 @@ IPC_STRUCT_TRAITS_BEGIN(WebApplicationInfo) ...@@ -165,9 +165,6 @@ IPC_STRUCT_TRAITS_BEGIN(WebApplicationInfo)
IPC_STRUCT_TRAITS_MEMBER(description) IPC_STRUCT_TRAITS_MEMBER(description)
IPC_STRUCT_TRAITS_MEMBER(app_url) IPC_STRUCT_TRAITS_MEMBER(app_url)
IPC_STRUCT_TRAITS_MEMBER(icons) 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_END()
IPC_STRUCT_TRAITS_BEGIN(extensions::DraggableRegion) IPC_STRUCT_TRAITS_BEGIN(extensions::DraggableRegion)
......
...@@ -10,8 +10,7 @@ WebApplicationInfo::IconInfo::IconInfo() : width(0), height(0) { ...@@ -10,8 +10,7 @@ WebApplicationInfo::IconInfo::IconInfo() : width(0), height(0) {
WebApplicationInfo::IconInfo::~IconInfo() { WebApplicationInfo::IconInfo::~IconInfo() {
} }
WebApplicationInfo::WebApplicationInfo() WebApplicationInfo::WebApplicationInfo() {
: is_bookmark_app(false), is_offline_enabled(false) {
} }
WebApplicationInfo::~WebApplicationInfo() { WebApplicationInfo::~WebApplicationInfo() {
......
...@@ -28,18 +28,6 @@ struct WebApplicationInfo { ...@@ -28,18 +28,6 @@ struct WebApplicationInfo {
WebApplicationInfo(); 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. // Title of the application.
base::string16 title; base::string16 title;
...@@ -51,20 +39,6 @@ struct WebApplicationInfo { ...@@ -51,20 +39,6 @@ struct WebApplicationInfo {
// Set of available icons. // Set of available icons.
std::vector<IconInfo> 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_ #endif // CHROME_COMMON_WEB_APPLICATION_INFO_H_
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