Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: content/browser/transition_request_manager.h

Issue 652953008: Navigation transitions (web to native app): Pass data after starting provisional load (Chrome side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 CONTENT_EXPORT TransitionLayerData(); 32 CONTENT_EXPORT TransitionLayerData();
32 CONTENT_EXPORT ~TransitionLayerData(); 33 CONTENT_EXPORT ~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 //
48 class TransitionRequestManager { 48 class TransitionRequestManager {
49 public: 49 public:
50 // Returns the singleton instance. 50 // Returns the singleton instance.
51 CONTENT_EXPORT static TransitionRequestManager* GetInstance(); 51 CONTENT_EXPORT static TransitionRequestManager* GetInstance();
52 52
53 // Parses out any transition-entering-stylesheet link headers from the 53 // Parses out any transition-entering-stylesheet link headers from the
54 // response headers. 54 // response headers.
55 CONTENT_EXPORT static void ParseTransitionStylesheetsFromHeaders( 55 CONTENT_EXPORT static void ParseTransitionStylesheetsFromHeaders(
56 const scoped_refptr<net::HttpResponseHeaders>& headers, 56 const scoped_refptr<net::HttpResponseHeaders>& headers,
57 std::vector<GURL>& entering_stylesheets, 57 std::vector<GURL>& entering_stylesheets,
58 const GURL& resolve_address); 58 const GURL& resolve_address);
59 59
60 // Returns whether the RenderFrameHost specified by the given IDs currently 60 // Get pending transition request data from RenderFrameHost specified by the
61 // has any pending transition request data. If so, we will have to delay the 61 // given IDs and return true if the data exists. For web to web transition, we
62 // response until the embedder resumes the request. 62 // will have to delay the response until the embedder resumes the request if
63 CONTENT_EXPORT bool HasPendingTransitionRequest( 63 // the data exists.
64 CONTENT_EXPORT bool GetPendingTransitionRequest(
64 int render_process_id, 65 int render_process_id,
65 int render_frame_id, 66 int render_frame_id,
66 const GURL& request_url, 67 const GURL& request_url,
67 TransitionLayerData* transition_data); 68 TransitionLayerData* transition_data);
68 69
69 // Adds pending request data for a transition navigation for the 70 // Adds pending request data for a transition navigation for the
70 // RenderFrameHost specified by the given IDs. 71 // RenderFrameHost specified by the given IDs.
71 CONTENT_EXPORT void AddPendingTransitionRequestData( 72 CONTENT_EXPORT void AddPendingTransitionRequestData(
72 int render_process_id, 73 int render_process_id,
73 int render_frame_id, 74 int render_frame_id,
74 const std::string& allowed_destination_host_pattern, 75 const std::string& allowed_destination_host_pattern,
75 const std::string& css_selector, 76 const std::string& css_selector,
76 const std::string& markup, 77 const std::string& markup,
77 const std::vector<std::string>& names, 78 const std::vector<TransitionElement>& elements);
78 const std::vector<gfx::Rect>& rects);
79 CONTENT_EXPORT void AddPendingTransitionRequestDataForTesting( 79 CONTENT_EXPORT void AddPendingTransitionRequestDataForTesting(
80 int render_process_id, 80 int render_process_id,
81 int render_frame_id); 81 int render_frame_id);
82 82
83 CONTENT_EXPORT void ClearPendingTransitionRequestData(int render_process_id, 83 CONTENT_EXPORT void ClearPendingTransitionRequestData(int render_process_id,
84 int render_frame_id); 84 int render_frame_id);
85 85
86 // The maximum number of elements is meant to avoid passing arbitrarily large
87 // amount of objects across the IPC boundary.
88 static const int kMaxNumOfElements = 1024;
89
86 private: 90 private:
87 class TransitionRequestData { 91 class TransitionRequestData {
88 public: 92 public:
89 TransitionRequestData(); 93 TransitionRequestData();
90 ~TransitionRequestData(); 94 ~TransitionRequestData();
91 void AddEntry(const std::string& allowed_destination_host_pattern, 95 void AddEntry(const std::string& allowed_destination_host_pattern,
92 const std::string& selector, 96 const std::string& selector,
93 const std::string& markup, 97 const std::string& markup,
94 const std::vector<std::string>& names, 98 const std::vector<TransitionElement>& elements);
95 const std::vector<gfx::Rect>& rects);
96 bool FindEntry(const GURL& request_url, 99 bool FindEntry(const GURL& request_url,
97 TransitionLayerData* transition_data); 100 TransitionLayerData* transition_data);
98 101
99 private: 102 private:
100 struct AllowedEntry { 103 struct AllowedEntry {
101 // These strings could have originated from a compromised renderer, 104 // These strings could have originated from a compromised renderer,
102 // and should not be trusted or assumed safe. They are only used within 105 // and should not be trusted or assumed safe. They are only used within
103 // a sandboxed iframe with scripts disabled. 106 // a sandboxed iframe with scripts disabled.
104 std::string allowed_destination_host_pattern; 107 std::string allowed_destination_host_pattern;
105 std::string css_selector; 108 std::string css_selector;
106 std::string markup; 109 std::string markup;
107 std::vector<std::string> names; 110 std::vector<TransitionElement> elements;
108 std::vector<gfx::Rect> rects;
109 111
110 AllowedEntry(const std::string& allowed_destination_host_pattern, 112 AllowedEntry(const std::string& allowed_destination_host_pattern,
111 const std::string& css_selector, 113 const std::string& css_selector,
112 const std::string& markup, 114 const std::string& markup,
113 const std::vector<std::string>& names, 115 const std::vector<TransitionElement>& elements);
114 const std::vector<gfx::Rect>& rects);
115 ~AllowedEntry(); 116 ~AllowedEntry();
116 }; 117 };
117 std::vector<AllowedEntry> allowed_entries_; 118 std::vector<AllowedEntry> allowed_entries_;
118 }; 119 };
119 120
120 friend struct DefaultSingletonTraits<TransitionRequestManager>; 121 friend struct DefaultSingletonTraits<TransitionRequestManager>;
121 typedef std::map<std::pair<int, int>, TransitionRequestData> 122 typedef std::map<std::pair<int, int>, TransitionRequestData>
122 RenderFrameRequestDataMap; 123 RenderFrameRequestDataMap;
123 124
124 TransitionRequestManager(); 125 TransitionRequestManager();
125 ~TransitionRequestManager(); 126 ~TransitionRequestManager();
126 127
127 // Map of (render_process_host_id, render_frame_id) pairs of all 128 // Map of (render_process_host_id, render_frame_id) pairs of all
128 // RenderFrameHosts that have pending cross-site requests and their data. 129 // RenderFrameHosts that have pending cross-site requests and their data.
129 // Used to pass information to the CrossSiteResourceHandler without doing a 130 // Used to pass information to the CrossSiteResourceHandler without doing a
130 // round-trip between IO->UI->IO threads. 131 // round-trip between IO->UI->IO threads.
131 RenderFrameRequestDataMap pending_transition_frames_; 132 RenderFrameRequestDataMap pending_transition_frames_;
132 133
133 DISALLOW_COPY_AND_ASSIGN(TransitionRequestManager); 134 DISALLOW_COPY_AND_ASSIGN(TransitionRequestManager);
134 }; 135 };
135 136
136 } // namespace content 137 } // namespace content
137 138
138 #endif // CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ 139 #endif // CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/transition_browsertest.cc ('k') | content/browser/transition_request_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698