diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 18:01:18 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 18:01:18 +0000 |
commit | dbeb39586fd6d8e75ed6ad4e6c4606ee16e53348 (patch) | |
tree | 5bec0f3b7d6bd08d4283e6fcd2b68b2b01f2730d /webkit/glue/dom_operations.cc | |
parent | abbc5739c1689384fbbdbd0ee6c9d2d9a8c2da0b (diff) | |
download | chromium_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/dom_operations.cc')
-rw-r--r-- | webkit/glue/dom_operations.cc | 26 |
1 files changed, 18 insertions, 8 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 |