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