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

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

Issue 435833002: Navigation transitions: Plumb data from the outgoing renderer to the incoming renderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes Created 6 years, 4 months 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 | Annotate | Revision Log
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 <set> 8 #include <map>
9 #include <string>
9 #include <utility> 10 #include <utility>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/basictypes.h" 13 #include "base/basictypes.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
17 template <typename T> 18 template <typename T>
18 struct DefaultSingletonTraits; 19 struct DefaultSingletonTraits;
19 20
20 namespace net { 21 namespace net {
21 class HttpResponseHeaders; 22 class HttpResponseHeaders;
22 } 23 }
24 class GURL;
23 25
24 namespace content { 26 namespace content {
25 27
28 // This struct passes data about an imminent transition between threads.
29 struct TransitionLayerData {
30 TransitionLayerData();
31 ~TransitionLayerData();
32
33 std::string markup;
34 std::string css_selector;
35 scoped_refptr<net::HttpResponseHeaders> response_headers;
36 GURL request_url;
37 };
38
26 // TransitionRequestManager is used to handle bookkeeping for transition 39 // TransitionRequestManager is used to handle bookkeeping for transition
27 // requests and responses. 40 // requests and responses.
28 // 41 //
29 // TransitionRequestManager is a singleton and should only be accessed on the IO 42 // TransitionRequestManager is a singleton and should only be accessed on the IO
30 // thread. 43 // thread.
31 // 44 //
32 class TransitionRequestManager { 45 class TransitionRequestManager {
33 public: 46 public:
34 // Returns the singleton instance. 47 // Returns the singleton instance.
35 CONTENT_EXPORT static TransitionRequestManager* GetInstance(); 48 CONTENT_EXPORT static TransitionRequestManager* GetInstance();
36 49
37 // Parses out any transition-entering-stylesheet link headers from the 50 // Parses out any transition-entering-stylesheet link headers from the
38 // response headers. 51 // response headers.
39 CONTENT_EXPORT static void ParseTransitionStylesheetsFromHeaders( 52 CONTENT_EXPORT static void ParseTransitionStylesheetsFromHeaders(
40 const scoped_refptr<net::HttpResponseHeaders>& headers, 53 const scoped_refptr<net::HttpResponseHeaders>& headers,
41 std::vector<GURL>& entering_stylesheets, 54 std::vector<GURL>& entering_stylesheets,
42 const GURL& resolve_address); 55 const GURL& resolve_address);
43 56
44 // Returns whether the RenderFrameHost specified by the given IDs currently 57 // Returns whether the RenderFrameHost specified by the given IDs currently
45 // has a pending transition request. If so, we will have to delay the 58 // has any pending transition request data. If so, we will have to delay the
46 // response until the embedder resumes the request. 59 // response until the embedder resumes the request.
47 bool HasPendingTransitionRequest(int process_id, int render_frame_id); 60 bool HasPendingTransitionRequest(int render_process_id,
61 int render_frame_id,
62 const GURL& request_url,
63 TransitionLayerData* transition_data);
48 64
49 // Sets whether the RenderFrameHost specified by the given IDs currently has a 65 // Adds pending request data for a transition navigation for the
50 // pending transition request. 66 // RenderFrameHost specified by the given IDs.
51 CONTENT_EXPORT void SetHasPendingTransitionRequest(int process_id, 67 CONTENT_EXPORT void AddPendingTransitionRequestData(
52 int render_frame_id, 68 int render_process_id,
53 bool has_pending); 69 int render_frame_id,
70 const std::string& origin,
71 const std::string& css_selector,
72 const std::string& markup);
73
74 void ClearPendingTransitionRequestData(int render_process_id,
75 int render_frame_id);
54 76
55 private: 77 private:
78 class TransitionRequestData {
79 public:
80 TransitionRequestData();
81 ~TransitionRequestData();
82 void AddEntry(const std::string& origin,
83 const std::string& selector,
84 const std::string& markup);
85 bool FindEntry(const GURL& request_url,
86 TransitionLayerData* transition_data);
87
88 private:
89 struct AllowedEntry {
90 // These strings could have originated from a compromised renderer,
Charlie Reis 2014/08/05 20:58:14 Need 2 space indent here as well.
oystein (OOO til 10th of July) 2014/08/06 22:36:19 Done.
91 // and should not be trusted or assumed safe.
Charlie Reis 2014/08/05 20:58:14 I like your explanation in the review comment. Le
oystein (OOO til 10th of July) 2014/08/06 22:36:19 Done.
92 std::string origin;
93 std::string css_selector;
94 std::string markup;
95
96 AllowedEntry(const std::string& origin,
97 const std::string& css_selector,
98 const std::string& markup) :
99 origin(origin),
100 css_selector(css_selector),
101 markup(markup) {}
102 };
103 std::vector<AllowedEntry> allowed_entries_;
104 };
105
56 friend struct DefaultSingletonTraits<TransitionRequestManager>; 106 friend struct DefaultSingletonTraits<TransitionRequestManager>;
57 typedef std::set<std::pair<int, int> > RenderFrameSet; 107 typedef std::map<std::pair<int, int>, TransitionRequestData>
108 RenderFrameRequestDataMap;
58 109
59 TransitionRequestManager(); 110 TransitionRequestManager();
60 ~TransitionRequestManager(); 111 ~TransitionRequestManager();
61 112
62 // Set of (render_process_host_id, render_frame_id) pairs of all 113 // Map of (render_process_host_id, render_frame_id) pairs of all
63 // RenderFrameHosts that have pending transition requests. Used to pass 114 // RenderFrameHosts that have pending cross-site requests and their data.
64 // information to the CrossSiteResourceHandler without doing a round-trip 115 // Used to pass information to the CrossSiteResourceHandler without doing a
65 // between IO->UI->IO threads. 116 // round-trip between IO->UI->IO threads.
66 RenderFrameSet pending_transition_frames_; 117 RenderFrameRequestDataMap pending_transition_frames_;
67 118
68 DISALLOW_COPY_AND_ASSIGN(TransitionRequestManager); 119 DISALLOW_COPY_AND_ASSIGN(TransitionRequestManager);
69 }; 120 };
70 121
71 } // namespace content 122 } // namespace content
72 123
73 #endif // CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_ 124 #endif // CONTENT_BROWSER_TRANSITION_REQUEST_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698