summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/loader/cross_site_resource_handler.cc2
-rw-r--r--content/browser/renderer_host/render_message_filter.cc5
-rw-r--r--content/browser/transition_browsertest.cc2
-rw-r--r--content/browser/transition_request_manager.cc25
-rw-r--r--content/browser/transition_request_manager.h29
-rw-r--r--content/common/frame_messages.h23
-rw-r--r--content/content_common.gypi1
-rw-r--r--content/public/common/transition_element.h23
-rw-r--r--content/renderer/render_frame_impl.cc7
9 files changed, 70 insertions, 47 deletions
diff --git a/content/browser/loader/cross_site_resource_handler.cc b/content/browser/loader/cross_site_resource_handler.cc
index 596cf62..2ec5ee5 100644
--- a/content/browser/loader/cross_site_resource_handler.cc
+++ b/content/browser/loader/cross_site_resource_handler.cc
@@ -150,7 +150,7 @@ bool CrossSiteResourceHandler::OnResponseStarted(
TransitionLayerData transition_data;
bool is_navigation_transition =
- TransitionRequestManager::GetInstance()->HasPendingTransitionRequest(
+ TransitionRequestManager::GetInstance()->GetPendingTransitionRequest(
info->GetChildID(), info->GetRenderFrameID(), request()->url(),
&transition_data);
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 27ad9c8..0474e08 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -1230,14 +1230,15 @@ void RenderMessageFilter::OnWebAudioMediaCodec(
void RenderMessageFilter::OnAddNavigationTransitionData(
FrameHostMsg_AddNavigationTransitionData_Params params) {
+ if (params.elements.size() > TransitionRequestManager::kMaxNumOfElements)
+ return;
TransitionRequestManager::GetInstance()->AddPendingTransitionRequestData(
render_process_id_,
params.render_frame_id,
params.allowed_destination_host_pattern,
params.selector,
params.markup,
- params.names,
- params.rects);
+ params.elements);
}
void RenderMessageFilter::OnAllocateGpuMemoryBuffer(
diff --git a/content/browser/transition_browsertest.cc b/content/browser/transition_browsertest.cc
index 147e771..1fba073 100644
--- a/content/browser/transition_browsertest.cc
+++ b/content/browser/transition_browsertest.cc
@@ -86,7 +86,7 @@ class TransitionBrowserTestObserver
ResourceRequestInfoImpl::ForRequest(request_);
TransitionLayerData transition_data;
did_clear_data_ = !TransitionRequestManager::GetInstance(
- )->HasPendingTransitionRequest(info->GetChildID(),
+ )->GetPendingTransitionRequest(info->GetChildID(),
info->GetRenderFrameID(),
request_->url(),
&transition_data);
diff --git a/content/browser/transition_request_manager.cc b/content/browser/transition_request_manager.cc
index b863991..e3f4317 100644
--- a/content/browser/transition_request_manager.cc
+++ b/content/browser/transition_request_manager.cc
@@ -86,13 +86,11 @@ TransitionRequestManager::TransitionRequestData::AllowedEntry::AllowedEntry(
const std::string& allowed_destination_host_pattern,
const std::string& css_selector,
const std::string& markup,
- const std::vector<std::string>& names,
- const std::vector<gfx::Rect>& rects)
+ const std::vector<TransitionElement>& elements)
: allowed_destination_host_pattern(allowed_destination_host_pattern),
css_selector(css_selector),
markup(markup),
- names(names),
- rects(rects) {
+ elements(elements) {
}
TransitionRequestManager::TransitionRequestData::AllowedEntry::~AllowedEntry() {
@@ -129,13 +127,11 @@ void TransitionRequestManager::TransitionRequestData::AddEntry(
const std::string& allowed_destination_host_pattern,
const std::string& css_selector,
const std::string& markup,
- const std::vector<std::string>& names,
- const std::vector<gfx::Rect>& rects) {
+ const std::vector<TransitionElement>& elements) {
allowed_entries_.push_back(AllowedEntry(allowed_destination_host_pattern,
css_selector,
markup,
- names,
- rects));
+ elements));
}
bool TransitionRequestManager::TransitionRequestData::FindEntry(
@@ -153,12 +149,11 @@ bool TransitionRequestManager::TransitionRequestData::FindEntry(
const AllowedEntry& allowed_entry = allowed_entries_[0];
transition_data->markup = allowed_entry.markup;
transition_data->css_selector = allowed_entry.css_selector;
- transition_data->names = allowed_entry.names;
- transition_data->rects = allowed_entry.rects;
+ transition_data->elements = allowed_entry.elements;
return true;
}
-bool TransitionRequestManager::HasPendingTransitionRequest(
+bool TransitionRequestManager::GetPendingTransitionRequest(
int render_process_id,
int render_frame_id,
const GURL& request_url,
@@ -178,13 +173,12 @@ void TransitionRequestManager::AddPendingTransitionRequestData(
const std::string& allowed_destination_host_pattern,
const std::string& css_selector,
const std::string& markup,
- const std::vector<std::string>& names,
- const std::vector<gfx::Rect>& rects) {
+ const std::vector<TransitionElement>& elements) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
std::pair<int, int> key(render_process_id, render_frame_id);
pending_transition_frames_[key].AddEntry(
- allowed_destination_host_pattern, css_selector, markup, names, rects);
+ allowed_destination_host_pattern, css_selector, markup, elements);
}
void TransitionRequestManager::AddPendingTransitionRequestDataForTesting(
@@ -197,8 +191,7 @@ void TransitionRequestManager::AddPendingTransitionRequestDataForTesting(
"*", /* allowed_destination_host_pattern */
"", /* css_selector */
"", /* markup */
- std::vector<std::string>(), /* names */
- std::vector<gfx::Rect>()); /* rects */
+ std::vector<TransitionElement>()); /* elements */
}
void TransitionRequestManager::ClearPendingTransitionRequestData(
diff --git a/content/browser/transition_request_manager.h b/content/browser/transition_request_manager.h
index 3db4d87..65b5792 100644
--- a/content/browser/transition_request_manager.h
+++ b/content/browser/transition_request_manager.h
@@ -13,6 +13,7 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
+#include "content/public/common/transition_element.h"
#include "ui/gfx/geometry/rect.h"
#include "url/gurl.h"
@@ -33,8 +34,7 @@ struct TransitionLayerData {
std::string markup;
std::string css_selector;
- std::vector<std::string> names;
- std::vector<gfx::Rect> rects;
+ std::vector<TransitionElement> elements;
scoped_refptr<net::HttpResponseHeaders> response_headers;
GURL request_url;
};
@@ -57,10 +57,11 @@ class TransitionRequestManager {
std::vector<GURL>& entering_stylesheets,
const GURL& resolve_address);
- // Returns whether the RenderFrameHost specified by the given IDs currently
- // has any pending transition request data. If so, we will have to delay the
- // response until the embedder resumes the request.
- CONTENT_EXPORT bool HasPendingTransitionRequest(
+ // Get pending transition request data from RenderFrameHost specified by the
+ // given IDs and return true if the data exists. For web to web transition, we
+ // will have to delay the response until the embedder resumes the request if
+ // the data exists.
+ CONTENT_EXPORT bool GetPendingTransitionRequest(
int render_process_id,
int render_frame_id,
const GURL& request_url,
@@ -74,8 +75,7 @@ class TransitionRequestManager {
const std::string& allowed_destination_host_pattern,
const std::string& css_selector,
const std::string& markup,
- const std::vector<std::string>& names,
- const std::vector<gfx::Rect>& rects);
+ const std::vector<TransitionElement>& elements);
CONTENT_EXPORT void AddPendingTransitionRequestDataForTesting(
int render_process_id,
int render_frame_id);
@@ -83,6 +83,10 @@ class TransitionRequestManager {
CONTENT_EXPORT void ClearPendingTransitionRequestData(int render_process_id,
int render_frame_id);
+ // The maximum number of elements is meant to avoid passing arbitrarily large
+ // amount of objects across the IPC boundary.
+ static const int kMaxNumOfElements = 1024;
+
private:
class TransitionRequestData {
public:
@@ -91,8 +95,7 @@ class TransitionRequestManager {
void AddEntry(const std::string& allowed_destination_host_pattern,
const std::string& selector,
const std::string& markup,
- const std::vector<std::string>& names,
- const std::vector<gfx::Rect>& rects);
+ const std::vector<TransitionElement>& elements);
bool FindEntry(const GURL& request_url,
TransitionLayerData* transition_data);
@@ -104,14 +107,12 @@ class TransitionRequestManager {
std::string allowed_destination_host_pattern;
std::string css_selector;
std::string markup;
- std::vector<std::string> names;
- std::vector<gfx::Rect> rects;
+ std::vector<TransitionElement> elements;
AllowedEntry(const std::string& allowed_destination_host_pattern,
const std::string& css_selector,
const std::string& markup,
- const std::vector<std::string>& names,
- const std::vector<gfx::Rect>& rects);
+ const std::vector<TransitionElement>& elements);
~AllowedEntry();
};
std::vector<AllowedEntry> allowed_entries_;
diff --git a/content/common/frame_messages.h b/content/common/frame_messages.h
index 6d1d71c..7d03f8c5 100644
--- a/content/common/frame_messages.h
+++ b/content/common/frame_messages.h
@@ -19,6 +19,7 @@
#include "content/public/common/javascript_message_type.h"
#include "content/public/common/page_state.h"
#include "content/public/common/resource_response.h"
+#include "content/public/common/transition_element.h"
#include "ipc/ipc_message_macros.h"
#include "ui/gfx/ipc/gfx_param_traits.h"
#include "url/gurl.h"
@@ -89,6 +90,19 @@ IPC_STRUCT_TRAITS_BEGIN(content::CustomContextMenuContext)
IPC_STRUCT_TRAITS_MEMBER(link_followed)
IPC_STRUCT_TRAITS_END()
+IPC_STRUCT_TRAITS_BEGIN(content::TransitionElement)
+ IPC_STRUCT_TRAITS_MEMBER(name)
+ IPC_STRUCT_TRAITS_MEMBER(rect)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_BEGIN(FrameHostMsg_AddNavigationTransitionData_Params)
+ IPC_STRUCT_MEMBER(int, render_frame_id)
+ IPC_STRUCT_MEMBER(std::string, allowed_destination_host_pattern)
+ IPC_STRUCT_MEMBER(std::string, selector)
+ IPC_STRUCT_MEMBER(std::string, markup)
+ IPC_STRUCT_MEMBER(std::vector<content::TransitionElement>, elements)
+IPC_STRUCT_END()
+
IPC_STRUCT_BEGIN(FrameHostMsg_DidFailProvisionalLoadWithError_Params)
// Error code as reported in the DidFailProvisionalLoad callback.
IPC_STRUCT_MEMBER(int, error_code)
@@ -262,15 +276,6 @@ IPC_STRUCT_BEGIN(FrameMsg_Navigate_Params)
IPC_STRUCT_MEMBER(std::string, frame_to_navigate)
IPC_STRUCT_END()
-IPC_STRUCT_BEGIN(FrameHostMsg_AddNavigationTransitionData_Params)
- IPC_STRUCT_MEMBER(int, render_frame_id)
- IPC_STRUCT_MEMBER(std::string, allowed_destination_host_pattern)
- IPC_STRUCT_MEMBER(std::string, selector)
- IPC_STRUCT_MEMBER(std::string, markup)
- IPC_STRUCT_MEMBER(std::vector<std::string>, names)
- IPC_STRUCT_MEMBER(std::vector<gfx::Rect>, rects)
-IPC_STRUCT_END()
-
IPC_STRUCT_BEGIN(FrameHostMsg_OpenURL_Params)
IPC_STRUCT_MEMBER(GURL, url)
IPC_STRUCT_MEMBER(content::Referrer, referrer)
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 447007cd..6d9a28d 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -125,6 +125,7 @@
'public/common/three_d_api_types.h',
'public/common/top_controls_state.h',
'public/common/top_controls_state_list.h',
+ 'public/common/transition_element.h',
'public/common/url_constants.cc',
'public/common/url_constants.h',
'public/common/url_fetcher.h',
diff --git a/content/public/common/transition_element.h b/content/public/common/transition_element.h
new file mode 100644
index 0000000..d8168b8
--- /dev/null
+++ b/content/public/common/transition_element.h
@@ -0,0 +1,23 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_COMMON_TRANSITION_ELEMENT_H_
+#define CONTENT_PUBLIC_COMMON_TRANSITION_ELEMENT_H_
+
+#include <string>
+
+#include "content/common/content_export.h"
+#include "ui/gfx/geometry/rect.h"
+
+namespace content {
+
+// This struct stores the information of one transition element.
+struct CONTENT_EXPORT TransitionElement {
+ std::string name;
+ gfx::Rect rect;
+};
+
+} // namespace content
+
+#endif // CONTENT_PUBLIC_COMMON_TRANSITION_ELEMENT_H_
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 65a2c42..6088aba 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -2586,11 +2586,10 @@ void RenderFrameImpl::addNavigationTransitionData(
allowed_destination_host_pattern.utf8();
params.selector = selector.utf8();
params.markup = markup.utf8();
+ params.elements.resize(web_names.size());
for (size_t i = 0; i < web_names.size(); i++) {
- params.names.push_back(web_names[i].utf8());
- }
- for (size_t i = 0; i < web_rects.size(); i++) {
- params.rects.push_back(gfx::Rect(web_rects[i]));
+ params.elements[i].name = web_names[i].utf8();
+ params.elements[i].rect = gfx::Rect(web_rects[i]);
}
Send(new FrameHostMsg_AddNavigationTransitionData(params));