summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorgrv@chromium.org <grv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-24 03:38:03 +0000
committergrv@chromium.org <grv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-24 03:38:03 +0000
commitc80ef51b451c91ae2f037b090dbec7a0d050c56f (patch)
treec3ddfe404e424a7476a9d3b6bef633797ce2de2b /chrome
parent762451ad8d8ab9a83bb06667b9855f4e8b280e70 (diff)
downloadchromium_src-c80ef51b451c91ae2f037b090dbec7a0d050c56f.zip
chromium_src-c80ef51b451c91ae2f037b090dbec7a0d050c56f.tar.gz
chromium_src-c80ef51b451c91ae2f037b090dbec7a0d050c56f.tar.bz2
Add offline_mode support in crx-less apps
Added a key in the manifest file "offline_enabled", for crx-less apps to support offline_mode. BUG=101782 TEST=unit_test Review URL: https://chromiumcodereview.appspot.com/10704092 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148039 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/convert_web_app.cc4
-rw-r--r--chrome/common/extensions/extension_messages.h1
-rw-r--r--chrome/common/web_apps.cc4
-rw-r--r--chrome/common/web_apps.h5
-rw-r--r--chrome/common/web_apps_unittest.cc1
-rw-r--r--chrome/test/data/web_app_info/full.json1
6 files changed, 15 insertions, 1 deletions
diff --git a/chrome/browser/extensions/convert_web_app.cc b/chrome/browser/extensions/convert_web_app.cc
index 0f8bc53..a114cc3 100644
--- a/chrome/browser/extensions/convert_web_app.cc
+++ b/chrome/browser/extensions/convert_web_app.cc
@@ -103,6 +103,10 @@ scoped_refptr<Extension> ConvertWebAppToExtension(
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, UTF16ToUTF8(web_app.title));
root->SetString(keys::kVersion, ConvertTimeToExtensionVersion(create_time));
root->SetString(keys::kDescription, UTF16ToUTF8(web_app.description));
diff --git a/chrome/common/extensions/extension_messages.h b/chrome/common/extensions/extension_messages.h
index b09b18c..82f66e3 100644
--- a/chrome/common/extensions/extension_messages.h
+++ b/chrome/common/extensions/extension_messages.h
@@ -92,6 +92,7 @@ IPC_STRUCT_TRAITS_BEGIN(WebApplicationInfo)
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()
// Singly-included section for custom IPC traits.
diff --git a/chrome/common/web_apps.cc b/chrome/common/web_apps.cc
index 8a2cdcc..a2d1d7e 100644
--- a/chrome/common/web_apps.cc
+++ b/chrome/common/web_apps.cc
@@ -103,6 +103,7 @@ const char WebApplicationInfo::kInvalidIconURL[] =
WebApplicationInfo::WebApplicationInfo() {
is_bookmark_app = false;
+ is_offline_enabled = false;
}
WebApplicationInfo::~WebApplicationInfo() {
@@ -316,6 +317,9 @@ bool ParseWebAppFromDefinitionFile(Value* definition_value,
}
}
+ // Parse if offline mode is enabled.
+ definition->GetBoolean("offline_enabled", &web_app->is_offline_enabled);
+
CHECK(definition->GetString("name", &web_app->title));
definition->GetString("description", &web_app->description);
definition->GetString("launch_container", &web_app->launch_container);
diff --git a/chrome/common/web_apps.h b/chrome/common/web_apps.h
index e0526b6..b3ea039 100644
--- a/chrome/common/web_apps.h
+++ b/chrome/common/web_apps.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -74,6 +74,9 @@ struct WebApplicationInfo {
// 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;
};
diff --git a/chrome/common/web_apps_unittest.cc b/chrome/common/web_apps_unittest.cc
index 20db234..5f71fcd 100644
--- a/chrome/common/web_apps_unittest.cc
+++ b/chrome/common/web_apps_unittest.cc
@@ -134,6 +134,7 @@ TEST(WebAppInfo, Full) {
EXPECT_EQ("geolocation", web_app->permissions[0]);
EXPECT_EQ("notifications", web_app->permissions[1]);
EXPECT_EQ("panel", web_app->launch_container);
+ EXPECT_EQ(true, web_app->is_offline_enabled);
}
// Tests ParseIconSizes with various input.
diff --git a/chrome/test/data/web_app_info/full.json b/chrome/test/data/web_app_info/full.json
index ef38f53..ab58160 100644
--- a/chrome/test/data/web_app_info/full.json
+++ b/chrome/test/data/web_app_info/full.json
@@ -4,6 +4,7 @@
"launch_url": "launch_url",
"launch_container": "panel",
"permissions": [ "geolocation", "notifications" ],
+ "offline_enabled": true,
"urls": [ "foobar", "baz" ],
"icons": {
"ignored": "ignored.png",