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 #include "content/renderer/savable_resources.h" | 5 #include "content/renderer/savable_resources.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "third_party/WebKit/public/platform/WebString.h" | 12 #include "third_party/WebKit/public/platform/WebString.h" |
13 #include "third_party/WebKit/public/platform/WebVector.h" | 13 #include "third_party/WebKit/public/platform/WebVector.h" |
14 #include "third_party/WebKit/public/web/WebDocument.h" | 14 #include "third_party/WebKit/public/web/WebDocument.h" |
15 #include "third_party/WebKit/public/web/WebElement.h" | 15 #include "third_party/WebKit/public/web/WebElement.h" |
16 #include "third_party/WebKit/public/web/WebFrame.h" | 16 #include "third_party/WebKit/public/web/WebFrame.h" |
17 #include "third_party/WebKit/public/web/WebInputElement.h" | 17 #include "third_party/WebKit/public/web/WebInputElement.h" |
18 #include "third_party/WebKit/public/web/WebNode.h" | 18 #include "third_party/WebKit/public/web/WebNode.h" |
19 #include "third_party/WebKit/public/web/WebNodeCollection.h" | 19 #include "third_party/WebKit/public/web/WebNodeCollection.h" |
20 #include "third_party/WebKit/public/web/WebNodeList.h" | 20 #include "third_party/WebKit/public/web/WebNodeList.h" |
21 #include "third_party/WebKit/public/web/WebView.h" | 21 #include "third_party/WebKit/public/web/WebView.h" |
22 | 22 |
23 using WebKit::WebDocument; | 23 using blink::WebDocument; |
24 using WebKit::WebElement; | 24 using blink::WebElement; |
25 using WebKit::WebFrame; | 25 using blink::WebFrame; |
26 using WebKit::WebInputElement; | 26 using blink::WebInputElement; |
27 using WebKit::WebNode; | 27 using blink::WebNode; |
28 using WebKit::WebNodeCollection; | 28 using blink::WebNodeCollection; |
29 using WebKit::WebNodeList; | 29 using blink::WebNodeList; |
30 using WebKit::WebString; | 30 using blink::WebString; |
31 using WebKit::WebVector; | 31 using blink::WebVector; |
32 using WebKit::WebView; | 32 using blink::WebView; |
33 | 33 |
34 namespace content { | 34 namespace content { |
35 namespace { | 35 namespace { |
36 | 36 |
37 // Structure for storage the unique set of all savable resource links for | 37 // Structure for storage the unique set of all savable resource links for |
38 // making sure that no duplicated resource link in final result. The consumer | 38 // making sure that no duplicated resource link in final result. The consumer |
39 // of the SavableResourcesUniqueCheck is responsible for keeping these pointers | 39 // of the SavableResourcesUniqueCheck is responsible for keeping these pointers |
40 // valid for the lifetime of the SavableResourcesUniqueCheck instance. | 40 // valid for the lifetime of the SavableResourcesUniqueCheck instance. |
41 struct SavableResourcesUniqueCheck { | 41 struct SavableResourcesUniqueCheck { |
42 // Unique set of all sub resource links. | 42 // Unique set of all sub resource links. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // protocol does no have cache mechanism, we will skip all | 90 // protocol does no have cache mechanism, we will skip all |
91 // sub-resources if they use FTP protocol. | 91 // sub-resources if they use FTP protocol. |
92 if (!u.SchemeIsHTTPOrHTTPS() && !u.SchemeIs("file")) | 92 if (!u.SchemeIsHTTPOrHTTPS() && !u.SchemeIs("file")) |
93 return; | 93 return; |
94 // Ignore duplicated resource link. | 94 // Ignore duplicated resource link. |
95 if (!unique_check->resources_set->insert(u).second) | 95 if (!unique_check->resources_set->insert(u).second) |
96 return; | 96 return; |
97 result->resources_list->push_back(u); | 97 result->resources_list->push_back(u); |
98 // Insert referrer for above new resource link. | 98 // Insert referrer for above new resource link. |
99 result->referrer_urls_list->push_back(GURL()); | 99 result->referrer_urls_list->push_back(GURL()); |
100 result->referrer_policies_list->push_back(WebKit::WebReferrerPolicyDefault); | 100 result->referrer_policies_list->push_back(blink::WebReferrerPolicyDefault); |
101 } | 101 } |
102 | 102 |
103 // Get all savable resource links from current WebFrameImpl object pointer. | 103 // Get all savable resource links from current WebFrameImpl object pointer. |
104 void GetAllSavableResourceLinksForFrame(WebFrame* current_frame, | 104 void GetAllSavableResourceLinksForFrame(WebFrame* current_frame, |
105 SavableResourcesUniqueCheck* unique_check, | 105 SavableResourcesUniqueCheck* unique_check, |
106 SavableResourcesResult* result, | 106 SavableResourcesResult* result, |
107 const char** savable_schemes) { | 107 const char** savable_schemes) { |
108 // Get current frame's URL. | 108 // Get current frame's URL. |
109 GURL current_frame_url = current_frame->document().url(); | 109 GURL current_frame_url = current_frame->document().url(); |
110 | 110 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 it != frames_set.end(); ++it) { | 229 it != frames_set.end(); ++it) { |
230 // Append unique frame source to savable frame list. | 230 // Append unique frame source to savable frame list. |
231 if (resources_set.find(*it) == resources_set.end()) | 231 if (resources_set.find(*it) == resources_set.end()) |
232 result->frames_list->push_back(*it); | 232 result->frames_list->push_back(*it); |
233 } | 233 } |
234 | 234 |
235 return true; | 235 return true; |
236 } | 236 } |
237 | 237 |
238 } // namespace content | 238 } // namespace content |
OLD | NEW |