webContents: handle POST navigation for new windows

This commit is contained in:
deepak1556 2016-10-10 05:00:38 +05:30 committed by Kevin Sawicki
parent 7cfe1dd0af
commit 0410a184ce
10 changed files with 187 additions and 49 deletions

View file

@ -528,12 +528,14 @@ void App::OnLogin(LoginHandler* login_handler,
login_handler->CancelAuth();
}
void App::OnCreateWindow(const GURL& target_url,
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<base::string16>& features,
int render_process_id,
int render_frame_id) {
void App::OnCreateWindow(
const GURL& target_url,
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<base::string16>& features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
int render_process_id,
int render_frame_id) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
content::RenderFrameHost* rfh =
@ -545,7 +547,8 @@ void App::OnCreateWindow(const GURL& target_url,
api_web_contents->OnCreateWindow(target_url,
frame_name,
disposition,
features);
features,
body);
}
}

View file

@ -48,12 +48,14 @@ class App : public AtomBrowserClient::Delegate,
v8::Local<v8::FunctionTemplate> prototype);
// Called when window with disposition needs to be created.
void OnCreateWindow(const GURL& target_url,
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<base::string16>& features,
int render_process_id,
int render_frame_id);
void OnCreateWindow(
const GURL& target_url,
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<base::string16>& features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
int render_process_id,
int render_frame_id);
#if defined(USE_NSS_CERTS)
void OnCertificateManagerModelCreated(

View file

@ -387,12 +387,14 @@ bool WebContents::AddMessageToConsole(content::WebContents* source,
}
}
void WebContents::OnCreateWindow(const GURL& target_url,
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<base::string16>& features) {
void WebContents::OnCreateWindow(
const GURL& target_url,
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<base::string16>& features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body) {
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN)
Emit("-new-window", target_url, frame_name, disposition, features);
Emit("-new-window", target_url, frame_name, disposition, features, body);
else
Emit("new-window", target_url, frame_name, disposition, features);
}
@ -855,6 +857,12 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
if (options.Get("extraHeaders", &extra_headers))
params.extra_headers = extra_headers;
scoped_refptr<content::ResourceRequestBodyImpl> body;
if (options.Get("postData", &body)) {
params.post_data = body;
params.load_type = content::NavigationController::LOAD_TYPE_HTTP_POST;
}
params.transition_type = ui::PAGE_TRANSITION_TYPED;
params.should_clear_history_list = true;
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;

View file

@ -26,6 +26,10 @@ namespace brightray {
class InspectableWebContents;
}
namespace content {
class ResourceRequestBodyImpl;
}
namespace mate {
class Arguments;
class Dictionary;
@ -176,10 +180,12 @@ class WebContents : public mate::TrackableObject<WebContents>,
bool allowed);
// Create window with the given disposition.
void OnCreateWindow(const GURL& target_url,
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<base::string16>& features);
void OnCreateWindow(
const GURL& target_url,
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<base::string16>& features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body);
// Returns the web preferences of current WebContents.
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate);

View file

@ -30,6 +30,7 @@
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
#include "chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.h"
#include "chrome/browser/speech/tts_message_filter.h"
#include "content/common/resource_request_body_impl.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/geolocation_delegate.h"
@ -319,7 +320,7 @@ bool AtomBrowserClient::CanCreateWindow(
WindowOpenDisposition disposition,
const blink::WebWindowFeatures& features,
const std::vector<base::string16>& additional_features,
const scoped_refptr<ResourceRequestBodyImpl>& body,
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
bool user_gesture,
bool opener_suppressed,
content::ResourceContext* context,
@ -342,6 +343,7 @@ bool AtomBrowserClient::CanCreateWindow(
frame_name,
disposition,
additional_features,
body,
render_process_id,
opener_render_frame_id));
}

View file

@ -13,8 +13,6 @@
#include "brightray/browser/browser_client.h"
#include "content/public/browser/render_process_host_observer.h"
using content::ResourceRequestBodyImpl;
namespace content {
class QuotaPermissionContext;
class ClientCertificateDelegate;
@ -81,24 +79,25 @@ class AtomBrowserClient : public brightray::BrowserClient,
net::SSLCertRequestInfo* cert_request_info,
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
void ResourceDispatcherHostCreated() override;
bool CanCreateWindow(const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
WindowContainerType container_type,
const std::string& frame_name,
const GURL& target_url,
const content::Referrer& referrer,
WindowOpenDisposition disposition,
const blink::WebWindowFeatures& features,
const std::vector<base::string16>& additional_features,
const scoped_refptr<ResourceRequestBodyImpl>& body,
bool user_gesture,
bool opener_suppressed,
content::ResourceContext* context,
int render_process_id,
int opener_render_view_id,
int opener_render_frame_id,
bool* no_javascript_access) override;
bool CanCreateWindow(
const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
WindowContainerType container_type,
const std::string& frame_name,
const GURL& target_url,
const content::Referrer& referrer,
WindowOpenDisposition disposition,
const blink::WebWindowFeatures& features,
const std::vector<base::string16>& additional_features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
bool user_gesture,
bool opener_suppressed,
content::ResourceContext* context,
int render_process_id,
int opener_render_view_id,
int opener_render_frame_id,
bool* no_javascript_access) override;
void GetAdditionalAllowedSchemesForFileSystem(
std::vector<std::string>* schemes) override;