From 9ee47385d5f79444c5d28558ae3338e737aec849 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 4 Apr 2017 12:16:42 +0900 Subject: [PATCH 01/12] Update libchromiumcontent to Chrome 58 --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 44448acf6a21..8c3e53238581 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 44448acf6a21024b9adb7140ffef6402a509f8bf +Subproject commit 8c3e532385811b5cea80e969c1beb1bf3ffb6777 From fdb880eca2cdc1c3391642b1c2486805afff6de3 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 4 Apr 2017 12:36:15 +0900 Subject: [PATCH 02/12] Remove the ENABLE_WEBRTC define Headers are now defined in gen/media/media_features.h. --- brightray/brightray.gypi | 2 -- 1 file changed, 2 deletions(-) diff --git a/brightray/brightray.gypi b/brightray/brightray.gypi index 064ae1a2df0e..b7fb38be63ab 100644 --- a/brightray/brightray.gypi +++ b/brightray/brightray.gypi @@ -92,8 +92,6 @@ 'Common_Base': { 'abstract': 1, 'defines': [ - # Used by content_browser_client.h: - 'ENABLE_WEBRTC', # We are using Release version libchromiumcontent: 'NDEBUG', # Needed by gin: From 0a110a44f91993c48c15e225d68f4a412777ec60 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 4 Apr 2017 13:26:50 +0900 Subject: [PATCH 03/12] ScopedPtrHashMap has been removed --- .../browser/inspectable_web_contents_impl.cc | 2 +- .../browser/inspectable_web_contents_impl.h | 2 +- .../net/devtools_network_controller.cc | 21 +++++++++---------- .../browser/net/devtools_network_controller.h | 11 +++++++--- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 4c5209742739..0bf9b6732a3d 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -689,7 +689,7 @@ bool InspectableWebContentsImpl::ShouldCreateWebContents( int32_t route_id, int32_t main_frame_route_id, int32_t main_frame_widget_route_id, - WindowContainerType window_container_type, + content::mojom::WindowContainerType window_container_type, const std::string& frame_name, const GURL& target_url, const std::string& partition_id, diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index 2f000c210227..31ebd392b266 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -146,7 +146,7 @@ class InspectableWebContentsImpl : int32_t route_id, int32_t main_frame_route_id, int32_t main_frame_widget_route_id, - WindowContainerType window_container_type, + content::mojom::WindowContainerType window_container_type, const std::string& frame_name, const GURL& target_url, const std::string& partition_id, diff --git a/brightray/browser/net/devtools_network_controller.cc b/brightray/browser/net/devtools_network_controller.cc index 07b469b1f77c..8bf411ac1a4e 100644 --- a/brightray/browser/net/devtools_network_controller.cc +++ b/brightray/browser/net/devtools_network_controller.cc @@ -27,29 +27,28 @@ void DevToolsNetworkController::SetNetworkState( std::unique_ptr conditions) { DCHECK_CURRENTLY_ON(BrowserThread::IO); - DevToolsNetworkInterceptor* interceptor = interceptors_.get(client_id); - if (!interceptor) { + auto it = interceptors_.find(client_id); + if (it == interceptors_.end()) { if (!conditions) return; std::unique_ptr new_interceptor( new DevToolsNetworkInterceptor); new_interceptor->UpdateConditions(std::move(conditions)); - interceptors_.set(client_id, std::move(new_interceptor)); + interceptors_[client_id] = std::move(new_interceptor); } else { if (!conditions) { std::unique_ptr online_conditions( new DevToolsNetworkConditions(false)); - interceptor->UpdateConditions(std::move(online_conditions)); + it->second->UpdateConditions(std::move(online_conditions)); interceptors_.erase(client_id); } else { - interceptor->UpdateConditions(std::move(conditions)); + it->second->UpdateConditions(std::move(conditions)); } } bool has_offline_interceptors = false; - auto it = interceptors_.begin(); - for (; it != interceptors_.end(); ++it) { - if (it->second->IsOffline()) { + for (const auto& interceptor : interceptors_) { + if (interceptor.second->IsOffline()) { has_offline_interceptors = true; break; } @@ -70,11 +69,11 @@ DevToolsNetworkController::GetInterceptor(const std::string& client_id) { if (interceptors_.empty() || client_id.empty()) return nullptr; - DevToolsNetworkInterceptor* interceptor = interceptors_.get(client_id); - if (!interceptor) + auto it = interceptors_.find(client_id); + if (it == interceptors_.end()) return nullptr; - return interceptor; + return it->second.get(); } } // namespace brightray diff --git a/brightray/browser/net/devtools_network_controller.h b/brightray/browser/net/devtools_network_controller.h index 7e6c948b42b9..c36d888df110 100644 --- a/brightray/browser/net/devtools_network_controller.h +++ b/brightray/browser/net/devtools_network_controller.h @@ -5,8 +5,12 @@ #ifndef BROWSER_DEVTOOLS_NETWORK_CONTROLLER_H_ #define BROWSER_DEVTOOLS_NETWORK_CONTROLLER_H_ -#include "base/containers/scoped_ptr_hash_map.h" +#include +#include +#include + #include "base/macros.h" +#include "base/threading/thread_checker.h" namespace brightray { @@ -21,12 +25,13 @@ class DevToolsNetworkController { void SetNetworkState(const std::string& client_id, std::unique_ptr conditions); + DevToolsNetworkInterceptor* GetInterceptor(const std::string& client_id); private: using InterceptorMap = - base::ScopedPtrHashMap>; + std::unordered_map>; std::unique_ptr appcache_interceptor_; InterceptorMap interceptors_; From c41fb922b3ab7b555db53c0315fe14da1dc6f68f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 4 Apr 2017 13:43:49 +0900 Subject: [PATCH 04/12] Fix API changes of Chrome 58 --- brightray/browser/browser_main_parts.cc | 2 +- .../devtools_embedder_message_dispatcher.cc | 1 - .../devtools_embedder_message_dispatcher.h | 1 - .../browser/inspectable_web_contents_impl.cc | 21 +++++-------------- .../browser/inspectable_web_contents_impl.h | 3 ++- brightray/browser/network_delegate.cc | 8 ------- brightray/browser/network_delegate.h | 1 - brightray/browser/permission_manager.cc | 6 ------ brightray/browser/permission_manager.h | 3 --- .../browser/platform_notification_service.cc | 2 +- .../browser/platform_notification_service.h | 2 +- brightray/browser/special_storage_policy.cc | 10 +++------ brightray/browser/special_storage_policy.h | 3 +-- 13 files changed, 14 insertions(+), 49 deletions(-) diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc index aa2a60eb901f..ab2e484f1d38 100644 --- a/brightray/browser/browser_main_parts.cc +++ b/brightray/browser/browser_main_parts.cc @@ -15,7 +15,7 @@ #include "base/strings/utf_string_conversions.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/content_switches.h" -#include "media/base/media_resources.h" +#include "media/base/localized_strings.h" #include "net/proxy/proxy_resolver_v8.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/material_design/material_design_controller.h" diff --git a/brightray/browser/devtools_embedder_message_dispatcher.cc b/brightray/browser/devtools_embedder_message_dispatcher.cc index ffba3268aecf..13c54c4c7eca 100644 --- a/brightray/browser/devtools_embedder_message_dispatcher.cc +++ b/brightray/browser/devtools_embedder_message_dispatcher.cc @@ -194,7 +194,6 @@ DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend( d->RegisterHandler("dispatchProtocolMessage", &Delegate::DispatchProtocolMessageFromDevToolsFrontend, delegate); - d->RegisterHandler("recordActionUMA", &Delegate::RecordActionUMA, delegate); d->RegisterHandlerWithCallback("sendJsonRequest", &Delegate::SendJsonRequest, delegate); d->RegisterHandlerWithCallback("getPreferences", diff --git a/brightray/browser/devtools_embedder_message_dispatcher.h b/brightray/browser/devtools_embedder_message_dispatcher.h index 4401bd5ab85e..b77a83fc07c1 100644 --- a/brightray/browser/devtools_embedder_message_dispatcher.h +++ b/brightray/browser/devtools_embedder_message_dispatcher.h @@ -70,7 +70,6 @@ class DevToolsEmbedderMessageDispatcher { virtual void SetDevicesUpdatesEnabled(bool enabled) = 0; virtual void DispatchProtocolMessageFromDevToolsFrontend( const std::string& message) = 0; - virtual void RecordActionUMA(const std::string& name, int action) = 0; virtual void SendJsonRequest(const DispatchCallback& callback, const std::string& browser_id, const std::string& url) = 0; diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 0bf9b6732a3d..f4eb15d3650b 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -61,11 +61,6 @@ const char kFrontendHostMethod[] = "method"; const char kFrontendHostParams[] = "params"; const char kTitleFormat[] = "Developer Tools - %s"; -const char kDevToolsActionTakenHistogram[] = "DevTools.ActionTaken"; -const int kDevToolsActionTakenBoundary = 100; -const char kDevToolsPanelShownHistogram[] = "DevTools.PanelShown"; -const int kDevToolsPanelShownBoundary = 20; - const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4; void RectToDictionary(const gfx::Rect& bounds, base::DictionaryValue* dict) { @@ -171,7 +166,7 @@ int ResponseWriter::Initialize(const net::CompletionCallback& callback) { int ResponseWriter::Write(net::IOBuffer* buffer, int num_bytes, const net::CompletionCallback& callback) { - auto* id = new base::FundamentalValue(stream_id_); + auto* id = new base::Value(stream_id_); base::StringValue* chunk = new base::StringValue(std::string(buffer->data(), num_bytes)); @@ -563,14 +558,6 @@ void InspectableWebContentsImpl::DispatchProtocolMessageFromDevToolsFrontend( agent_host_->DispatchProtocolMessage(this, message); } -void InspectableWebContentsImpl::RecordActionUMA(const std::string& name, - int action) { - if (name == kDevToolsActionTakenHistogram) - UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsActionTakenBoundary); - else if (name == kDevToolsPanelShownHistogram) - UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsPanelShownBoundary); -} - void InspectableWebContentsImpl::SendJsonRequest( const DispatchCallback& callback, const std::string& browser_id, @@ -639,7 +626,7 @@ void InspectableWebContentsImpl::DispatchProtocolMessage( return; } - base::FundamentalValue total_size(static_cast(message.length())); + base::Value total_size(static_cast(message.length())); for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { base::StringValue message_value(message.substr(pos, kMaxMessageChunkSize)); CallClientFunction("DevToolsAPI.dispatchMessageChunk", @@ -686,10 +673,12 @@ bool InspectableWebContentsImpl::DidAddMessageToConsole( bool InspectableWebContentsImpl::ShouldCreateWebContents( content::WebContents* web_contents, + content::SiteInstance* source_site_instance, int32_t route_id, int32_t main_frame_route_id, int32_t main_frame_widget_route_id, content::mojom::WindowContainerType window_container_type, + const GURL& opener_url, const std::string& frame_name, const GURL& target_url, const std::string& partition_id, @@ -777,7 +766,7 @@ void InspectableWebContentsImpl::OnURLFetchComplete( void InspectableWebContentsImpl::SendMessageAck(int request_id, const base::Value* arg) { - base::FundamentalValue id_value(request_id); + base::Value id_value(request_id); CallClientFunction("DevToolsAPI.embedderMessageAck", &id_value, arg, nullptr); } diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index 31ebd392b266..25cffa957aff 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -107,7 +107,6 @@ class InspectableWebContentsImpl : void SetDevicesUpdatesEnabled(bool enabled) override; void DispatchProtocolMessageFromDevToolsFrontend( const std::string& message) override; - void RecordActionUMA(const std::string& name, int action) override; void SendJsonRequest(const DispatchCallback& callback, const std::string& browser_id, const std::string& url) override; @@ -143,10 +142,12 @@ class InspectableWebContentsImpl : const base::string16& source_id) override; bool ShouldCreateWebContents( content::WebContents* web_contents, + content::SiteInstance* source_site_instance, int32_t route_id, int32_t main_frame_route_id, int32_t main_frame_widget_route_id, content::mojom::WindowContainerType window_container_type, + const GURL& opener_url, const std::string& frame_name, const GURL& target_url, const std::string& partition_id, diff --git a/brightray/browser/network_delegate.cc b/brightray/browser/network_delegate.cc index 2af03e0f959f..59b842768bde 100644 --- a/brightray/browser/network_delegate.cc +++ b/brightray/browser/network_delegate.cc @@ -134,14 +134,6 @@ bool NetworkDelegate::OnCanEnablePrivacyMode( return false; } -bool NetworkDelegate::OnAreStrictSecureCookiesEnabled() const { - return true; -} - -bool NetworkDelegate::OnAreExperimentalCookieFeaturesEnabled() const { - return true; -} - bool NetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( const net::URLRequest& request, const GURL& target_url, diff --git a/brightray/browser/network_delegate.h b/brightray/browser/network_delegate.h index 752434222aca..b8a8b5225368 100644 --- a/brightray/browser/network_delegate.h +++ b/brightray/browser/network_delegate.h @@ -63,7 +63,6 @@ class NetworkDelegate : public net::NetworkDelegate { bool OnCanEnablePrivacyMode( const GURL& url, const GURL& first_party_for_cookies) const override; - bool OnAreStrictSecureCookiesEnabled() const override; bool OnAreExperimentalCookieFeaturesEnabled() const override; bool OnCancelURLRequestWithPolicyViolatingReferrerHeader( const net::URLRequest& request, diff --git a/brightray/browser/permission_manager.cc b/brightray/browser/permission_manager.cc index f2b0d97d9baf..198e35d8c38c 100644 --- a/brightray/browser/permission_manager.cc +++ b/brightray/browser/permission_manager.cc @@ -70,12 +70,6 @@ blink::mojom::PermissionStatus PermissionManager::GetPermissionStatus( return blink::mojom::PermissionStatus::GRANTED; } -void PermissionManager::RegisterPermissionUsage( - content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin) { -} - int PermissionManager::SubscribePermissionStatusChange( content::PermissionType permission, const GURL& requesting_origin, diff --git a/brightray/browser/permission_manager.h b/brightray/browser/permission_manager.h index 7e9a283913f3..734529f06eb4 100644 --- a/brightray/browser/permission_manager.h +++ b/brightray/browser/permission_manager.h @@ -40,9 +40,6 @@ class PermissionManager : public content::PermissionManager { content::PermissionType permission, const GURL& requesting_origin, const GURL& embedding_origin) override; - void RegisterPermissionUsage(content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin) override; int SubscribePermissionStatusChange( content::PermissionType permission, const GURL& requesting_origin, diff --git a/brightray/browser/platform_notification_service.cc b/brightray/browser/platform_notification_service.cc index 8f9f16a2c17f..36c515153537 100644 --- a/brightray/browser/platform_notification_service.cc +++ b/brightray/browser/platform_notification_service.cc @@ -100,7 +100,7 @@ void PlatformNotificationService::ClosePersistentNotification( const std::string& notification_id) { } -bool PlatformNotificationService::GetDisplayedPersistentNotifications( +bool PlatformNotificationService::GetDisplayedNotifications( content::BrowserContext* browser_context, std::set* displayed_notifications) { return false; diff --git a/brightray/browser/platform_notification_service.h b/brightray/browser/platform_notification_service.h index b2b6471d0fde..f9b09c64bdff 100644 --- a/brightray/browser/platform_notification_service.h +++ b/brightray/browser/platform_notification_service.h @@ -45,7 +45,7 @@ class PlatformNotificationService const content::NotificationResources& notification_resources) override; void ClosePersistentNotification(content::BrowserContext* browser_context, const std::string& notification_id) override; - bool GetDisplayedPersistentNotifications( + bool GetDisplayedNotifications( content::BrowserContext* browser_context, std::set* displayed_notifications) override; diff --git a/brightray/browser/special_storage_policy.cc b/brightray/browser/special_storage_policy.cc index 77a302bb1f8f..2010dbd1a041 100644 --- a/brightray/browser/special_storage_policy.cc +++ b/brightray/browser/special_storage_policy.cc @@ -24,20 +24,16 @@ bool SpecialStoragePolicy::IsStorageDurable(const GURL& origin) { return true; } -bool SpecialStoragePolicy::IsStorageSessionOnly(const GURL& origin) { +bool SpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) { return false; } -bool SpecialStoragePolicy::CanQueryDiskSize(const GURL& origin) { - return true; +bool SpecialStoragePolicy::IsStorageSessionOnly(const GURL& origin) { + return false; } bool SpecialStoragePolicy::HasSessionOnlyOrigins() { return false; } -bool SpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) { - return false; -} - } // namespace brightray diff --git a/brightray/browser/special_storage_policy.h b/brightray/browser/special_storage_policy.h index 265df536cf23..0c89db2d4c51 100644 --- a/brightray/browser/special_storage_policy.h +++ b/brightray/browser/special_storage_policy.h @@ -17,9 +17,8 @@ class SpecialStoragePolicy : public storage::SpecialStoragePolicy { bool IsStorageProtected(const GURL& origin) override; bool IsStorageUnlimited(const GURL& origin) override; bool IsStorageDurable(const GURL& origin) override; - bool IsStorageSessionOnly(const GURL& origin) override; - bool CanQueryDiskSize(const GURL& origin) override; bool HasIsolatedStorage(const GURL& origin) override; + bool IsStorageSessionOnly(const GURL& origin) override; bool HasSessionOnlyOrigins() override; protected: From bbd474966884c4eb998e43c8ff8db32d619b99f6 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 4 Apr 2017 15:56:35 +0900 Subject: [PATCH 05/12] base::WrapUnique has changed its API --- brightray/browser/url_request_context_getter.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index a9e0a22756b1..2e483d62ae5f 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -195,9 +195,8 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { std::unique_ptr cookie_store = content::CreateCookieStore(cookie_config); storage_->set_cookie_store(std::move(cookie_store)); - storage_->set_channel_id_service(base::WrapUnique( - new net::ChannelIDService(new net::DefaultChannelIDStore(nullptr), - base::WorkerPool::GetTaskRunner(true)))); + storage_->set_channel_id_service(base::MakeUnique( + new net::DefaultChannelIDStore(nullptr))); std::string accept_lang = l10n_util::GetApplicationLocale(""); storage_->set_http_user_agent_settings(base::WrapUnique( @@ -354,9 +353,9 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { it != protocol_interceptors_.rend(); ++it) { top_job_factory.reset(new net::URLRequestInterceptingJobFactory( - std::move(top_job_factory), base::WrapUnique(*it))); + std::move(top_job_factory), std::move(*it))); } - protocol_interceptors_.weak_clear(); + protocol_interceptors_.clear(); storage_->set_job_factory(std::move(top_job_factory)); } From affd80aef0f710828e795378ea00aa42aa888426 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 11 Apr 2017 15:14:36 +0900 Subject: [PATCH 06/12] Add gen/third_party/WebKit to include dirs --- brightray/brightray.gyp | 1 + 1 file changed, 1 insertion(+) diff --git a/brightray/brightray.gyp b/brightray/brightray.gyp index e60d17a1585a..0c96237f4efd 100644 --- a/brightray/brightray.gyp +++ b/brightray/brightray.gyp @@ -35,6 +35,7 @@ '<(libchromiumcontent_src_dir)/third_party/khronos', '<(libchromiumcontent_src_dir)/third_party/WebKit', '<(libchromiumcontent_dir)/gen', + '<(libchromiumcontent_dir)/gen/third_party/WebKit', ], }, 'sources': [ '<@(brightray_sources)' ], From 79a441874ee5acc2135e367ffb588c728b1401b6 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 13 Apr 2017 20:04:08 +0900 Subject: [PATCH 07/12] Fill missing NetworkDelegate method --- brightray/browser/network_delegate.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/brightray/browser/network_delegate.cc b/brightray/browser/network_delegate.cc index 59b842768bde..f7be1b028b68 100644 --- a/brightray/browser/network_delegate.cc +++ b/brightray/browser/network_delegate.cc @@ -134,6 +134,10 @@ bool NetworkDelegate::OnCanEnablePrivacyMode( return false; } +bool NetworkDelegate::OnAreExperimentalCookieFeaturesEnabled() const { + return true; +} + bool NetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( const net::URLRequest& request, const GURL& target_url, From 98c039c880068ff2d31ebec99aeaf3b2af6fdc20 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 20 Mar 2017 12:22:46 -0700 Subject: [PATCH 08/12] Detach from devtools before destroying Otherwise Electron would crash on exit in Chrome 58. --- brightray/browser/inspectable_web_contents_impl.cc | 13 ++++++++++--- brightray/vendor/libchromiumcontent | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index f4eb15d3650b..8efb160f63f3 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -235,9 +235,14 @@ InspectableWebContentsImpl::InspectableWebContentsImpl( } InspectableWebContentsImpl::~InspectableWebContentsImpl() { - if (devtools_web_contents_) - devtools_web_contents_->Close(); - Observe(nullptr); + // Unsubscribe from devtools and Clean up resources. + if (devtools_web_contents_) { + devtools_web_contents_->SetDelegate(nullptr); + // Calling this also unsubscribes the observer, so WebContentsDestroyed + // won't be called again. + WebContentsDestroyed(); + } + // Let destructor destroy devtools_web_contents_. } InspectableWebContentsView* InspectableWebContentsImpl::GetView() const { @@ -651,6 +656,7 @@ void InspectableWebContentsImpl::RenderFrameHostChanged( void InspectableWebContentsImpl::WebContentsDestroyed() { frontend_loaded_ = false; + Observe(nullptr); Detach(); for (const auto& pair : pending_requests_) @@ -695,6 +701,7 @@ void InspectableWebContentsImpl::HandleKeyboardEvent( } void InspectableWebContentsImpl::CloseContents(content::WebContents* source) { + // This is where the devtools closes itself (by clicking the x button). CloseDevTools(); } diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 8c3e53238581..791141a820ec 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 8c3e532385811b5cea80e969c1beb1bf3ffb6777 +Subproject commit 791141a820ecf6166a86249701838b57f43777ea From b82845dc4a6908f4dc2903073a5d25d081eecbf2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 17 Apr 2017 16:10:30 +0900 Subject: [PATCH 09/12] A quick fix for crashing when closing devtools --- brightray/browser/inspectable_web_contents_impl.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 8efb160f63f3..20ee3081558a 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -310,6 +310,7 @@ void InspectableWebContentsImpl::ShowDevTools() { void InspectableWebContentsImpl::CloseDevTools() { if (devtools_web_contents_) { + frontend_loaded_ = false; view_->CloseDevTools(); devtools_web_contents_.reset(); web_contents_->Focus(); From 55e9c3196a59a92cf0b55ea2b1639e7b54b97174 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 17 Apr 2017 16:52:24 +0900 Subject: [PATCH 10/12] Fix building on Linux --- brightray/browser/browser_main_parts.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc index ab2e484f1d38..8d46b4af4b4c 100644 --- a/brightray/browser/browser_main_parts.cc +++ b/brightray/browser/browser_main_parts.cc @@ -163,7 +163,7 @@ void BrowserMainParts::PreEarlyInitialization() { base::FeatureList::SetInstance(std::move(feature_list)); #if defined(USE_X11) - views::LinuxUI::SetInstance(BuildGtk2UI()); + views::LinuxUI::SetInstance(BuildGtkUi()); OverrideLinuxAppDataPath(); // Installs the X11 error handlers for the browser process used during From 70d67f9da4429a0e28730f669e193a4965dca935 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 18 Apr 2017 16:05:57 +0900 Subject: [PATCH 11/12] Link with VideoToolbox.framework --- brightray/brightray.gyp | 2 ++ brightray/vendor/libchromiumcontent | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/brightray/brightray.gyp b/brightray/brightray.gyp index 0c96237f4efd..85b319783a8e 100644 --- a/brightray/brightray.gyp +++ b/brightray/brightray.gyp @@ -162,6 +162,8 @@ # Required by webrtc: '$(SDKROOT)/System/Library/Frameworks/OpenGL.framework', '$(SDKROOT)/System/Library/Frameworks/IOKit.framework', + # Required by media: + '$(SDKROOT)/System/Library/Frameworks/VideoToolbox.framework', ], }, 'conditions': [ diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 791141a820ec..72cfdcb1b916 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 791141a820ecf6166a86249701838b57f43777ea +Subproject commit 72cfdcb1b916546cf198cf39c8fc53c3175c248c From 3601ae3549d3ed00dfa927cb8546be4bf198656e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 27 Apr 2017 17:50:02 +0900 Subject: [PATCH 12/12] Update to Chrome 58.0.3029.81 --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 72cfdcb1b916..3ca4584486ac 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 72cfdcb1b916546cf198cf39c8fc53c3175c248c +Subproject commit 3ca4584486acbfb4b344c7ce956fdcd40a4ed63e