Revert revision 1765 changes due to broken sub-frame loading.
- Move LoadRequest execution to the browser process and use data: URLs for LoadString (issue #579). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1780 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
18f634c11f
commit
b34963b743
|
@ -26,4 +26,3 @@ Corey Lucier <clucier@adobe.com>
|
||||||
Mihai Tica <mitica@adobe.com>
|
Mihai Tica <mitica@adobe.com>
|
||||||
Czarek Tomczak <czarek.tomczak@gmail.com>
|
Czarek Tomczak <czarek.tomczak@gmail.com>
|
||||||
Felix Bruns <felixbruns@spotify.com>
|
Felix Bruns <felixbruns@spotify.com>
|
||||||
Gonzo Berman <gberman@factset.com>
|
|
||||||
|
|
2
cef.gyp
2
cef.gyp
|
@ -932,6 +932,8 @@
|
||||||
'libcef/browser/menu_creator.h',
|
'libcef/browser/menu_creator.h',
|
||||||
'libcef/browser/menu_model_impl.cc',
|
'libcef/browser/menu_model_impl.cc',
|
||||||
'libcef/browser/menu_model_impl.h',
|
'libcef/browser/menu_model_impl.h',
|
||||||
|
'libcef/browser/navigate_params.cc',
|
||||||
|
'libcef/browser/navigate_params.h',
|
||||||
'libcef/browser/origin_whitelist_impl.cc',
|
'libcef/browser/origin_whitelist_impl.cc',
|
||||||
'libcef/browser/origin_whitelist_impl.h',
|
'libcef/browser/origin_whitelist_impl.h',
|
||||||
'libcef/browser/path_util_impl.cc',
|
'libcef/browser/path_util_impl.cc',
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "libcef/browser/devtools_delegate.h"
|
#include "libcef/browser/devtools_delegate.h"
|
||||||
#include "libcef/browser/devtools_frontend.h"
|
#include "libcef/browser/devtools_frontend.h"
|
||||||
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
||||||
|
#include "libcef/browser/navigate_params.h"
|
||||||
#include "libcef/browser/printing/print_view_manager.h"
|
#include "libcef/browser/printing/print_view_manager.h"
|
||||||
#include "libcef/browser/render_widget_host_view_osr.h"
|
#include "libcef/browser/render_widget_host_view_osr.h"
|
||||||
#include "libcef/browser/request_context_impl.h"
|
#include "libcef/browser/request_context_impl.h"
|
||||||
|
@ -31,7 +32,6 @@
|
||||||
#include "libcef/common/process_message_impl.h"
|
#include "libcef/common/process_message_impl.h"
|
||||||
#include "libcef/common/request_impl.h"
|
#include "libcef/common/request_impl.h"
|
||||||
|
|
||||||
#include "base/base64.h"
|
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/bind_helpers.h"
|
#include "base/bind_helpers.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
|
@ -263,143 +263,6 @@ class CefRunFileDialogCallbackWrapper
|
||||||
CefRefPtr<CefRunFileDialogCallback> callback_;
|
CefRefPtr<CefRunFileDialogCallback> callback_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NavigationHelper {
|
|
||||||
public:
|
|
||||||
static content::NavigationController::LoadURLParams GetParams(
|
|
||||||
int64 frame_id,
|
|
||||||
const std::string& url) {
|
|
||||||
content::NavigationController::LoadURLParams params(
|
|
||||||
GetGURL(url));
|
|
||||||
params.frame_tree_node_id = frame_id;
|
|
||||||
params.transition_type = content::PAGE_TRANSITION_TYPED;
|
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
static content::NavigationController::LoadURLParams GetParams(
|
|
||||||
int64 frame_id,
|
|
||||||
CefRefPtr<CefRequest> request) {
|
|
||||||
content::NavigationController::LoadURLParams params(
|
|
||||||
GetGURL(request->GetURL()));
|
|
||||||
params.frame_tree_node_id = frame_id;
|
|
||||||
params.transition_type =
|
|
||||||
static_cast<content::PageTransition>(request->GetTransitionType());
|
|
||||||
params.extra_headers = GetHeaders(request);
|
|
||||||
|
|
||||||
if (request->GetMethod() == "POST") {
|
|
||||||
params.load_type =
|
|
||||||
content::NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
|
|
||||||
params.browser_initiated_post_data = GetPostData(request->GetPostData());
|
|
||||||
}
|
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
static content::NavigationController::LoadURLParams GetParams(
|
|
||||||
int64 frame_id,
|
|
||||||
const std::string& data,
|
|
||||||
const std::string& url) {
|
|
||||||
content::NavigationController::LoadURLParams params(GetDataURL(data));
|
|
||||||
params.frame_tree_node_id = frame_id;
|
|
||||||
params.load_type = content::NavigationController::LOAD_TYPE_DATA;
|
|
||||||
params.virtual_url_for_data_url = GURL(url);
|
|
||||||
params.base_url_for_data_url = GURL(url);
|
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
static content::NavigationController::LoadURLParams GetParams(
|
|
||||||
const content::OpenURLParams& content_params) {
|
|
||||||
GURL gurl = GetGURL(content_params.url.spec());
|
|
||||||
content::NavigationController::LoadURLParams params(gurl);
|
|
||||||
params.frame_tree_node_id = CefFrameHostImpl::kMainFrameId;
|
|
||||||
params.referrer = content_params.referrer;
|
|
||||||
params.transition_type = content_params.transition;
|
|
||||||
params.extra_headers = content_params.extra_headers;
|
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
static content::NavigationController::LoadURLParams GetParams(
|
|
||||||
const CefHostMsg_LoadRequest_Params& request_params) {
|
|
||||||
content::NavigationController::LoadURLParams params(request_params.url);
|
|
||||||
params.referrer.url = request_params.referrer;
|
|
||||||
params.referrer.policy =
|
|
||||||
static_cast<blink::WebReferrerPolicy>(request_params.referrer_policy);
|
|
||||||
params.frame_tree_node_id = request_params.frame_id;
|
|
||||||
params.extra_headers = request_params.headers;
|
|
||||||
if (request_params.method == "POST") {
|
|
||||||
params.load_type =
|
|
||||||
content::NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
|
|
||||||
params.browser_initiated_post_data =
|
|
||||||
GetPostData(request_params.upload_data);
|
|
||||||
}
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
static GURL GetDataURL(const std::string& data) {
|
|
||||||
std::string encoded_data;
|
|
||||||
base::Base64Encode(data, &encoded_data);
|
|
||||||
|
|
||||||
GURL gurl("data:text/html;charset=UTF-8;base64," + encoded_data);
|
|
||||||
return gurl;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GURL GetGURL(const std::string& url) {
|
|
||||||
GURL gurl(url);
|
|
||||||
|
|
||||||
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
|
||||||
// Try to add "http://" at the beginning
|
|
||||||
std::string new_url = std::string("http://") + url;
|
|
||||||
gurl = GURL(new_url);
|
|
||||||
}
|
|
||||||
|
|
||||||
return gurl;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string GetHeaders(CefRefPtr<CefRequest> request) {
|
|
||||||
CefRequest::HeaderMap headerMap;
|
|
||||||
request->GetHeaderMap(headerMap);
|
|
||||||
if (!headerMap.empty()) {
|
|
||||||
return HttpHeaderUtils::GenerateHeaders(headerMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
static base::RefCountedBytes* GetPostData(
|
|
||||||
CefRefPtr<CefPostData> postData) {
|
|
||||||
if (postData.get()) {
|
|
||||||
CefPostDataImpl* impl = static_cast<CefPostDataImpl*>(postData.get());
|
|
||||||
scoped_refptr<net::UploadData> upload_data = new net::UploadData();
|
|
||||||
impl->Get(*upload_data);
|
|
||||||
|
|
||||||
return GetPostData(upload_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static base::RefCountedBytes* GetPostData(
|
|
||||||
scoped_refptr<net::UploadData> upload_data) {
|
|
||||||
if (upload_data.get()) {
|
|
||||||
std::vector<unsigned char> body;
|
|
||||||
if (!upload_data->elements().empty()) {
|
|
||||||
const net::UploadElement* elem = upload_data->elements().front();
|
|
||||||
if (elem) {
|
|
||||||
body.insert(body.end(), elem->bytes(),
|
|
||||||
elem->bytes() + elem->bytes_length());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return base::RefCountedBytes::TakeVector(&body);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
|
@ -510,7 +373,8 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::Create(
|
||||||
CefBrowserHostImpl::CreateInternal(windowInfo, settings, client, NULL,
|
CefBrowserHostImpl::CreateInternal(windowInfo, settings, client, NULL,
|
||||||
info, opener, request_context);
|
info, opener, request_context);
|
||||||
if (browser && !url.empty()) {
|
if (browser && !url.empty()) {
|
||||||
browser->LoadURL(CefFrameHostImpl::kMainFrameId, url);
|
browser->LoadURL(CefFrameHostImpl::kMainFrameId, url, content::Referrer(),
|
||||||
|
content::PAGE_TRANSITION_TYPED, std::string());
|
||||||
}
|
}
|
||||||
return browser.get();
|
return browser.get();
|
||||||
}
|
}
|
||||||
|
@ -1576,18 +1440,122 @@ CefRefPtr<CefFrame> CefBrowserHostImpl::GetFrameForRequest(
|
||||||
GURL());
|
GURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserHostImpl::LoadRequest(int64 frame_id,
|
void CefBrowserHostImpl::Navigate(const CefNavigateParams& params) {
|
||||||
CefRefPtr<CefRequest> request) {
|
// Only known frame ids and kMainFrameId are supported.
|
||||||
Navigate(NavigationHelper::GetParams(frame_id, request));
|
DCHECK(params.frame_id >= CefFrameHostImpl::kMainFrameId);
|
||||||
|
|
||||||
|
CefMsg_LoadRequest_Params request;
|
||||||
|
request.url = params.url;
|
||||||
|
if (!request.url.is_valid()) {
|
||||||
|
LOG(ERROR) << "Invalid URL passed to CefBrowserHostImpl::Navigate: " <<
|
||||||
|
params.url;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
request.method = params.method;
|
||||||
|
request.referrer = params.referrer.url;
|
||||||
|
request.referrer_policy = params.referrer.policy;
|
||||||
|
request.frame_id = params.frame_id;
|
||||||
|
request.first_party_for_cookies = params.first_party_for_cookies;
|
||||||
|
request.headers = params.headers;
|
||||||
|
request.load_flags = params.load_flags;
|
||||||
|
request.upload_data = params.upload_data;
|
||||||
|
|
||||||
|
Send(new CefMsg_LoadRequest(routing_id(), request));
|
||||||
|
|
||||||
|
OnSetFocus(FOCUS_SOURCE_NAVIGATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserHostImpl::LoadURL(int64 frame_id, const std::string& url) {
|
void CefBrowserHostImpl::LoadRequest(int64 frame_id,
|
||||||
Navigate(NavigationHelper::GetParams(frame_id, url));
|
CefRefPtr<CefRequest> request) {
|
||||||
|
CefNavigateParams params(GURL(std::string(request->GetURL())),
|
||||||
|
content::PAGE_TRANSITION_TYPED);
|
||||||
|
params.method = request->GetMethod();
|
||||||
|
params.frame_id = frame_id;
|
||||||
|
params.first_party_for_cookies =
|
||||||
|
GURL(std::string(request->GetFirstPartyForCookies()));
|
||||||
|
|
||||||
|
CefRequest::HeaderMap headerMap;
|
||||||
|
request->GetHeaderMap(headerMap);
|
||||||
|
if (!headerMap.empty())
|
||||||
|
params.headers = HttpHeaderUtils::GenerateHeaders(headerMap);
|
||||||
|
|
||||||
|
CefRefPtr<CefPostData> postData = request->GetPostData();
|
||||||
|
if (postData.get()) {
|
||||||
|
CefPostDataImpl* impl = static_cast<CefPostDataImpl*>(postData.get());
|
||||||
|
params.upload_data = new net::UploadData();
|
||||||
|
impl->Get(*params.upload_data.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
params.load_flags = request->GetFlags();
|
||||||
|
|
||||||
|
Navigate(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserHostImpl::LoadURL(
|
||||||
|
int64 frame_id,
|
||||||
|
const std::string& url,
|
||||||
|
const content::Referrer& referrer,
|
||||||
|
content::PageTransition transition,
|
||||||
|
const std::string& extra_headers) {
|
||||||
|
if (frame_id == CefFrameHostImpl::kMainFrameId) {
|
||||||
|
// Go through the navigation controller.
|
||||||
|
if (CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
if (web_contents_.get()) {
|
||||||
|
GURL gurl = GURL(url);
|
||||||
|
|
||||||
|
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
||||||
|
// Try to add "http://" at the beginning
|
||||||
|
std::string new_url = std::string("http://") + url;
|
||||||
|
gurl = GURL(new_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gurl.is_valid()) {
|
||||||
|
LOG(ERROR) <<
|
||||||
|
"Invalid URL passed to CefBrowserHostImpl::LoadURL: " << url;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the loading URL.
|
||||||
|
OnLoadingURLChange(gurl);
|
||||||
|
|
||||||
|
web_contents_->GetController().LoadURL(
|
||||||
|
gurl,
|
||||||
|
referrer,
|
||||||
|
transition,
|
||||||
|
extra_headers);
|
||||||
|
OnSetFocus(FOCUS_SOURCE_NAVIGATION);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CEF_POST_TASK(CEF_UIT,
|
||||||
|
base::Bind(&CefBrowserHostImpl::LoadURL, this, frame_id, url,
|
||||||
|
referrer, transition, extra_headers));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CefNavigateParams params(GURL(url), transition);
|
||||||
|
params.frame_id = frame_id;
|
||||||
|
params.referrer = referrer;
|
||||||
|
params.headers = extra_headers;
|
||||||
|
Navigate(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserHostImpl::LoadString(int64 frame_id, const std::string& string,
|
void CefBrowserHostImpl::LoadString(int64 frame_id, const std::string& string,
|
||||||
const std::string& url) {
|
const std::string& url) {
|
||||||
Navigate(NavigationHelper::GetParams(frame_id, string, url));
|
// Only known frame ids or kMainFrameId are supported.
|
||||||
|
DCHECK(frame_id >= CefFrameHostImpl::kMainFrameId);
|
||||||
|
|
||||||
|
Cef_Request_Params params;
|
||||||
|
params.name = "load-string";
|
||||||
|
params.frame_id = frame_id;
|
||||||
|
params.user_initiated = false;
|
||||||
|
params.request_id = -1;
|
||||||
|
params.expect_response = false;
|
||||||
|
|
||||||
|
params.arguments.Append(base::Value::CreateStringValue(string));
|
||||||
|
params.arguments.Append(base::Value::CreateStringValue(url));
|
||||||
|
|
||||||
|
Send(new CefMsg_Request(routing_id(), params));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserHostImpl::SendCommand(
|
void CefBrowserHostImpl::SendCommand(
|
||||||
|
@ -1954,34 +1922,6 @@ void CefBrowserHostImpl::DragSourceEndedAt(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CefBrowserHostImpl::Navigate(
|
|
||||||
const content::NavigationController::LoadURLParams& params) {
|
|
||||||
// Only known frame ids and kMainFrameId are supported.
|
|
||||||
DCHECK(params.frame_tree_node_id >= CefFrameHostImpl::kMainFrameId);
|
|
||||||
|
|
||||||
// Go through the navigation controller.
|
|
||||||
if (CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
if (web_contents_.get()) {
|
|
||||||
if (!params.url.is_valid()) {
|
|
||||||
LOG(ERROR)
|
|
||||||
<< "Invalid URL passed to CefBrowserHostImpl::LoadURLWithParams: "
|
|
||||||
<< params.url.spec();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the loading URL.
|
|
||||||
OnLoadingURLChange(params.url);
|
|
||||||
|
|
||||||
web_contents_->GetController().LoadURLWithParams(params);
|
|
||||||
|
|
||||||
OnSetFocus(FOCUS_SOURCE_NAVIGATION);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
CEF_POST_TASK(CEF_UIT,
|
|
||||||
base::Bind(&CefBrowserHostImpl::Navigate, this, params));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// content::WebContentsDelegate methods.
|
// content::WebContentsDelegate methods.
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -1990,7 +1930,8 @@ content::WebContents* CefBrowserHostImpl::OpenURLFromTab(
|
||||||
const content::OpenURLParams& params) {
|
const content::OpenURLParams& params) {
|
||||||
// Start a navigation that will result in the creation of a new render
|
// Start a navigation that will result in the creation of a new render
|
||||||
// process.
|
// process.
|
||||||
Navigate(NavigationHelper::GetParams(params));
|
LoadURL(CefFrameHostImpl::kMainFrameId, params.url.spec(), params.referrer,
|
||||||
|
params.transition, params.extra_headers);
|
||||||
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
@ -2491,7 +2432,6 @@ bool CefBrowserHostImpl::OnMessageReceived(const IPC::Message& message) {
|
||||||
IPC_MESSAGE_HANDLER(CefHostMsg_Request, OnRequest)
|
IPC_MESSAGE_HANDLER(CefHostMsg_Request, OnRequest)
|
||||||
IPC_MESSAGE_HANDLER(CefHostMsg_Response, OnResponse)
|
IPC_MESSAGE_HANDLER(CefHostMsg_Response, OnResponse)
|
||||||
IPC_MESSAGE_HANDLER(CefHostMsg_ResponseAck, OnResponseAck)
|
IPC_MESSAGE_HANDLER(CefHostMsg_ResponseAck, OnResponseAck)
|
||||||
IPC_MESSAGE_HANDLER(CefHostMsg_LoadRequest, OnLoadRequest)
|
|
||||||
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PDFHasUnsupportedFeature,
|
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PDFHasUnsupportedFeature,
|
||||||
OnPDFHasUnsupportedFeature)
|
OnPDFHasUnsupportedFeature)
|
||||||
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PDFSaveURLAs, OnPDFSaveURLAs)
|
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PDFSaveURLAs, OnPDFSaveURLAs)
|
||||||
|
@ -2594,11 +2534,6 @@ void CefBrowserHostImpl::OnResponseAck(int request_id) {
|
||||||
response_manager_->RunAckHandler(request_id);
|
response_manager_->RunAckHandler(request_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserHostImpl::OnLoadRequest(
|
|
||||||
const CefHostMsg_LoadRequest_Params& request_params) {
|
|
||||||
Navigate(NavigationHelper::GetParams(request_params));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefBrowserHostImpl::OnPDFHasUnsupportedFeature() {
|
void CefBrowserHostImpl::OnPDFHasUnsupportedFeature() {
|
||||||
// TODO(cef): Use Adobe PDF plugin instead. See PDFHasUnsupportedFeature in
|
// TODO(cef): Use Adobe PDF plugin instead. See PDFHasUnsupportedFeature in
|
||||||
// chrome/browser/ui/pdf/pdf_unsupported_feature.cc.
|
// chrome/browser/ui/pdf/pdf_unsupported_feature.cc.
|
||||||
|
|
|
@ -64,11 +64,11 @@ class Widget;
|
||||||
class CefWindowX11;
|
class CefWindowX11;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct CefHostMsg_LoadRequest_Params;
|
|
||||||
struct Cef_Request_Params;
|
struct Cef_Request_Params;
|
||||||
struct Cef_Response_Params;
|
struct Cef_Response_Params;
|
||||||
class CefBrowserInfo;
|
class CefBrowserInfo;
|
||||||
class CefDevToolsFrontend;
|
class CefDevToolsFrontend;
|
||||||
|
struct CefNavigateParams;
|
||||||
class SiteInstance;
|
class SiteInstance;
|
||||||
|
|
||||||
// Implementation of CefBrowser.
|
// Implementation of CefBrowser.
|
||||||
|
@ -237,13 +237,17 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||||
CefRefPtr<CefFrame> GetFrameForRequest(net::URLRequest* request);
|
CefRefPtr<CefFrame> GetFrameForRequest(net::URLRequest* request);
|
||||||
|
|
||||||
// Navigate as specified by the |params| argument.
|
// Navigate as specified by the |params| argument.
|
||||||
void Navigate(const content::NavigationController::LoadURLParams& params);
|
void Navigate(const CefNavigateParams& params);
|
||||||
|
|
||||||
// Load the specified request.
|
// Load the specified request.
|
||||||
void LoadRequest(int64 frame_id, CefRefPtr<CefRequest> request);
|
void LoadRequest(int64 frame_id, CefRefPtr<CefRequest> request);
|
||||||
|
|
||||||
// Load the specified URL.
|
// Load the specified URL.
|
||||||
void LoadURL(int64 frame_id, const std::string& url);
|
void LoadURL(int64 frame_id,
|
||||||
|
const std::string& url,
|
||||||
|
const content::Referrer& referrer,
|
||||||
|
content::PageTransition transition,
|
||||||
|
const std::string& extra_headers);
|
||||||
|
|
||||||
// Load the specified string.
|
// Load the specified string.
|
||||||
void LoadString(int64 frame_id, const std::string& string,
|
void LoadString(int64 frame_id, const std::string& string,
|
||||||
|
@ -452,7 +456,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||||
void OnRequest(const Cef_Request_Params& params);
|
void OnRequest(const Cef_Request_Params& params);
|
||||||
void OnResponse(const Cef_Response_Params& params);
|
void OnResponse(const Cef_Response_Params& params);
|
||||||
void OnResponseAck(int request_id);
|
void OnResponseAck(int request_id);
|
||||||
void OnLoadRequest(const CefHostMsg_LoadRequest_Params& params);
|
|
||||||
void OnPDFHasUnsupportedFeature();
|
void OnPDFHasUnsupportedFeature();
|
||||||
void OnPDFSaveURLAs(const GURL& url,
|
void OnPDFSaveURLAs(const GURL& url,
|
||||||
const content::Referrer& referrer);
|
const content::Referrer& referrer);
|
||||||
|
|
|
@ -136,7 +136,8 @@ void CefFrameHostImpl::LoadURL(const CefString& url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browser) {
|
if (browser) {
|
||||||
browser->LoadURL(frame_id, url);
|
browser->LoadURL(frame_id, url, content::Referrer(),
|
||||||
|
content::PAGE_TRANSITION_TYPED, std::string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
||||||
|
// Portions copyright (c) 2012 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.
|
||||||
|
|
||||||
|
#include "libcef/browser/navigate_params.h"
|
||||||
|
|
||||||
|
CefNavigateParams::CefNavigateParams(
|
||||||
|
const GURL& a_url,
|
||||||
|
content::PageTransition a_transition)
|
||||||
|
: url(a_url),
|
||||||
|
frame_id(-1),
|
||||||
|
disposition(CURRENT_TAB),
|
||||||
|
transition(a_transition),
|
||||||
|
is_renderer_initiated(false),
|
||||||
|
user_gesture(true) {
|
||||||
|
}
|
||||||
|
|
||||||
|
CefNavigateParams::~CefNavigateParams() {
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
||||||
|
// Portions copyright (c) 2011 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 CEF_LIBCEF_BROWSER_NAVIGATE_PARAMS_H_
|
||||||
|
#define CEF_LIBCEF_BROWSER_NAVIGATE_PARAMS_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "libcef/common/upload_data.h"
|
||||||
|
|
||||||
|
#include "content/public/browser/global_request_id.h"
|
||||||
|
#include "content/public/common/page_transition_types.h"
|
||||||
|
#include "content/public/common/referrer.h"
|
||||||
|
#include "ui/base/window_open_disposition.h"
|
||||||
|
#include "url/gurl.h"
|
||||||
|
|
||||||
|
// Parameters that tell CefBrowserHostImpl::Navigate() what to do.
|
||||||
|
struct CefNavigateParams {
|
||||||
|
CefNavigateParams(const GURL& a_url,
|
||||||
|
content::PageTransition a_transition);
|
||||||
|
~CefNavigateParams();
|
||||||
|
|
||||||
|
// The following parameters are sent to the renderer via CefMsg_LoadRequest.
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Request method.
|
||||||
|
std::string method;
|
||||||
|
|
||||||
|
// The URL/referrer to be loaded.
|
||||||
|
GURL url;
|
||||||
|
content::Referrer referrer;
|
||||||
|
|
||||||
|
// The frame that the request should be loaded in or -1 to use the main frame.
|
||||||
|
int64 frame_id;
|
||||||
|
|
||||||
|
// Usually the URL of the document in the top-level window, which may be
|
||||||
|
// checked by the third-party cookie blocking policy. Leaving it empty may
|
||||||
|
// lead to undesired cookie blocking. Third-party cookie blocking can be
|
||||||
|
// bypassed by setting first_party_for_cookies = url, but this should ideally
|
||||||
|
// only be done if there really is no way to determine the correct value.
|
||||||
|
GURL first_party_for_cookies;
|
||||||
|
|
||||||
|
// Additional HTTP request headers.
|
||||||
|
std::string headers;
|
||||||
|
|
||||||
|
// net::URLRequest load flags (0 by default).
|
||||||
|
int load_flags;
|
||||||
|
|
||||||
|
// Upload data (may be NULL).
|
||||||
|
scoped_refptr<net::UploadData> upload_data;
|
||||||
|
|
||||||
|
|
||||||
|
// The following parameters are used to define browser behavior when servicing
|
||||||
|
// the navigation request.
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// The disposition requested by the navigation source. Default is CURRENT_TAB.
|
||||||
|
WindowOpenDisposition disposition;
|
||||||
|
|
||||||
|
// The transition type of the navigation.
|
||||||
|
content::PageTransition transition;
|
||||||
|
|
||||||
|
// Whether this navigation was initiated by the renderer process.
|
||||||
|
bool is_renderer_initiated;
|
||||||
|
|
||||||
|
// If non-empty, the new tab contents encoding is overriden by this value.
|
||||||
|
std::string override_encoding;
|
||||||
|
|
||||||
|
// If false then the navigation was not initiated by a user gesture. Default
|
||||||
|
// is true.
|
||||||
|
bool user_gesture;
|
||||||
|
|
||||||
|
// Refers to a navigation that was parked in the browser in order to be
|
||||||
|
// transferred to another RVH. Only used in case of a redirection of a request
|
||||||
|
// to a different site that created a new RVH.
|
||||||
|
content::GlobalRequestID transferred_global_request_id;
|
||||||
|
|
||||||
|
private:
|
||||||
|
CefNavigateParams();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CEF_LIBCEF_BROWSER_NAVIGATE_PARAMS_H_
|
|
@ -70,6 +70,45 @@ IPC_STRUCT_END()
|
||||||
|
|
||||||
// Messages sent from the browser to the renderer.
|
// Messages sent from the browser to the renderer.
|
||||||
|
|
||||||
|
// Parameters for a resource request.
|
||||||
|
IPC_STRUCT_BEGIN(CefMsg_LoadRequest_Params)
|
||||||
|
// The request method: GET, POST, etc.
|
||||||
|
IPC_STRUCT_MEMBER(std::string, method)
|
||||||
|
|
||||||
|
// The requested URL.
|
||||||
|
IPC_STRUCT_MEMBER(GURL, url)
|
||||||
|
|
||||||
|
// The URL to send in the "Referer" header field. Can be empty if there is
|
||||||
|
// no referrer.
|
||||||
|
IPC_STRUCT_MEMBER(GURL, referrer)
|
||||||
|
// One of the blink::WebReferrerPolicy values.
|
||||||
|
IPC_STRUCT_MEMBER(int, referrer_policy)
|
||||||
|
|
||||||
|
// Identifies the frame within the RenderView that sent the request.
|
||||||
|
// -1 if unknown / invalid.
|
||||||
|
IPC_STRUCT_MEMBER(int64, frame_id)
|
||||||
|
|
||||||
|
// Usually the URL of the document in the top-level window, which may be
|
||||||
|
// checked by the third-party cookie blocking policy. Leaving it empty may
|
||||||
|
// lead to undesired cookie blocking. Third-party cookie blocking can be
|
||||||
|
// bypassed by setting first_party_for_cookies = url, but this should ideally
|
||||||
|
// only be done if there really is no way to determine the correct value.
|
||||||
|
IPC_STRUCT_MEMBER(GURL, first_party_for_cookies)
|
||||||
|
|
||||||
|
// Additional HTTP request headers.
|
||||||
|
IPC_STRUCT_MEMBER(std::string, headers)
|
||||||
|
|
||||||
|
// net::URLRequest load flags (0 by default).
|
||||||
|
IPC_STRUCT_MEMBER(int, load_flags)
|
||||||
|
|
||||||
|
// Optional upload data (may be null).
|
||||||
|
IPC_STRUCT_MEMBER(scoped_refptr<net::UploadData>, upload_data)
|
||||||
|
IPC_STRUCT_END()
|
||||||
|
|
||||||
|
// Tell the renderer to load a request.
|
||||||
|
IPC_MESSAGE_ROUTED1(CefMsg_LoadRequest,
|
||||||
|
CefMsg_LoadRequest_Params)
|
||||||
|
|
||||||
// Sent when the browser has a request for the renderer. The renderer may
|
// Sent when the browser has a request for the renderer. The renderer may
|
||||||
// respond with a CefHostMsg_Response.
|
// respond with a CefHostMsg_Response.
|
||||||
IPC_MESSAGE_ROUTED1(CefMsg_Request,
|
IPC_MESSAGE_ROUTED1(CefMsg_Request,
|
||||||
|
@ -162,35 +201,6 @@ IPC_MESSAGE_ROUTED1(CefHostMsg_Response,
|
||||||
IPC_MESSAGE_ROUTED1(CefHostMsg_ResponseAck,
|
IPC_MESSAGE_ROUTED1(CefHostMsg_ResponseAck,
|
||||||
int /* request_id */)
|
int /* request_id */)
|
||||||
|
|
||||||
// Parameters for a resource request.
|
|
||||||
IPC_STRUCT_BEGIN(CefHostMsg_LoadRequest_Params)
|
|
||||||
// The request method: GET, POST, etc.
|
|
||||||
IPC_STRUCT_MEMBER(std::string, method)
|
|
||||||
|
|
||||||
// The requested URL.
|
|
||||||
IPC_STRUCT_MEMBER(GURL, url)
|
|
||||||
|
|
||||||
// The URL to send in the "Referer" header field. Can be empty if there is
|
|
||||||
// no referrer.
|
|
||||||
IPC_STRUCT_MEMBER(GURL, referrer)
|
|
||||||
// One of the blink::WebReferrerPolicy values.
|
|
||||||
IPC_STRUCT_MEMBER(int, referrer_policy)
|
|
||||||
|
|
||||||
// Identifies the frame within the RenderView that sent the request.
|
|
||||||
// -1 if unknown / invalid.
|
|
||||||
IPC_STRUCT_MEMBER(int64, frame_id)
|
|
||||||
|
|
||||||
// Additional HTTP request headers.
|
|
||||||
IPC_STRUCT_MEMBER(std::string, headers)
|
|
||||||
|
|
||||||
// Optional upload data (may be null).
|
|
||||||
IPC_STRUCT_MEMBER(scoped_refptr<net::UploadData>, upload_data)
|
|
||||||
IPC_STRUCT_END()
|
|
||||||
|
|
||||||
// Tell the browser to load a request.
|
|
||||||
IPC_MESSAGE_ROUTED1(CefHostMsg_LoadRequest,
|
|
||||||
CefHostMsg_LoadRequest_Params)
|
|
||||||
|
|
||||||
|
|
||||||
// Pepper PDF plugin messages excerpted from chrome/common/render_messages.h.
|
// Pepper PDF plugin messages excerpted from chrome/common/render_messages.h.
|
||||||
// Including all of render_messages.h would bring in a number of chrome
|
// Including all of render_messages.h would bring in a number of chrome
|
||||||
|
|
|
@ -45,6 +45,20 @@ using blink::WebString;
|
||||||
using blink::WebURL;
|
using blink::WebURL;
|
||||||
using blink::WebView;
|
using blink::WebView;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
blink::WebString FilePathStringToWebString(
|
||||||
|
const base::FilePath::StringType& str) {
|
||||||
|
#if defined(OS_POSIX)
|
||||||
|
return base::WideToUTF16(base::SysNativeMBToWide(str));
|
||||||
|
#elif defined(OS_WIN)
|
||||||
|
return base::WideToUTF16(str);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
// CefBrowserImpl static methods.
|
// CefBrowserImpl static methods.
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -267,8 +281,80 @@ CefBrowserImpl::CefBrowserImpl(content::RenderView* render_view,
|
||||||
CefBrowserImpl::~CefBrowserImpl() {
|
CefBrowserImpl::~CefBrowserImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::LoadRequest(const CefHostMsg_LoadRequest_Params& params) {
|
void CefBrowserImpl::LoadRequest(const CefMsg_LoadRequest_Params& params) {
|
||||||
Send(new CefHostMsg_LoadRequest(routing_id(), params));
|
CefRefPtr<CefFrameImpl> framePtr = GetWebFrameImpl(params.frame_id);
|
||||||
|
if (!framePtr.get())
|
||||||
|
return;
|
||||||
|
|
||||||
|
WebFrame* web_frame = framePtr->web_frame();
|
||||||
|
|
||||||
|
blink::WebURLRequest request(params.url);
|
||||||
|
|
||||||
|
// DidCreateDataSource checks for this value.
|
||||||
|
request.setRequestorID(-1);
|
||||||
|
|
||||||
|
if (!params.method.empty())
|
||||||
|
request.setHTTPMethod(base::ASCIIToUTF16(params.method));
|
||||||
|
|
||||||
|
if (params.referrer.is_valid()) {
|
||||||
|
WebString referrer = blink::WebSecurityPolicy::generateReferrerHeader(
|
||||||
|
static_cast<blink::WebReferrerPolicy>(params.referrer_policy),
|
||||||
|
params.url,
|
||||||
|
WebString::fromUTF8(params.referrer.spec()));
|
||||||
|
if (!referrer.isEmpty())
|
||||||
|
request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.first_party_for_cookies.is_valid())
|
||||||
|
request.setFirstPartyForCookies(params.first_party_for_cookies);
|
||||||
|
|
||||||
|
if (!params.headers.empty()) {
|
||||||
|
for (net::HttpUtil::HeadersIterator i(params.headers.begin(),
|
||||||
|
params.headers.end(), "\n");
|
||||||
|
i.GetNext(); ) {
|
||||||
|
request.addHTTPHeaderField(WebString::fromUTF8(i.name()),
|
||||||
|
WebString::fromUTF8(i.values()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.upload_data.get()) {
|
||||||
|
base::string16 method = request.httpMethod();
|
||||||
|
if (method == base::ASCIIToUTF16("GET") ||
|
||||||
|
method == base::ASCIIToUTF16("HEAD")) {
|
||||||
|
request.setHTTPMethod(base::ASCIIToUTF16("POST"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.httpHeaderField(
|
||||||
|
base::ASCIIToUTF16("Content-Type")).length() == 0) {
|
||||||
|
request.setHTTPHeaderField(
|
||||||
|
base::ASCIIToUTF16("Content-Type"),
|
||||||
|
base::ASCIIToUTF16("application/x-www-form-urlencoded"));
|
||||||
|
}
|
||||||
|
|
||||||
|
blink::WebHTTPBody body;
|
||||||
|
body.initialize();
|
||||||
|
|
||||||
|
const ScopedVector<net::UploadElement>& elements =
|
||||||
|
params.upload_data->elements();
|
||||||
|
ScopedVector<net::UploadElement>::const_iterator it =
|
||||||
|
elements.begin();
|
||||||
|
for (; it != elements.end(); ++it) {
|
||||||
|
const net::UploadElement& element = **it;
|
||||||
|
if (element.type() == net::UploadElement::TYPE_BYTES) {
|
||||||
|
blink::WebData data;
|
||||||
|
data.assign(element.bytes(), element.bytes_length());
|
||||||
|
body.appendData(data);
|
||||||
|
} else if (element.type() == net::UploadElement::TYPE_FILE) {
|
||||||
|
body.appendFile(FilePathStringToWebString(element.file_path().value()));
|
||||||
|
} else {
|
||||||
|
NOTREACHED();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
request.setHTTPBody(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
web_frame->loadRequest(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefBrowserImpl::SendProcessMessage(CefProcessId target_process,
|
bool CefBrowserImpl::SendProcessMessage(CefProcessId target_process,
|
||||||
|
@ -530,6 +616,7 @@ bool CefBrowserImpl::OnMessageReceived(const IPC::Message& message) {
|
||||||
IPC_MESSAGE_HANDLER(CefMsg_Request, OnRequest)
|
IPC_MESSAGE_HANDLER(CefMsg_Request, OnRequest)
|
||||||
IPC_MESSAGE_HANDLER(CefMsg_Response, OnResponse)
|
IPC_MESSAGE_HANDLER(CefMsg_Response, OnResponse)
|
||||||
IPC_MESSAGE_HANDLER(CefMsg_ResponseAck, OnResponseAck)
|
IPC_MESSAGE_HANDLER(CefMsg_ResponseAck, OnResponseAck)
|
||||||
|
IPC_MESSAGE_HANDLER(CefMsg_LoadRequest, LoadRequest)
|
||||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||||
IPC_END_MESSAGE_MAP()
|
IPC_END_MESSAGE_MAP()
|
||||||
return handled;
|
return handled;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "content/public/renderer/render_view_observer.h"
|
#include "content/public/renderer/render_view_observer.h"
|
||||||
|
|
||||||
class GURL;
|
class GURL;
|
||||||
struct CefHostMsg_LoadRequest_Params;
|
struct CefMsg_LoadRequest_Params;
|
||||||
struct Cef_Request_Params;
|
struct Cef_Request_Params;
|
||||||
struct Cef_Response_Params;
|
struct Cef_Response_Params;
|
||||||
class CefContentRendererClient;
|
class CefContentRendererClient;
|
||||||
|
@ -79,7 +79,7 @@ class CefBrowserImpl : public CefBrowser,
|
||||||
bool is_windowless);
|
bool is_windowless);
|
||||||
virtual ~CefBrowserImpl();
|
virtual ~CefBrowserImpl();
|
||||||
|
|
||||||
void LoadRequest(const CefHostMsg_LoadRequest_Params& params);
|
void LoadRequest(const CefMsg_LoadRequest_Params& params);
|
||||||
|
|
||||||
// Avoids unnecessary string type conversions.
|
// Avoids unnecessary string type conversions.
|
||||||
bool SendProcessMessage(CefProcessId target_process,
|
bool SendProcessMessage(CefProcessId target_process,
|
||||||
|
|
|
@ -110,10 +110,12 @@ void CefFrameImpl::LoadRequest(CefRefPtr<CefRequest> request) {
|
||||||
if (!browser_)
|
if (!browser_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CefHostMsg_LoadRequest_Params params;
|
CefMsg_LoadRequest_Params params;
|
||||||
params.url = GURL(std::string(request->GetURL()));
|
params.url = GURL(std::string(request->GetURL()));
|
||||||
params.method = request->GetMethod();
|
params.method = request->GetMethod();
|
||||||
params.frame_id = frame_id_;
|
params.frame_id = frame_id_;
|
||||||
|
params.first_party_for_cookies =
|
||||||
|
GURL(std::string(request->GetFirstPartyForCookies()));
|
||||||
|
|
||||||
CefRequest::HeaderMap headerMap;
|
CefRequest::HeaderMap headerMap;
|
||||||
request->GetHeaderMap(headerMap);
|
request->GetHeaderMap(headerMap);
|
||||||
|
@ -127,6 +129,8 @@ void CefFrameImpl::LoadRequest(CefRefPtr<CefRequest> request) {
|
||||||
impl->Get(*params.upload_data.get());
|
impl->Get(*params.upload_data.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params.load_flags = request->GetFlags();
|
||||||
|
|
||||||
browser_->LoadRequest(params);
|
browser_->LoadRequest(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +140,7 @@ void CefFrameImpl::LoadURL(const CefString& url) {
|
||||||
if (!browser_)
|
if (!browser_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CefHostMsg_LoadRequest_Params params;
|
CefMsg_LoadRequest_Params params;
|
||||||
params.url = GURL(url.ToString());
|
params.url = GURL(url.ToString());
|
||||||
params.method = "GET";
|
params.method = "GET";
|
||||||
params.frame_id = frame_id_;
|
params.frame_id = frame_id_;
|
||||||
|
|
|
@ -145,7 +145,7 @@ class RequestSendRecvTestHandler : public TestHandler {
|
||||||
CreateRequest(request_);
|
CreateRequest(request_);
|
||||||
|
|
||||||
// Create the browser
|
// Create the browser
|
||||||
CreateBrowser("");
|
CreateBrowser("about:blank");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE {
|
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE {
|
||||||
|
@ -161,7 +161,7 @@ class RequestSendRecvTestHandler : public TestHandler {
|
||||||
// Verify that the request is the same
|
// Verify that the request is the same
|
||||||
TestRequestEqual(request_, request, true);
|
TestRequestEqual(request_, request, true);
|
||||||
EXPECT_EQ(RT_MAIN_FRAME, request->GetResourceType());
|
EXPECT_EQ(RT_MAIN_FRAME, request->GetResourceType());
|
||||||
EXPECT_EQ(request_->GetTransitionType(), request->GetTransitionType());
|
EXPECT_EQ(TT_LINK, request->GetTransitionType());
|
||||||
|
|
||||||
got_before_resource_load_.yes();
|
got_before_resource_load_.yes();
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ class RequestSendRecvTestHandler : public TestHandler {
|
||||||
// Verify that the request is the same
|
// Verify that the request is the same
|
||||||
TestRequestEqual(request_, request, true);
|
TestRequestEqual(request_, request, true);
|
||||||
EXPECT_EQ(RT_MAIN_FRAME, request->GetResourceType());
|
EXPECT_EQ(RT_MAIN_FRAME, request->GetResourceType());
|
||||||
EXPECT_EQ(request_->GetTransitionType(), request->GetTransitionType());
|
EXPECT_EQ(TT_LINK, request->GetTransitionType());
|
||||||
|
|
||||||
got_resource_handler_.yes();
|
got_resource_handler_.yes();
|
||||||
|
|
||||||
|
@ -205,64 +205,6 @@ TEST(RequestTest, SendRecv) {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class LoadStringTestHandler : public TestHandler,
|
|
||||||
public CefStringVisitor {
|
|
||||||
public:
|
|
||||||
LoadStringTestHandler() {
|
|
||||||
source_ = "<html><head></head><body>Test</body></html>";
|
|
||||||
url_ = "http://tests/run.html";
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void RunTest() OVERRIDE {
|
|
||||||
CreateBrowser("");
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE {
|
|
||||||
TestHandler::OnAfterCreated(browser);
|
|
||||||
|
|
||||||
browser->GetMainFrame()->LoadString(source_, url_);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
|
||||||
CefRefPtr<CefFrame> frame,
|
|
||||||
int httpStatusCode) OVERRIDE {
|
|
||||||
EXPECT_EQ(url_, frame->GetURL().ToString());
|
|
||||||
|
|
||||||
CefRefPtr<CefStringVisitor> visitor(this);
|
|
||||||
frame->GetSource(visitor);
|
|
||||||
|
|
||||||
got_on_load_end_.yes();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void Visit(const CefString& source) OVERRIDE {
|
|
||||||
EXPECT_EQ(source_, source.ToString());
|
|
||||||
got_source_.yes();
|
|
||||||
DestroyTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string source_;
|
|
||||||
std::string url_;
|
|
||||||
|
|
||||||
TrackCallback got_on_load_end_;
|
|
||||||
TrackCallback got_source_;
|
|
||||||
|
|
||||||
private:
|
|
||||||
IMPLEMENT_REFCOUNTING(LoadStringTestHandler);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
TEST(RequestTest, LoadStringTest) {
|
|
||||||
CefRefPtr<LoadStringTestHandler> handler =
|
|
||||||
new LoadStringTestHandler();
|
|
||||||
|
|
||||||
handler->ExecuteTest();
|
|
||||||
ASSERT_TRUE(handler->got_on_load_end_);
|
|
||||||
ASSERT_TRUE(handler->got_source_);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const char kTypeTestCompleteMsg[] = "RequestTest.Type";
|
const char kTypeTestCompleteMsg[] = "RequestTest.Type";
|
||||||
const char kTypeTestOrigin[] = "http://tests-requesttt.com/";
|
const char kTypeTestOrigin[] = "http://tests-requesttt.com/";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue