From e14c91771becf66c5598f108f9f1c3851235a977 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Thu, 31 Mar 2016 19:51:18 +0530 Subject: [PATCH] removed redundant delegation --- atom/browser/api/atom_api_app.cc | 65 ++++++++--------------------- atom/browser/api/atom_api_app.h | 28 ++++--------- atom/browser/atom_browser_client.cc | 31 ++++++-------- 3 files changed, 37 insertions(+), 87 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 03f2437edd58..de1272e03e80 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -27,7 +27,6 @@ #include "base/path_service.h" #include "brightray/browser/brightray_paths.h" #include "chrome/common/chrome_paths.h" -#include "content/public/browser/browser_thread.h" #include "content/public/browser/client_certificate_delegate.h" #include "content/public/browser/gpu_data_manager.h" #include "content/public/browser/render_frame_host.h" @@ -230,6 +229,23 @@ void App::OnLogin(LoginHandler* login_handler) { login_handler->CancelAuth(); } +void App::OnCreateWindow(const GURL& target_url, + const std::string& frame_name, + WindowOpenDisposition disposition, + int render_process_id, + int render_frame_id) { + v8::Locker locker(isolate()); + v8::HandleScope handle_scope(isolate()); + content::RenderFrameHost* rfh = + content::RenderFrameHost::FromID(render_process_id, render_frame_id); + content::WebContents* web_contents = + content::WebContents::FromRenderFrameHost(rfh); + if (web_contents) { + auto api_web_contents = WebContents::CreateFrom(isolate(), web_contents); + api_web_contents->CreateWindow(target_url, frame_name, disposition); + } +} + void App::AllowCertificateError( content::WebContents* web_contents, int cert_error, @@ -276,53 +292,6 @@ void App::SelectClientCertificate( cert_request_info->client_certs[0].get()); } -bool App::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, - 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) { - DCHECK_CURRENTLY_ON(content::BrowserThread::IO); - - content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, - base::Bind(&App::OnCreateWindow, - base::Unretained(this), - target_url, - frame_name, - disposition, - render_process_id, - opener_render_frame_id)); - - return false; -} - -void App::OnCreateWindow(const GURL& target_url, - const std::string& frame_name, - WindowOpenDisposition disposition, - int render_process_id, - int render_frame_id) { - v8::Locker locker(isolate()); - v8::HandleScope handle_scope(isolate()); - content::RenderFrameHost* rfh = - content::RenderFrameHost::FromID(render_process_id, render_frame_id); - content::WebContents* web_contents = - content::WebContents::FromRenderFrameHost(rfh); - if (web_contents) { - auto api_web_contents = WebContents::CreateFrom(isolate(), web_contents); - api_web_contents->CreateWindow(target_url, frame_name, disposition); - } -} - void App::OnGpuProcessCrashed(base::TerminationStatus exit_code) { Emit("gpu-process-crashed"); } diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index 3cf442c9e6e5..5025a3869dd4 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -34,6 +34,13 @@ class App : public AtomBrowserClient::Delegate, public: static mate::Handle Create(v8::Isolate* isolate); + // Called when window with disposition needs to be created. + void OnCreateWindow(const GURL& target_url, + const std::string& frame_name, + WindowOpenDisposition disposition, + int render_process_id, + int render_frame_id); + protected: App(); virtual ~App(); @@ -66,22 +73,6 @@ class App : public AtomBrowserClient::Delegate, content::WebContents* web_contents, net::SSLCertRequestInfo* cert_request_info, scoped_ptr delegate) 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, - 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; // content::GpuDataManagerObserver: void OnGpuProcessCrashed(base::TerminationStatus exit_code) override; @@ -106,11 +97,6 @@ class App : public AtomBrowserClient::Delegate, bool MakeSingleInstance( const ProcessSingleton::NotificationCallback& callback); std::string GetLocale(); - void OnCreateWindow(const GURL& target_url, - const std::string& frame_name, - WindowOpenDisposition disposition, - int render_process_id, - int render_frame_id); #if defined(OS_WIN) bool IsAeroGlassEnabled(); diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index ec58777d9c92..9a59c3f9d412 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -8,6 +8,7 @@ #include #endif +#include "atom/browser/api/atom_api_app.h" #include "atom/browser/atom_access_token_store.h" #include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_main_parts.h" @@ -281,26 +282,20 @@ bool AtomBrowserClient::CanCreateWindow( int opener_render_view_id, int opener_render_frame_id, bool* no_javascript_access) { + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + if (delegate_) { - return delegate_->CanCreateWindow(opener_url, - opener_top_level_frame_url, - source_origin, - container_type, - frame_name, - target_url, - referrer, - disposition, - features, - user_gesture, - opener_suppressed, - context, - render_process_id, - opener_render_view_id, - opener_render_frame_id, - no_javascript_access); - } else { - return false; + content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, + base::Bind(&api::App::OnCreateWindow, + base::Unretained(static_cast(delegate_)), + target_url, + frame_name, + disposition, + render_process_id, + opener_render_frame_id)); } + + return false; } brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts(