Skip to content

Commit f10c279

Browse files
author
John Kleinschmidt
authored
Merge pull request electron#11370 from electron/fix_dchecks
Fix: Re-enable some dchecks
2 parents 63c91e7 + 16d96a6 commit f10c279

5 files changed

Lines changed: 42 additions & 30 deletions

File tree

atom/browser/api/atom_api_app.cc

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -667,25 +667,33 @@ void App::OnLogin(LoginHandler* login_handler,
667667
login_handler->CancelAuth();
668668
}
669669

670-
void App::OnCreateWindow(
670+
bool App::CanCreateWindow(
671+
content::RenderFrameHost* opener,
672+
const GURL& opener_url,
673+
const GURL& opener_top_level_frame_url,
674+
const GURL& source_origin,
675+
content::mojom::WindowContainerType container_type,
671676
const GURL& target_url,
677+
const content::Referrer& referrer,
672678
const std::string& frame_name,
673679
WindowOpenDisposition disposition,
674-
const std::vector<std::string>& features,
680+
const blink::mojom::WindowFeatures& features,
681+
const std::vector<std::string>& additional_features,
675682
const scoped_refptr<content::ResourceRequestBody>& body,
676-
content::RenderFrameHost* opener) {
683+
bool user_gesture,
684+
bool opener_suppressed,
685+
bool* no_javascript_access) {
677686
v8::Locker locker(isolate());
678687
v8::HandleScope handle_scope(isolate());
679688
content::WebContents* web_contents =
680689
content::WebContents::FromRenderFrameHost(opener);
681690
if (web_contents) {
682691
auto api_web_contents = WebContents::CreateFrom(isolate(), web_contents);
683-
api_web_contents->OnCreateWindow(target_url,
684-
frame_name,
685-
disposition,
686-
features,
687-
body);
692+
api_web_contents->OnCreateWindow(target_url, frame_name, disposition,
693+
additional_features, body);
688694
}
695+
696+
return false;
689697
}
690698

691699
void App::AllowCertificateError(

atom/browser/api/atom_api_app.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,6 @@ class App : public AtomBrowserClient::Delegate,
7575
static void BuildPrototype(v8::Isolate* isolate,
7676
v8::Local<v8::FunctionTemplate> prototype);
7777

78-
// Called when window with disposition needs to be created.
79-
void OnCreateWindow(
80-
const GURL& target_url,
81-
const std::string& frame_name,
82-
WindowOpenDisposition disposition,
83-
const std::vector<std::string>& features,
84-
const scoped_refptr<content::ResourceRequestBody>& body,
85-
content::RenderFrameHost* opener);
86-
8778
#if defined(USE_NSS_CERTS)
8879
void OnCertificateManagerModelCreated(
8980
std::unique_ptr<base::DictionaryValue> options,
@@ -152,6 +143,21 @@ class App : public AtomBrowserClient::Delegate,
152143
net::SSLCertRequestInfo* cert_request_info,
153144
net::ClientCertIdentityList client_certs,
154145
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
146+
bool CanCreateWindow(content::RenderFrameHost* opener,
147+
const GURL& opener_url,
148+
const GURL& opener_top_level_frame_url,
149+
const GURL& source_origin,
150+
content::mojom::WindowContainerType container_type,
151+
const GURL& target_url,
152+
const content::Referrer& referrer,
153+
const std::string& frame_name,
154+
WindowOpenDisposition disposition,
155+
const blink::mojom::WindowFeatures& features,
156+
const std::vector<std::string>& additional_features,
157+
const scoped_refptr<content::ResourceRequestBody>& body,
158+
bool user_gesture,
159+
bool opener_suppressed,
160+
bool* no_javascript_access) override;
155161

156162
// content::GpuDataManagerObserver:
157163
void OnGpuProcessCrashed(base::TerminationStatus status) override;

atom/browser/atom_browser_client.cc

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,7 @@ bool AtomBrowserClient::CanCreateWindow(
351351
bool user_gesture,
352352
bool opener_suppressed,
353353
bool* no_javascript_access) {
354-
// FIXME: Ensure the DCHECK doesn't fail and then re-enable
355-
// DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
354+
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
356355

357356
int opener_render_process_id = opener->GetProcess()->GetID();
358357

@@ -373,15 +372,11 @@ bool AtomBrowserClient::CanCreateWindow(
373372
}
374373

375374
if (delegate_) {
376-
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
377-
base::Bind(&api::App::OnCreateWindow,
378-
base::Unretained(static_cast<api::App*>(delegate_)),
379-
target_url,
380-
frame_name,
381-
disposition,
382-
additional_features,
383-
body,
384-
opener));
375+
return delegate_->CanCreateWindow(
376+
opener, opener_url, opener_top_level_frame_url, source_origin,
377+
container_type, target_url, referrer, frame_name, disposition, features,
378+
additional_features, body, user_gesture, opener_suppressed,
379+
no_javascript_access);
385380
}
386381

387382
return false;

brightray/browser/browser_main_parts.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "base/strings/utf_string_conversions.h"
1919
#include "brightray/browser/browser_context.h"
2020
#include "brightray/browser/devtools_manager_delegate.h"
21+
#include "brightray/browser/media/media_capture_devices_dispatcher.h"
2122
#include "brightray/browser/web_ui_controller_factory.h"
2223
#include "brightray/common/application_info.h"
2324
#include "brightray/common/main_delegate.h"
@@ -268,6 +269,9 @@ int BrowserMainParts::PreCreateThreads() {
268269
#endif
269270
#endif
270271

272+
// Force MediaCaptureDevicesDispatcher to be created on UI thread.
273+
MediaCaptureDevicesDispatcher::GetInstance();
274+
271275
if (!views::LayoutProvider::Get())
272276
layout_provider_.reset(new views::LayoutProvider());
273277

brightray/browser/media/media_capture_devices_dispatcher.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher()
4444
: is_device_enumeration_disabled_(false) {
4545
// MediaCaptureDevicesDispatcher is a singleton. It should be created on
4646
// UI thread.
47-
// FIXME: Ensure the DCHECK doesn't fail and then re-enable
48-
// DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
47+
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
4948
}
5049

5150
MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {}

0 commit comments

Comments
 (0)