Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 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::string& allowed_destination_host_pattern, |
| 71 const std::string& css_selector, | 74 const std::string& css_selector, |
| 72 const std::string& markup); | 75 const std::string& markup, |
| 76 const std::vector<std::string>& names, | |
| 77 const std::vector<gfx::Rect>& rects); | |
| 78 CONTENT_EXPORT void AddPendingTransitionRequestDataForTesting( | |
| 79 int render_process_id, | |
| 80 int render_frame_id); | |
| 73 | 81 |
| 74 void ClearPendingTransitionRequestData(int render_process_id, | 82 void ClearPendingTransitionRequestData(int render_process_id, |
| 75 int render_frame_id); | 83 int render_frame_id); |
| 76 | 84 |
| 77 private: | 85 private: |
| 78 class TransitionRequestData { | 86 class TransitionRequestData { |
| 79 public: | 87 public: |
| 80 TransitionRequestData(); | 88 TransitionRequestData(); |
| 81 ~TransitionRequestData(); | 89 ~TransitionRequestData(); |
| 82 void AddEntry(const std::string& allowed_destination_host_pattern, | 90 void AddEntry(const std::string& allowed_destination_host_pattern, |
| 83 const std::string& selector, | 91 const std::string& selector, |
| 84 const std::string& markup); | 92 const std::string& markup, |
| 93 const std::vector<std::string>& names, | |
| 94 const std::vector<gfx::Rect>& rects); | |
| 85 bool FindEntry(const GURL& request_url, | 95 bool FindEntry(const GURL& request_url, |
| 86 TransitionLayerData* transition_data); | 96 TransitionLayerData* transition_data); |
| 87 | 97 |
| 88 private: | 98 private: |
| 89 struct AllowedEntry { | 99 struct AllowedEntry { |
| 90 // These strings could have originated from a compromised renderer, | 100 // These strings could have originated from a compromised renderer, |
| 91 // and should not be trusted or assumed safe. They are only used within | 101 // and should not be trusted or assumed safe. They are only used within |
| 92 // a sandboxed iframe with scripts disabled. | 102 // a sandboxed iframe with scripts disabled. |
| 93 std::string allowed_destination_host_pattern; | 103 std::string allowed_destination_host_pattern; |
| 94 std::string css_selector; | 104 std::string css_selector; |
| 95 std::string markup; | 105 std::string markup; |
| 106 std::vector<std::string> names; | |
| 107 std::vector<gfx::Rect> rects; | |
| 96 | 108 |
| 97 AllowedEntry(const std::string& allowed_destination_host_pattern, | 109 AllowedEntry(const std::string& allowed_destination_host_pattern, |
| 98 const std::string& css_selector, | 110 const std::string& css_selector, |
| 99 const std::string& markup) : | 111 const std::string& markup, |
| 100 allowed_destination_host_pattern(allowed_destination_host_pattern), | 112 const std::vector<std::string>& names, |
| 101 css_selector(css_selector), | 113 const std::vector<gfx::Rect>& rects); |
| 102 markup(markup) {} | 114 ~AllowedEntry(); |
|
nasko
2014/10/17 20:04:19
If there is a destructor, this is no longer a simp
Zhen Wang
2014/10/17 21:34:29
It will complain without the destructor.
http://w
nasko
2014/10/20 14:14:18
Acknowledged.
| |
| 103 }; | 115 }; |
| 104 std::vector<AllowedEntry> allowed_entries_; | 116 std::vector<AllowedEntry> allowed_entries_; |
| 105 }; | 117 }; |
| 106 | 118 |
| 107 friend struct DefaultSingletonTraits<TransitionRequestManager>; | 119 friend struct DefaultSingletonTraits<TransitionRequestManager>; |
| 108 typedef std::map<std::pair<int, int>, TransitionRequestData> | 120 typedef std::map<std::pair<int, int>, TransitionRequestData> |
| 109 RenderFrameRequestDataMap; | 121 RenderFrameRequestDataMap; |
| 110 | 122 |
| 111 TransitionRequestManager(); | 123 TransitionRequestManager(); |
| 112 ~TransitionRequestManager(); | 124 ~TransitionRequestManager(); |
| 113 | 125 |
| 114 // Map of (render_process_host_id, render_frame_id) pairs of all | 126 // Map of (render_process_host_id, render_frame_id) pairs of all |
| 115 // RenderFrameHosts that have pending cross-site requests and their data. | 127 // RenderFrameHosts that have pending cross-site requests and their data. |
| 116 // Used to pass information to the CrossSiteResourceHandler without doing a | 128 // Used to pass information to the CrossSiteResourceHandler without doing a |
| 117 // round-trip between IO->UI->IO threads. | 129 // round-trip between IO->UI->IO threads. |
| 118 RenderFrameRequestDataMap pending_transition_frames_; | 130 RenderFrameRequestDataMap pending_transition_frames_; |
| 119 | 131 |
| 120 DISALLOW_COPY_AND_ASSIGN(TransitionRequestManager); | 132 DISALLOW_COPY_AND_ASSIGN(TransitionRequestManager); |
| 121 }; | 133 }; |
| 122 | 134 |
| 123 } // namespace content | 135 } // namespace content |
| 124 | 136 |
| 125 #endif // CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ | 137 #endif // CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ |
| OLD | NEW |