| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_SAVABLE_RESOURCES_H_ | 5 #ifndef CONTENT_RENDERER_SAVABLE_RESOURCES_H_ |
| 6 #define CONTENT_RENDERER_SAVABLE_RESOURCES_H_ | 6 #define CONTENT_RENDERER_SAVABLE_RESOURCES_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 12 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 class WebElement; | 16 class WebElement; |
| 17 class WebFrame; |
| 17 class WebString; | 18 class WebString; |
| 18 class WebView; | 19 class WebView; |
| 19 } | 20 } |
| 20 | 21 |
| 21 // A collection of operations that access the underlying WebKit DOM directly. | 22 // A collection of operations that access the underlying WebKit DOM directly. |
| 22 namespace content { | 23 namespace content { |
| 23 | 24 |
| 24 // Structure for storage the result of getting all savable resource links | 25 // Structure for storage the result of getting all savable resource links |
| 25 // for current page. The consumer of the SavableResourcesResult is responsible | 26 // for current page. The consumer of the SavableResourcesResult is responsible |
| 26 // for keeping these pointers valid for the lifetime of the | 27 // for keeping these pointers valid for the lifetime of the |
| 27 // SavableResourcesResult instance. | 28 // SavableResourcesResult instance. |
| 28 struct SavableResourcesResult { | 29 struct SavableResourcesResult { |
| 29 // vector which contains all savable links of sub resource. | 30 // vector which contains all savable links of sub resource. |
| 30 std::vector<GURL>* resources_list; | 31 std::vector<GURL>* resources_list; |
| 31 // vector which contains corresponding all referral links of sub resource, | 32 // vector which contains corresponding all referral links of sub resource, |
| 32 // it matched with links one by one. | 33 // it matched with links one by one. |
| 33 std::vector<GURL>* referrer_urls_list; | 34 std::vector<GURL>* referrer_urls_list; |
| 34 // and the corresponding referrer policies. | 35 // and the corresponding referrer policies. |
| 35 std::vector<blink::WebReferrerPolicy>* referrer_policies_list; | 36 std::vector<blink::WebReferrerPolicy>* referrer_policies_list; |
| 36 // vector which contains all savable links of main frame and sub frames. | |
| 37 std::vector<GURL>* frames_list; | |
| 38 | 37 |
| 39 // Constructor. | 38 // Constructor. |
| 40 SavableResourcesResult( | 39 SavableResourcesResult( |
| 41 std::vector<GURL>* resources_list, | 40 std::vector<GURL>* resources_list, |
| 42 std::vector<GURL>* referrer_urls_list, | 41 std::vector<GURL>* referrer_urls_list, |
| 43 std::vector<blink::WebReferrerPolicy>* referrer_policies_list, | 42 std::vector<blink::WebReferrerPolicy>* referrer_policies_list) |
| 44 std::vector<GURL>* frames_list) | |
| 45 : resources_list(resources_list), | 43 : resources_list(resources_list), |
| 46 referrer_urls_list(referrer_urls_list), | 44 referrer_urls_list(referrer_urls_list), |
| 47 referrer_policies_list(referrer_policies_list), | 45 referrer_policies_list(referrer_policies_list) {} |
| 48 frames_list(frames_list) { } | |
| 49 | 46 |
| 50 private: | 47 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(SavableResourcesResult); | 48 DISALLOW_COPY_AND_ASSIGN(SavableResourcesResult); |
| 52 }; | 49 }; |
| 53 | 50 |
| 54 // Get all savable resource links from current webview, include main frame | 51 // Get all savable resource links from specified webframe. |
| 55 // and sub-frame. After collecting all savable resource links, this function | 52 // Returns true if the saved resources links have been saved successfully. |
| 56 // will send those links to embedder. Return value indicates whether we get | 53 // Otherwise returns false (i.e. if the frame contains a non-savable content). |
| 57 // all saved resource links successfully. | 54 CONTENT_EXPORT bool GetSavableResourceLinksForFrame( |
| 58 CONTENT_EXPORT bool GetAllSavableResourceLinksForCurrentPage( | 55 blink::WebFrame* frame, |
| 59 blink::WebView* view, | 56 SavableResourcesResult* result, |
| 60 const GURL& page_url, | |
| 61 SavableResourcesResult* savable_resources_result, | |
| 62 const char** savable_schemes); | 57 const char** savable_schemes); |
| 63 | 58 |
| 64 // Returns the value in an elements resource url attribute. For IMG, SCRIPT or | 59 // Returns the value in an elements resource url attribute. For IMG, SCRIPT or |
| 65 // INPUT TYPE=image, returns the value in "src". For LINK TYPE=text/css, returns | 60 // INPUT TYPE=image, returns the value in "src". For LINK TYPE=text/css, returns |
| 66 // the value in "href". For BODY, TABLE, TR, TD, returns the value in | 61 // the value in "href". For BODY, TABLE, TR, TD, returns the value in |
| 67 // "background". For BLOCKQUOTE, Q, DEL, INS, returns the value in "cite" | 62 // "background". For BLOCKQUOTE, Q, DEL, INS, returns the value in "cite" |
| 68 // attribute. Otherwise returns a null WebString. | 63 // attribute. Otherwise returns a null WebString. |
| 69 CONTENT_EXPORT blink::WebString GetSubResourceLinkFromElement( | 64 CONTENT_EXPORT blink::WebString GetSubResourceLinkFromElement( |
| 70 const blink::WebElement& element); | 65 const blink::WebElement& element); |
| 71 | 66 |
| 72 } // namespace content | 67 } // namespace content |
| 73 | 68 |
| 74 #endif // CONTENT_RENDERER_SAVABLE_RESOURCES_H_ | 69 #endif // CONTENT_RENDERER_SAVABLE_RESOURCES_H_ |
| OLD | NEW |