summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 18:01:18 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 18:01:18 +0000
commitdbeb39586fd6d8e75ed6ad4e6c4606ee16e53348 (patch)
tree5bec0f3b7d6bd08d4283e6fcd2b68b2b01f2730d /chrome
parentabbc5739c1689384fbbdbd0ee6c9d2d9a8c2da0b (diff)
downloadchromium_src-dbeb39586fd6d8e75ed6ad4e6c4606ee16e53348.zip
chromium_src-dbeb39586fd6d8e75ed6ad4e6c4606ee16e53348.tar.gz
chromium_src-dbeb39586fd6d8e75ed6ad4e6c4606ee16e53348.tar.bz2
This patch enables "Save page as" (ctrl+s) for resources located at
chrome-extension URLs. In the absence of any API for doing file I/O this adds very useful functionality to chrome extensions. This patch is needed to allow APU to save its instrumentation data to disk without the need for a plugin. patch by: Jaime Yap (jaimeyap@google.com) BUG=none TEST=Bundle a page "foo.html" with an extension. Usings the tabs API or window.open, open "foo.html" in the extensions process. Try to save it using CTRL+S. (You can test with any of the existing samples that bundle a page). Review URL: http://codereview.chromium.org/266051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28839 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/download/save_package.cc10
-rw-r--r--chrome/common/url_constants.cc11
-rw-r--r--chrome/common/url_constants.h3
-rw-r--r--chrome/renderer/render_view.cc8
4 files changed, 25 insertions, 7 deletions
diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc
index 3c4c7a6..ac4a39e 100644
--- a/chrome/browser/download/save_package.cc
+++ b/chrome/browser/download/save_package.cc
@@ -1193,10 +1193,12 @@ void SavePackage::ContinueSave(SavePackageParam* param,
// Static
bool SavePackage::IsSavableURL(const GURL& url) {
- return url.SchemeIs(chrome::kHttpScheme) ||
- url.SchemeIs(chrome::kHttpsScheme) ||
- url.SchemeIs(chrome::kFileScheme) ||
- url.SchemeIs(chrome::kFtpScheme);
+ for (int i = 0; chrome::kSavableSchemes[i] != NULL; ++i) {
+ if (url.SchemeIs(chrome::kSavableSchemes[i])) {
+ return true;
+ }
+ }
+ return false;
}
// Static
diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc
index 9da39eb..2c7ec0e 100644
--- a/chrome/common/url_constants.cc
+++ b/chrome/common/url_constants.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <stdlib.h>
+
#include "chrome/common/url_constants.h"
namespace chrome {
@@ -24,6 +26,15 @@ const char kViewSourceScheme[] = "view-source";
const char kStandardSchemeSeparator[] = "://";
+const char* kSavableSchemes[] = {
+ kHttpScheme,
+ kHttpsScheme,
+ kFileScheme,
+ kFtpScheme,
+ kExtensionScheme,
+ NULL
+};
+
const char kAboutBlankURL[] = "about:blank";
const char kAboutCacheURL[] = "about:cache";
const char kAboutNetInternalsURL[] = "about:net-internals";
diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h
index 0cbde15..f59d279 100644
--- a/chrome/common/url_constants.h
+++ b/chrome/common/url_constants.h
@@ -29,6 +29,9 @@ extern const char kViewSourceScheme[];
// Used to separate a standard scheme and the hostname: "://".
extern const char kStandardSchemeSeparator[];
+// Null terminated list of schemes that are savable.
+extern const char* kSavableSchemes[];
+
// About URLs (including schmes).
extern const char kAboutBlankURL[];
extern const char kAboutBrowserCrash[];
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 746aefc..9dce62a 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -3111,9 +3111,11 @@ void RenderView::OnGetAllSavableResourceLinksForCurrentPage(
&referrers_list,
&frames_list);
- if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage(webview(),
- page_url,
- &result)) {
+ if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage(
+ webview(),
+ page_url,
+ &result,
+ chrome::kSavableSchemes)) {
// If something is wrong when collecting all savable resource links,
// send empty list to embedder(browser) to tell it failed.
referrers_list.clear();