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

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

Issue 652283002: Navigation transitions (web to native app): Get names and rects of transition elements (Chrome side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use struct as IPC params Created 6 years, 2 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
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 #include "content/browser/transition_request_manager.h" 5 #include "content/browser/transition_request_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } // namespace 75 } // namespace
76 76
77 namespace content { 77 namespace content {
78 78
79 TransitionLayerData::TransitionLayerData() { 79 TransitionLayerData::TransitionLayerData() {
80 } 80 }
81 81
82 TransitionLayerData::~TransitionLayerData() { 82 TransitionLayerData::~TransitionLayerData() {
83 } 83 }
84 84
85 TransitionRequestManager::TransitionRequestData::AllowedEntry::AllowedEntry(
86 const std::string& allowed_destination_host_pattern,
87 const std::string& css_selector,
88 const std::string& markup,
89 const std::vector<std::string>& names,
90 const std::vector<gfx::Rect>& rects)
91 : allowed_destination_host_pattern(allowed_destination_host_pattern),
92 css_selector(css_selector),
93 markup(markup),
94 names(names),
95 rects(rects) {
96 }
97
98 TransitionRequestManager::TransitionRequestData::AllowedEntry::~AllowedEntry() {
99 }
100
85 void TransitionRequestManager::ParseTransitionStylesheetsFromHeaders( 101 void TransitionRequestManager::ParseTransitionStylesheetsFromHeaders(
86 const scoped_refptr<net::HttpResponseHeaders>& headers, 102 const scoped_refptr<net::HttpResponseHeaders>& headers,
87 std::vector<GURL>& entering_stylesheets, 103 std::vector<GURL>& entering_stylesheets,
88 const GURL& resolve_address) { 104 const GURL& resolve_address) {
89 if (headers.get() == NULL) 105 if (headers.get() == NULL)
90 return; 106 return;
91 107
92 std::string transition_stylesheet; 108 std::string transition_stylesheet;
93 base::StringPairs attributes; 109 base::StringPairs attributes;
94 void* header_iter = NULL; 110 void* header_iter = NULL;
(...skipping 10 matching lines...) Expand all
105 121
106 TransitionRequestManager::TransitionRequestData::TransitionRequestData() { 122 TransitionRequestManager::TransitionRequestData::TransitionRequestData() {
107 } 123 }
108 124
109 TransitionRequestManager::TransitionRequestData::~TransitionRequestData() { 125 TransitionRequestManager::TransitionRequestData::~TransitionRequestData() {
110 } 126 }
111 127
112 void TransitionRequestManager::TransitionRequestData::AddEntry( 128 void TransitionRequestManager::TransitionRequestData::AddEntry(
113 const std::string& allowed_destination_host_pattern, 129 const std::string& allowed_destination_host_pattern,
114 const std::string& css_selector, 130 const std::string& css_selector,
115 const std::string& markup) { 131 const std::string& markup,
132 const std::vector<std::string>& names,
133 const std::vector<gfx::Rect>& rects) {
116 allowed_entries_.push_back(AllowedEntry(allowed_destination_host_pattern, 134 allowed_entries_.push_back(AllowedEntry(allowed_destination_host_pattern,
117 css_selector, 135 css_selector,
118 markup)); 136 markup,
137 names,
138 rects));
119 } 139 }
120 140
121 bool TransitionRequestManager::TransitionRequestData::FindEntry( 141 bool TransitionRequestManager::TransitionRequestData::FindEntry(
122 const GURL& request_url, 142 const GURL& request_url,
123 TransitionLayerData* transition_data) { 143 TransitionLayerData* transition_data) {
124 DCHECK(!allowed_entries_.empty()); 144 DCHECK(!allowed_entries_.empty());
125 CHECK(transition_data); 145 CHECK(transition_data);
126 // TODO(oysteine): Add CSP check to validate the host pattern and the 146 // TODO(oysteine): Add CSP check to validate the host pattern and the
127 // request_url. Must be done before this feature is moved out from the flag. 147 // request_url. Must be done before this feature is moved out from the flag.
128 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( 148 CHECK(CommandLine::ForCurrentProcess()->HasSwitch(
129 switches::kEnableExperimentalWebPlatformFeatures) || 149 switches::kEnableExperimentalWebPlatformFeatures) ||
130 base::FieldTrialList::FindFullName("NavigationTransitions") == 150 base::FieldTrialList::FindFullName("NavigationTransitions") ==
131 "Enabled"); 151 "Enabled");
132 152
133 const AllowedEntry& allowed_entry = allowed_entries_[0]; 153 const AllowedEntry& allowed_entry = allowed_entries_[0];
134 transition_data->markup = allowed_entry.markup; 154 transition_data->markup = allowed_entry.markup;
135 transition_data->css_selector = allowed_entry.css_selector; 155 transition_data->css_selector = allowed_entry.css_selector;
156 transition_data->names = allowed_entry.names;
157 transition_data->rects = allowed_entry.rects;
136 return true; 158 return true;
137 } 159 }
138 160
139 bool TransitionRequestManager::HasPendingTransitionRequest( 161 bool TransitionRequestManager::HasPendingTransitionRequest(
140 int render_process_id, 162 int render_process_id,
141 int render_frame_id, 163 int render_frame_id,
142 const GURL& request_url, 164 const GURL& request_url,
143 TransitionLayerData* transition_data) { 165 TransitionLayerData* transition_data) {
144 DCHECK_CURRENTLY_ON(BrowserThread::IO); 166 DCHECK_CURRENTLY_ON(BrowserThread::IO);
145 DCHECK(transition_data); 167 DCHECK(transition_data);
146 std::pair<int, int> key(render_process_id, render_frame_id); 168 std::pair<int, int> key(render_process_id, render_frame_id);
147 RenderFrameRequestDataMap::iterator iter = 169 RenderFrameRequestDataMap::iterator iter =
148 pending_transition_frames_.find(key); 170 pending_transition_frames_.find(key);
149 return iter != pending_transition_frames_.end() && 171 return iter != pending_transition_frames_.end() &&
150 iter->second.FindEntry(request_url, transition_data); 172 iter->second.FindEntry(request_url, transition_data);
151 } 173 }
152 174
153 void TransitionRequestManager::AddPendingTransitionRequestData( 175 void TransitionRequestManager::AddPendingTransitionRequestData(
154 int render_process_id, 176 int render_process_id,
155 int render_frame_id, 177 int render_frame_id,
156 const std::string& allowed_destination_host_pattern, 178 const std::string& allowed_destination_host_pattern,
157 const std::string& css_selector, 179 const std::string& css_selector,
158 const std::string& markup) { 180 const std::string& markup,
181 const std::vector<std::string>& names,
182 const std::vector<gfx::Rect>& rects) {
159 DCHECK_CURRENTLY_ON(BrowserThread::IO); 183 DCHECK_CURRENTLY_ON(BrowserThread::IO);
160 184
161 std::pair<int, int> key(render_process_id, render_frame_id); 185 std::pair<int, int> key(render_process_id, render_frame_id);
162 pending_transition_frames_[key].AddEntry(allowed_destination_host_pattern, 186 pending_transition_frames_[key].AddEntry(
163 css_selector, 187 allowed_destination_host_pattern, css_selector, markup, names, rects);
164 markup); 188 }
189
190 void TransitionRequestManager::AddPendingTransitionRequestDataForTesting(
191 int render_process_id,
192 int render_frame_id) {
193 DCHECK_CURRENTLY_ON(BrowserThread::IO);
194
195 std::pair<int, int> key(render_process_id, render_frame_id);
196 pending_transition_frames_[key].AddEntry(
197 "*", /* allowed_destination_host_pattern */
198 "", /* css_selector */
199 "", /* markup */
200 std::vector<std::string>(), /* names */
201 std::vector<gfx::Rect>()); /* rects */
nasko 2014/10/17 20:04:19 It seems strange to me to hardcode those in this m
Zhen Wang 2014/10/17 21:34:29 This is because it is used in WebContentsAndroid::
nasko 2014/10/20 14:14:18 How would you test non "*" pattern then?
165 } 202 }
166 203
167 void TransitionRequestManager::ClearPendingTransitionRequestData( 204 void TransitionRequestManager::ClearPendingTransitionRequestData(
168 int render_process_id, int render_frame_id) { 205 int render_process_id, int render_frame_id) {
169 DCHECK_CURRENTLY_ON(BrowserThread::IO); 206 DCHECK_CURRENTLY_ON(BrowserThread::IO);
170 std::pair<int, int> key(render_process_id, render_frame_id); 207 std::pair<int, int> key(render_process_id, render_frame_id);
171 pending_transition_frames_.erase(key); 208 pending_transition_frames_.erase(key);
172 } 209 }
173 210
174 TransitionRequestManager::TransitionRequestManager() { 211 TransitionRequestManager::TransitionRequestManager() {
175 } 212 }
176 213
177 TransitionRequestManager::~TransitionRequestManager() { 214 TransitionRequestManager::~TransitionRequestManager() {
178 } 215 }
179 216
180 // static 217 // static
181 TransitionRequestManager* TransitionRequestManager::GetInstance() { 218 TransitionRequestManager* TransitionRequestManager::GetInstance() {
182 return Singleton<TransitionRequestManager>::get(); 219 return Singleton<TransitionRequestManager>::get();
183 } 220 }
184 221
185 } // namespace content 222 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698