Merge pull request #11370 from electron/fix_dchecks

Fix: Re-enable some dchecks
This commit is contained in:
John Kleinschmidt 2017-12-07 15:55:33 -05:00 committed by GitHub
commit f10c279322
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 30 deletions

View file

@ -667,25 +667,33 @@ void App::OnLogin(LoginHandler* login_handler,
login_handler->CancelAuth(); login_handler->CancelAuth();
} }
void App::OnCreateWindow( bool App::CanCreateWindow(
content::RenderFrameHost* opener,
const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
content::mojom::WindowContainerType container_type,
const GURL& target_url, const GURL& target_url,
const content::Referrer& referrer,
const std::string& frame_name, const std::string& frame_name,
WindowOpenDisposition disposition, WindowOpenDisposition disposition,
const std::vector<std::string>& features, const blink::mojom::WindowFeatures& features,
const std::vector<std::string>& additional_features,
const scoped_refptr<content::ResourceRequestBody>& body, const scoped_refptr<content::ResourceRequestBody>& body,
content::RenderFrameHost* opener) { bool user_gesture,
bool opener_suppressed,
bool* no_javascript_access) {
v8::Locker locker(isolate()); v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate()); v8::HandleScope handle_scope(isolate());
content::WebContents* web_contents = content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(opener); content::WebContents::FromRenderFrameHost(opener);
if (web_contents) { if (web_contents) {
auto api_web_contents = WebContents::CreateFrom(isolate(), web_contents); auto api_web_contents = WebContents::CreateFrom(isolate(), web_contents);
api_web_contents->OnCreateWindow(target_url, api_web_contents->OnCreateWindow(target_url, frame_name, disposition,
frame_name, additional_features, body);
disposition,
features,
body);
} }
return false;
} }
void App::AllowCertificateError( void App::AllowCertificateError(

View file

@ -75,15 +75,6 @@ class App : public AtomBrowserClient::Delegate,
static void BuildPrototype(v8::Isolate* isolate, static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype); 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<std::string>& features,
const scoped_refptr<content::ResourceRequestBody>& body,
content::RenderFrameHost* opener);
#if defined(USE_NSS_CERTS) #if defined(USE_NSS_CERTS)
void OnCertificateManagerModelCreated( void OnCertificateManagerModelCreated(
std::unique_ptr<base::DictionaryValue> options, std::unique_ptr<base::DictionaryValue> options,
@ -152,6 +143,21 @@ class App : public AtomBrowserClient::Delegate,
net::SSLCertRequestInfo* cert_request_info, net::SSLCertRequestInfo* cert_request_info,
net::ClientCertIdentityList client_certs, net::ClientCertIdentityList client_certs,
std::unique_ptr<content::ClientCertificateDelegate> delegate) override; std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
bool CanCreateWindow(content::RenderFrameHost* opener,
const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
content::mojom::WindowContainerType container_type,
const GURL& target_url,
const content::Referrer& referrer,
const std::string& frame_name,
WindowOpenDisposition disposition,
const blink::mojom::WindowFeatures& features,
const std::vector<std::string>& additional_features,
const scoped_refptr<content::ResourceRequestBody>& body,
bool user_gesture,
bool opener_suppressed,
bool* no_javascript_access) override;
// content::GpuDataManagerObserver: // content::GpuDataManagerObserver:
void OnGpuProcessCrashed(base::TerminationStatus status) override; void OnGpuProcessCrashed(base::TerminationStatus status) override;

View file

@ -351,8 +351,7 @@ bool AtomBrowserClient::CanCreateWindow(
bool user_gesture, bool user_gesture,
bool opener_suppressed, bool opener_suppressed,
bool* no_javascript_access) { bool* no_javascript_access) {
// FIXME: Ensure the DCHECK doesn't fail and then re-enable DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
int opener_render_process_id = opener->GetProcess()->GetID(); int opener_render_process_id = opener->GetProcess()->GetID();
@ -373,15 +372,11 @@ bool AtomBrowserClient::CanCreateWindow(
} }
if (delegate_) { if (delegate_) {
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, return delegate_->CanCreateWindow(
base::Bind(&api::App::OnCreateWindow, opener, opener_url, opener_top_level_frame_url, source_origin,
base::Unretained(static_cast<api::App*>(delegate_)), container_type, target_url, referrer, frame_name, disposition, features,
target_url, additional_features, body, user_gesture, opener_suppressed,
frame_name, no_javascript_access);
disposition,
additional_features,
body,
opener));
} }
return false; return false;

View file

@ -18,6 +18,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "brightray/browser/browser_context.h" #include "brightray/browser/browser_context.h"
#include "brightray/browser/devtools_manager_delegate.h" #include "brightray/browser/devtools_manager_delegate.h"
#include "brightray/browser/media/media_capture_devices_dispatcher.h"
#include "brightray/browser/web_ui_controller_factory.h" #include "brightray/browser/web_ui_controller_factory.h"
#include "brightray/common/application_info.h" #include "brightray/common/application_info.h"
#include "brightray/common/main_delegate.h" #include "brightray/common/main_delegate.h"
@ -268,6 +269,9 @@ int BrowserMainParts::PreCreateThreads() {
#endif #endif
#endif #endif
// Force MediaCaptureDevicesDispatcher to be created on UI thread.
MediaCaptureDevicesDispatcher::GetInstance();
if (!views::LayoutProvider::Get()) if (!views::LayoutProvider::Get())
layout_provider_.reset(new views::LayoutProvider()); layout_provider_.reset(new views::LayoutProvider());

View file

@ -44,8 +44,7 @@ MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher()
: is_device_enumeration_disabled_(false) { : is_device_enumeration_disabled_(false) {
// MediaCaptureDevicesDispatcher is a singleton. It should be created on // MediaCaptureDevicesDispatcher is a singleton. It should be created on
// UI thread. // UI thread.
// FIXME: Ensure the DCHECK doesn't fail and then re-enable DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
} }
MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {} MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {}