summaryrefslogtreecommitdiffstats
path: root/webkit/glue
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 /webkit/glue
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 'webkit/glue')
-rw-r--r--webkit/glue/dom_operations.cc26
-rw-r--r--webkit/glue/dom_operations.h3
-rw-r--r--webkit/glue/dom_operations_unittest.cc9
3 files changed, 28 insertions, 10 deletions
diff --git a/webkit/glue/dom_operations.cc b/webkit/glue/dom_operations.cc
index 986b61f..298933d 100644
--- a/webkit/glue/dom_operations.cc
+++ b/webkit/glue/dom_operations.cc
@@ -116,20 +116,28 @@ void GetSavableResourceLinkForElement(WebCore::Element* element,
// Get all savable resource links from current WebFrameImpl object pointer.
void GetAllSavableResourceLinksForFrame(WebFrameImpl* current_frame,
SavableResourcesUniqueCheck* unique_check,
- webkit_glue::SavableResourcesResult* result) {
+ webkit_glue::SavableResourcesResult* result,
+ const char** savable_schemes) {
// Get current frame's URL.
const WebCore::KURL& current_frame_kurl =
current_frame->frame()->loader()->url();
GURL current_frame_gurl(webkit_glue::KURLToGURL(current_frame_kurl));
- // If url of current frame is invalid or not standard protocol, ignore it.
+ // If url of current frame is invalid, ignore it.
if (!current_frame_gurl.is_valid())
return;
- if (!current_frame_gurl.SchemeIs("http") &&
- !current_frame_gurl.SchemeIs("https") &&
- !current_frame_gurl.SchemeIs("ftp") &&
- !current_frame_gurl.SchemeIs("file"))
+
+ // If url of current frame is not a savable protocol, ignore it.
+ bool is_valid_protocol = false;
+ for (int i = 0; savable_schemes[i] != NULL; ++i) {
+ if (current_frame_gurl.SchemeIs(savable_schemes[i])) {
+ is_valid_protocol = true;
+ break;
+ }
+ }
+ if (!is_valid_protocol)
return;
+
// If find same frame we have recorded, ignore it.
if (!unique_check->frames_set->insert(current_frame_gurl).second)
return;
@@ -628,7 +636,8 @@ WebFrameImpl* GetWebFrameImplFromWebViewForSpecificURL(WebView* view,
// Get all savable resource links from current webview, include main
// frame and sub-frame
bool GetAllSavableResourceLinksForCurrentPage(WebView* view,
- const GURL& page_url, SavableResourcesResult* result) {
+ const GURL& page_url, SavableResourcesResult* result,
+ const char** savable_schemes) {
WebFrame* main_frame = view->mainFrame();
if (!main_frame)
return false;
@@ -655,7 +664,8 @@ bool GetAllSavableResourceLinksForCurrentPage(WebView* view,
// Check all resource in this page, include sub-frame.
for (int i = 0; i < static_cast<int>(frames.size()); ++i) {
// Get current frame's all savable resource links.
- GetAllSavableResourceLinksForFrame(frames[i], &unique_check, result);
+ GetAllSavableResourceLinksForFrame(frames[i], &unique_check, result,
+ savable_schemes);
}
// Since frame's src can also point to sub-resources link, so it is possible
diff --git a/webkit/glue/dom_operations.h b/webkit/glue/dom_operations.h
index f202def..1694f4d 100644
--- a/webkit/glue/dom_operations.h
+++ b/webkit/glue/dom_operations.h
@@ -87,7 +87,8 @@ struct SavableResourcesResult {
// will send those links to embedder. Return value indicates whether we get
// all saved resource links successfully.
bool GetAllSavableResourceLinksForCurrentPage(WebView* view,
- const GURL& page_url, SavableResourcesResult* savable_resources_result);
+ const GURL& page_url, SavableResourcesResult* savable_resources_result,
+ const char** savable_schemes);
// Structure used when installing a web page as an app. Populated via
// GetApplicationInfo.
diff --git a/webkit/glue/dom_operations_unittest.cc b/webkit/glue/dom_operations_unittest.cc
index b5487b2..92955da 100644
--- a/webkit/glue/dom_operations_unittest.cc
+++ b/webkit/glue/dom_operations_unittest.cc
@@ -51,8 +51,15 @@ void DomOperationsTests::GetSavableResourceLinksForPage(
&referrers_list,
&frames_list);
+ const char* savable_schemes[] = {
+ "http",
+ "https",
+ "file",
+ NULL
+ };
+
ASSERT_TRUE(webkit_glue::GetAllSavableResourceLinksForCurrentPage(
- test_shell_->webView(), file_url, &result));
+ test_shell_->webView(), file_url, &result, savable_schemes));
// Check all links of sub-resource
for (std::vector<GURL>::const_iterator cit = resources_list.begin();
cit != resources_list.end(); ++cit) {