| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BROWSER_TRANSITION_REQUEST_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ | 6 #define CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "ui/gfx/geometry/rect.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 template <typename T> | 19 template <typename T> |
| 19 struct DefaultSingletonTraits; | 20 struct DefaultSingletonTraits; |
| 20 | 21 |
| 21 namespace net { | 22 namespace net { |
| 22 class HttpResponseHeaders; | 23 class HttpResponseHeaders; |
| 23 } | 24 } |
| 24 class GURL; | 25 class GURL; |
| 25 | 26 |
| 26 namespace content { | 27 namespace content { |
| 27 | 28 |
| 28 // This struct passes data about an imminent transition between threads. | 29 // This struct passes data about an imminent transition between threads. |
| 29 struct TransitionLayerData { | 30 struct TransitionLayerData { |
| 30 TransitionLayerData(); | 31 TransitionLayerData(); |
| 31 ~TransitionLayerData(); | 32 ~TransitionLayerData(); |
| 32 | 33 |
| 33 std::string markup; | 34 std::string markup; |
| 34 std::string css_selector; | 35 std::string css_selector; |
| 36 std::vector<std::string> names; |
| 37 std::vector<gfx::Rect> rects; |
| 35 scoped_refptr<net::HttpResponseHeaders> response_headers; | 38 scoped_refptr<net::HttpResponseHeaders> response_headers; |
| 36 GURL request_url; | 39 GURL request_url; |
| 37 }; | 40 }; |
| 38 | 41 |
| 39 // TransitionRequestManager is used to handle bookkeeping for transition | 42 // TransitionRequestManager is used to handle bookkeeping for transition |
| 40 // requests and responses. | 43 // requests and responses. |
| 41 // | 44 // |
| 42 // TransitionRequestManager is a singleton and should only be accessed on the IO | 45 // TransitionRequestManager is a singleton and should only be accessed on the IO |
| 43 // thread. | 46 // thread. |
| 44 // | 47 // |
| (...skipping 15 matching lines...) Expand all Loading... |
| 60 bool HasPendingTransitionRequest(int render_process_id, | 63 bool HasPendingTransitionRequest(int render_process_id, |
| 61 int render_frame_id, | 64 int render_frame_id, |
| 62 const GURL& request_url, | 65 const GURL& request_url, |
| 63 TransitionLayerData* transition_data); | 66 TransitionLayerData* transition_data); |
| 64 | 67 |
| 65 // Adds pending request data for a transition navigation for the | 68 // Adds pending request data for a transition navigation for the |
| 66 // RenderFrameHost specified by the given IDs. | 69 // RenderFrameHost specified by the given IDs. |
| 67 CONTENT_EXPORT void AddPendingTransitionRequestData( | 70 CONTENT_EXPORT void AddPendingTransitionRequestData( |
| 68 int render_process_id, | 71 int render_process_id, |
| 69 int render_frame_id, | 72 int render_frame_id, |
| 70 const std::string& allowed_destination_host_pattern, | 73 const std::vector<std::string>& data, |
| 71 const std::string& css_selector, | 74 const std::vector<std::string>& names, |
| 72 const std::string& markup); | 75 const std::vector<gfx::Rect>& rects); |
| 73 | 76 |
| 74 void ClearPendingTransitionRequestData(int render_process_id, | 77 void ClearPendingTransitionRequestData(int render_process_id, |
| 75 int render_frame_id); | 78 int render_frame_id); |
| 76 | 79 |
| 77 private: | 80 private: |
| 78 class TransitionRequestData { | 81 class TransitionRequestData { |
| 79 public: | 82 public: |
| 80 TransitionRequestData(); | 83 TransitionRequestData(); |
| 81 ~TransitionRequestData(); | 84 ~TransitionRequestData(); |
| 82 void AddEntry(const std::string& allowed_destination_host_pattern, | 85 void AddEntry(const std::string& allowed_destination_host_pattern, |
| 83 const std::string& selector, | 86 const std::string& selector, |
| 84 const std::string& markup); | 87 const std::string& markup, |
| 88 const std::vector<std::string>& names, |
| 89 const std::vector<gfx::Rect>& rects); |
| 85 bool FindEntry(const GURL& request_url, | 90 bool FindEntry(const GURL& request_url, |
| 86 TransitionLayerData* transition_data); | 91 TransitionLayerData* transition_data); |
| 87 | 92 |
| 88 private: | 93 private: |
| 89 struct AllowedEntry { | 94 struct AllowedEntry { |
| 90 // These strings could have originated from a compromised renderer, | 95 // These strings could have originated from a compromised renderer, |
| 91 // and should not be trusted or assumed safe. They are only used within | 96 // and should not be trusted or assumed safe. They are only used within |
| 92 // a sandboxed iframe with scripts disabled. | 97 // a sandboxed iframe with scripts disabled. |
| 93 std::string allowed_destination_host_pattern; | 98 std::string allowed_destination_host_pattern; |
| 94 std::string css_selector; | 99 std::string css_selector; |
| 95 std::string markup; | 100 std::string markup; |
| 101 std::vector<std::string> names; |
| 102 std::vector<gfx::Rect> rects; |
| 96 | 103 |
| 97 AllowedEntry(const std::string& allowed_destination_host_pattern, | 104 AllowedEntry(const std::string& allowed_destination_host_pattern, |
| 98 const std::string& css_selector, | 105 const std::string& css_selector, |
| 99 const std::string& markup) : | 106 const std::string& markup, |
| 100 allowed_destination_host_pattern(allowed_destination_host_pattern), | 107 const std::vector<std::string>& names, |
| 101 css_selector(css_selector), | 108 const std::vector<gfx::Rect>& rects); |
| 102 markup(markup) {} | 109 ~AllowedEntry(); |
| 103 }; | 110 }; |
| 104 std::vector<AllowedEntry> allowed_entries_; | 111 std::vector<AllowedEntry> allowed_entries_; |
| 105 }; | 112 }; |
| 106 | 113 |
| 107 friend struct DefaultSingletonTraits<TransitionRequestManager>; | 114 friend struct DefaultSingletonTraits<TransitionRequestManager>; |
| 108 typedef std::map<std::pair<int, int>, TransitionRequestData> | 115 typedef std::map<std::pair<int, int>, TransitionRequestData> |
| 109 RenderFrameRequestDataMap; | 116 RenderFrameRequestDataMap; |
| 110 | 117 |
| 111 TransitionRequestManager(); | 118 TransitionRequestManager(); |
| 112 ~TransitionRequestManager(); | 119 ~TransitionRequestManager(); |
| 113 | 120 |
| 114 // Map of (render_process_host_id, render_frame_id) pairs of all | 121 // Map of (render_process_host_id, render_frame_id) pairs of all |
| 115 // RenderFrameHosts that have pending cross-site requests and their data. | 122 // RenderFrameHosts that have pending cross-site requests and their data. |
| 116 // Used to pass information to the CrossSiteResourceHandler without doing a | 123 // Used to pass information to the CrossSiteResourceHandler without doing a |
| 117 // round-trip between IO->UI->IO threads. | 124 // round-trip between IO->UI->IO threads. |
| 118 RenderFrameRequestDataMap pending_transition_frames_; | 125 RenderFrameRequestDataMap pending_transition_frames_; |
| 119 | 126 |
| 120 DISALLOW_COPY_AND_ASSIGN(TransitionRequestManager); | 127 DISALLOW_COPY_AND_ASSIGN(TransitionRequestManager); |
| 121 }; | 128 }; |
| 122 | 129 |
| 123 } // namespace content | 130 } // namespace content |
| 124 | 131 |
| 125 #endif // CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ | 132 #endif // CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ |
| OLD | NEW |