refactor: move media/net from brightray to atom (#15288)

This commit is contained in:
Milan Burda 2018-10-19 20:51:43 +02:00 committed by John Kleinschmidt
parent 6f3c46cc7e
commit 6d844a0b67
32 changed files with 108 additions and 152 deletions

View file

@ -19,6 +19,7 @@
#include "atom/browser/atom_browser_main_parts.h" #include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_permission_manager.h" #include "atom/browser/atom_permission_manager.h"
#include "atom/browser/browser.h" #include "atom/browser/browser.h"
#include "atom/browser/media/media_device_id_salt.h"
#include "atom/browser/net/atom_cert_verifier.h" #include "atom/browser/net/atom_cert_verifier.h"
#include "atom/browser/session_preferences.h" #include "atom/browser/session_preferences.h"
#include "atom/common/native_mate_converters/callback.h" #include "atom/common/native_mate_converters/callback.h"
@ -31,7 +32,6 @@
#include "base/guid.h" #include "base/guid.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "brightray/browser/media/media_device_id_salt.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/download/public/common/download_danger_type.h" #include "components/download/public/common/download_danger_type.h"
@ -440,7 +440,7 @@ void Session::ClearStorageData(mate::Arguments* args) {
if (options.storage_types & StoragePartition::REMOVE_DATA_MASK_COOKIES) { if (options.storage_types & StoragePartition::REMOVE_DATA_MASK_COOKIES) {
// Reset media device id salt when cookies are cleared. // Reset media device id salt when cookies are cleared.
// https://w3c.github.io/mediacapture-main/#dom-mediadeviceinfo-deviceid // https://w3c.github.io/mediacapture-main/#dom-mediadeviceinfo-deviceid
brightray::MediaDeviceIDSalt::Reset(browser_context()->prefs()); MediaDeviceIDSalt::Reset(browser_context()->prefs());
} }
storage_partition->ClearData( storage_partition->ClearData(
options.storage_types, options.quota_types, options.origin, options.storage_types, options.quota_types, options.origin,

View file

@ -22,6 +22,7 @@
#include "atom/browser/atom_speech_recognition_manager_delegate.h" #include "atom/browser/atom_speech_recognition_manager_delegate.h"
#include "atom/browser/child_web_contents_tracker.h" #include "atom/browser/child_web_contents_tracker.h"
#include "atom/browser/io_thread.h" #include "atom/browser/io_thread.h"
#include "atom/browser/media/media_capture_devices_dispatcher.h"
#include "atom/browser/native_window.h" #include "atom/browser/native_window.h"
#include "atom/browser/notifications/notification_presenter.h" #include "atom/browser/notifications/notification_presenter.h"
#include "atom/browser/notifications/platform_notification_service.h" #include "atom/browser/notifications/platform_notification_service.h"
@ -683,6 +684,10 @@ AtomBrowserClient::CreateThrottlesForNavigation(
return throttles; return throttles;
} }
content::MediaObserver* AtomBrowserClient::GetMediaObserver() {
return MediaCaptureDevicesDispatcher::GetInstance();
}
content::DevToolsManagerDelegate* content::DevToolsManagerDelegate*
AtomBrowserClient::GetDevToolsManagerDelegate() { AtomBrowserClient::GetDevToolsManagerDelegate() {
return new DevToolsManagerDelegate; return new DevToolsManagerDelegate;

View file

@ -127,6 +127,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
std::unique_ptr<base::Value> GetServiceManifestOverlay( std::unique_ptr<base::Value> GetServiceManifestOverlay(
base::StringPiece name) override; base::StringPiece name) override;
net::NetLog* GetNetLog() override; net::NetLog* GetNetLog() override;
content::MediaObserver* GetMediaObserver() override;
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override; content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
content::PlatformNotificationService* GetPlatformNotificationService() content::PlatformNotificationService* GetPlatformNotificationService()
override; override;

View file

@ -17,6 +17,7 @@
#include "atom/browser/special_storage_policy.h" #include "atom/browser/special_storage_policy.h"
#include "atom/browser/ui/inspectable_web_contents_impl.h" #include "atom/browser/ui/inspectable_web_contents_impl.h"
#include "atom/browser/web_view_manager.h" #include "atom/browser/web_view_manager.h"
#include "atom/browser/zoom_level_delegate.h"
#include "atom/common/atom_version.h" #include "atom/common/atom_version.h"
#include "atom/common/chrome_version.h" #include "atom/common/chrome_version.h"
#include "atom/common/options_switches.h" #include "atom/common/options_switches.h"
@ -28,7 +29,6 @@
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "brightray/browser/brightray_paths.h" #include "brightray/browser/brightray_paths.h"
#include "brightray/browser/zoom_level_delegate.h"
#include "brightray/common/application_info.h" #include "brightray/common/application_info.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
@ -153,8 +153,8 @@ void AtomBrowserContext::InitPrefs() {
download_dir); download_dir);
registry->RegisterDictionaryPref(prefs::kDevToolsFileSystemPaths); registry->RegisterDictionaryPref(prefs::kDevToolsFileSystemPaths);
InspectableWebContentsImpl::RegisterPrefs(registry.get()); InspectableWebContentsImpl::RegisterPrefs(registry.get());
brightray::MediaDeviceIDSalt::RegisterPrefs(registry.get()); MediaDeviceIDSalt::RegisterPrefs(registry.get());
brightray::ZoomLevelDelegate::RegisterPrefs(registry.get()); ZoomLevelDelegate::RegisterPrefs(registry.get());
PrefProxyConfigTrackerImpl::RegisterPrefs(registry.get()); PrefProxyConfigTrackerImpl::RegisterPrefs(registry.get());
prefs_ = prefs_factory.Create( prefs_ = prefs_factory.Create(
@ -210,7 +210,7 @@ content::ResourceContext* AtomBrowserContext::GetResourceContext() {
std::string AtomBrowserContext::GetMediaDeviceIDSalt() { std::string AtomBrowserContext::GetMediaDeviceIDSalt() {
if (!media_device_id_salt_.get()) if (!media_device_id_salt_.get())
media_device_id_salt_.reset(new brightray::MediaDeviceIDSalt(prefs_.get())); media_device_id_salt_.reset(new MediaDeviceIDSalt(prefs_.get()));
return media_device_id_salt_->GetSalt(); return media_device_id_salt_->GetSalt();
} }
@ -218,8 +218,7 @@ std::unique_ptr<content::ZoomLevelDelegate>
AtomBrowserContext::CreateZoomLevelDelegate( AtomBrowserContext::CreateZoomLevelDelegate(
const base::FilePath& partition_path) { const base::FilePath& partition_path) {
if (!IsOffTheRecord()) { if (!IsOffTheRecord()) {
return std::make_unique<brightray::ZoomLevelDelegate>(prefs(), return std::make_unique<ZoomLevelDelegate>(prefs(), partition_path);
partition_path);
} }
return std::unique_ptr<content::ZoomLevelDelegate>(); return std::unique_ptr<content::ZoomLevelDelegate>();
} }

View file

@ -10,10 +10,10 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "atom/browser/media/media_device_id_salt.h"
#include "atom/browser/net/url_request_context_getter.h" #include "atom/browser/net/url_request_context_getter.h"
#include "base/memory/ref_counted_delete_on_sequence.h" #include "base/memory/ref_counted_delete_on_sequence.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "brightray/browser/media/media_device_id_salt.h"
#include "chrome/browser/net/proxy_config_monitor.h" #include "chrome/browser/net/proxy_config_monitor.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
@ -152,7 +152,7 @@ class AtomBrowserContext
std::unique_ptr<WebViewManager> guest_manager_; std::unique_ptr<WebViewManager> guest_manager_;
std::unique_ptr<AtomPermissionManager> permission_manager_; std::unique_ptr<AtomPermissionManager> permission_manager_;
std::unique_ptr<AtomBlobReader> blob_reader_; std::unique_ptr<AtomBlobReader> blob_reader_;
std::unique_ptr<brightray::MediaDeviceIDSalt> media_device_id_salt_; std::unique_ptr<MediaDeviceIDSalt> media_device_id_salt_;
scoped_refptr<ResolveProxyHelper> resolve_proxy_helper_; scoped_refptr<ResolveProxyHelper> resolve_proxy_helper_;
scoped_refptr<storage::SpecialStoragePolicy> storage_policy_; scoped_refptr<storage::SpecialStoragePolicy> storage_policy_;

View file

@ -14,6 +14,7 @@
#include "atom/browser/browser.h" #include "atom/browser/browser.h"
#include "atom/browser/io_thread.h" #include "atom/browser/io_thread.h"
#include "atom/browser/javascript_environment.h" #include "atom/browser/javascript_environment.h"
#include "atom/browser/media/media_capture_devices_dispatcher.h"
#include "atom/browser/node_debugger.h" #include "atom/browser/node_debugger.h"
#include "atom/browser/ui/devtools_manager_delegate.h" #include "atom/browser/ui/devtools_manager_delegate.h"
#include "atom/common/api/atom_bindings.h" #include "atom/common/api/atom_bindings.h"
@ -177,6 +178,9 @@ int AtomBrowserMainParts::PreCreateThreads() {
brightray::BrowserClient::Get()->GetApplicationLocale()); brightray::BrowserClient::Get()->GetApplicationLocale());
} }
// Force MediaCaptureDevicesDispatcher to be created on UI thread.
MediaCaptureDevicesDispatcher::GetInstance();
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
ui::InitIdleMonitor(); ui::InitIdleMonitor();
#endif #endif

View file

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-CHROMIUM file. // found in the LICENSE-CHROMIUM file.
#include "brightray/browser/media/media_capture_devices_dispatcher.h" #include "atom/browser/media/media_capture_devices_dispatcher.h"
#include "base/logging.h" #include "base/logging.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/media_capture_devices.h" #include "content/public/browser/media_capture_devices.h"
#include "content/public/common/media_stream_request.h" #include "content/public/common/media_stream_request.h"
namespace brightray { namespace atom {
using content::BrowserThread; using content::BrowserThread;
using content::MediaStreamDevices; using content::MediaStreamDevices;
@ -149,4 +149,4 @@ void MediaCaptureDevicesDispatcher::OnSetCapturingLinkSecured(
content::MediaStreamType stream_type, content::MediaStreamType stream_type,
bool is_secure) {} bool is_secure) {}
} // namespace brightray } // namespace atom

View file

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-CHROMIUM file. // found in the LICENSE-CHROMIUM file.
#ifndef BRIGHTRAY_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ #ifndef ATOM_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
#define BRIGHTRAY_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ #define ATOM_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
#include <string> #include <string>
@ -11,7 +11,7 @@
#include "content/public/browser/media_observer.h" #include "content/public/browser/media_observer.h"
#include "content/public/common/media_stream_request.h" #include "content/public/common/media_stream_request.h"
namespace brightray { namespace atom {
// This singleton is used to receive updates about media events from the content // This singleton is used to receive updates about media events from the content
// layer. // layer.
@ -78,6 +78,6 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher); DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher);
}; };
} // namespace brightray } // namespace atom
#endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ #endif // ATOM_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_

View file

@ -1,7 +1,8 @@
// Copyright 2013 The Chromium Authors. All rights reserved. // Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "brightray/browser/media/media_device_id_salt.h"
#include "atom/browser/media/media_device_id_salt.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
@ -10,7 +11,7 @@
using content::BrowserThread; using content::BrowserThread;
namespace brightray { namespace atom {
namespace { namespace {
@ -50,4 +51,4 @@ void MediaDeviceIDSalt::Reset(PrefService* pref_service) {
content::BrowserContext::CreateRandomMediaDeviceIDSalt()); content::BrowserContext::CreateRandomMediaDeviceIDSalt());
} }
} // namespace brightray } // namespace atom

View file

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef BRIGHTRAY_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ #ifndef ATOM_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_
#define BRIGHTRAY_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ #define ATOM_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_
#include <string> #include <string>
@ -13,7 +13,7 @@
class PrefRegistrySimple; class PrefRegistrySimple;
class PrefService; class PrefService;
namespace brightray { namespace atom {
// MediaDeviceIDSalt is responsible for creating and retrieving a salt string // MediaDeviceIDSalt is responsible for creating and retrieving a salt string
// that is used for creating MediaSource IDs that can be cached by a web // that is used for creating MediaSource IDs that can be cached by a web
@ -34,6 +34,6 @@ class MediaDeviceIDSalt {
DISALLOW_COPY_AND_ASSIGN(MediaDeviceIDSalt); DISALLOW_COPY_AND_ASSIGN(MediaDeviceIDSalt);
}; };
} // namespace brightray } // namespace atom
#endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ #endif // ATOM_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_

View file

@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-CHROMIUM file. // found in the LICENSE-CHROMIUM file.
#include "brightray/browser/media/media_stream_devices_controller.h" #include "atom/browser/media/media_stream_devices_controller.h"
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "brightray/browser/media/media_capture_devices_dispatcher.h" #include "atom/browser/media/media_capture_devices_dispatcher.h"
#include "content/public/browser/desktop_media_id.h" #include "content/public/browser/desktop_media_id.h"
#include "content/public/common/media_stream_request.h" #include "content/public/common/media_stream_request.h"
namespace brightray { namespace atom {
namespace { namespace {
@ -188,4 +188,4 @@ void MediaStreamDevicesController::HandleUserMediaRequest() {
std::unique_ptr<content::MediaStreamUI>()); std::unique_ptr<content::MediaStreamUI>());
} }
} // namespace brightray } // namespace atom

View file

@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-CHROMIUM file. // found in the LICENSE-CHROMIUM file.
#ifndef BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ #ifndef ATOM_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
#define BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ #define ATOM_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
#include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_delegate.h"
namespace brightray { namespace atom {
class MediaStreamDevicesController { class MediaStreamDevicesController {
public: public:
@ -40,6 +40,6 @@ class MediaStreamDevicesController {
DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController);
}; };
} // namespace brightray } // namespace atom
#endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ #endif // ATOM_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_

View file

@ -7,10 +7,10 @@
#include <utility> #include <utility>
#include "atom/browser/browser.h" #include "atom/browser/browser.h"
#include "atom/browser/net/require_ct_delegate.h"
#include "atom/common/native_mate_converters/net_converter.h" #include "atom/common/native_mate_converters/net_converter.h"
#include "base/containers/linked_list.h" #include "base/containers/linked_list.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "brightray/browser/net/require_ct_delegate.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/cert/cert_verify_result.h" #include "net/cert/cert_verify_result.h"
@ -150,7 +150,7 @@ class CertVerifierRequest : public AtomCertVerifier::Request {
base::WeakPtrFactory<CertVerifierRequest> weak_ptr_factory_; base::WeakPtrFactory<CertVerifierRequest> weak_ptr_factory_;
}; };
AtomCertVerifier::AtomCertVerifier(brightray::RequireCTDelegate* ct_delegate) AtomCertVerifier::AtomCertVerifier(RequireCTDelegate* ct_delegate)
: default_cert_verifier_(net::CertVerifier::CreateDefault()), : default_cert_verifier_(net::CertVerifier::CreateDefault()),
ct_delegate_(ct_delegate) {} ct_delegate_(ct_delegate) {}

View file

@ -11,15 +11,10 @@
#include "net/cert/cert_verifier.h" #include "net/cert/cert_verifier.h"
namespace brightray {
class RequireCTDelegate;
} // namespace brightray
namespace atom { namespace atom {
class CertVerifierRequest; class CertVerifierRequest;
class RequireCTDelegate;
struct VerifyRequestParams { struct VerifyRequestParams {
std::string hostname; std::string hostname;
@ -34,7 +29,7 @@ struct VerifyRequestParams {
class AtomCertVerifier : public net::CertVerifier { class AtomCertVerifier : public net::CertVerifier {
public: public:
explicit AtomCertVerifier(brightray::RequireCTDelegate* ct_delegate); explicit AtomCertVerifier(RequireCTDelegate* ct_delegate);
~AtomCertVerifier() override; ~AtomCertVerifier() override;
using VerifyProc = base::Callback<void(const VerifyRequestParams& request, using VerifyProc = base::Callback<void(const VerifyRequestParams& request,
@ -43,7 +38,7 @@ class AtomCertVerifier : public net::CertVerifier {
void SetVerifyProc(const VerifyProc& proc); void SetVerifyProc(const VerifyProc& proc);
const VerifyProc verify_proc() const { return verify_proc_; } const VerifyProc verify_proc() const { return verify_proc_; }
brightray::RequireCTDelegate* ct_delegate() const { return ct_delegate_; } RequireCTDelegate* ct_delegate() const { return ct_delegate_; }
net::CertVerifier* default_verifier() const { net::CertVerifier* default_verifier() const {
return default_cert_verifier_.get(); return default_cert_verifier_.get();
} }
@ -66,7 +61,7 @@ class AtomCertVerifier : public net::CertVerifier {
std::map<RequestParams, CertVerifierRequest*> inflight_requests_; std::map<RequestParams, CertVerifierRequest*> inflight_requests_;
VerifyProc verify_proc_; VerifyProc verify_proc_;
std::unique_ptr<net::CertVerifier> default_cert_verifier_; std::unique_ptr<net::CertVerifier> default_cert_verifier_;
brightray::RequireCTDelegate* ct_delegate_; RequireCTDelegate* ct_delegate_;
DISALLOW_COPY_AND_ASSIGN(AtomCertVerifier); DISALLOW_COPY_AND_ASSIGN(AtomCertVerifier);
}; };

View file

@ -2,11 +2,11 @@
// Use of this source code is governed by the MIT license that can be // Use of this source code is governed by the MIT license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "brightray/browser/net/require_ct_delegate.h" #include "atom/browser/net/require_ct_delegate.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
namespace brightray { namespace atom {
RequireCTDelegate::RequireCTDelegate() {} RequireCTDelegate::RequireCTDelegate() {}
@ -33,4 +33,4 @@ RequireCTDelegate::CTRequirementLevel RequireCTDelegate::IsCTRequiredForHost(
return CTRequirementLevel::DEFAULT; return CTRequirementLevel::DEFAULT;
} }
} // namespace brightray } // namespace atom

View file

@ -2,15 +2,15 @@
// Use of this source code is governed by the MIT license that can be // Use of this source code is governed by the MIT license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef BRIGHTRAY_BROWSER_NET_REQUIRE_CT_DELEGATE_H_ #ifndef ATOM_BROWSER_NET_REQUIRE_CT_DELEGATE_H_
#define BRIGHTRAY_BROWSER_NET_REQUIRE_CT_DELEGATE_H_ #define ATOM_BROWSER_NET_REQUIRE_CT_DELEGATE_H_
#include <set> #include <set>
#include <string> #include <string>
#include "net/http/transport_security_state.h" #include "net/http/transport_security_state.h"
namespace brightray { namespace atom {
class RequireCTDelegate class RequireCTDelegate
: public net::TransportSecurityState::RequireCTDelegate { : public net::TransportSecurityState::RequireCTDelegate {
@ -32,6 +32,6 @@ class RequireCTDelegate
DISALLOW_COPY_AND_ASSIGN(RequireCTDelegate); DISALLOW_COPY_AND_ASSIGN(RequireCTDelegate);
}; };
} // namespace brightray } // namespace atom
#endif // BRIGHTRAY_BROWSER_NET_REQUIRE_CT_DELEGATE_H_ #endif // ATOM_BROWSER_NET_REQUIRE_CT_DELEGATE_H_

View file

@ -17,10 +17,10 @@
#include "atom/browser/net/atom_network_delegate.h" #include "atom/browser/net/atom_network_delegate.h"
#include "atom/browser/net/atom_url_request_job_factory.h" #include "atom/browser/net/atom_url_request_job_factory.h"
#include "atom/browser/net/http_protocol_handler.h" #include "atom/browser/net/http_protocol_handler.h"
#include "atom/browser/net/require_ct_delegate.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/task_scheduler/post_task.h" #include "base/task_scheduler/post_task.h"
#include "brightray/browser/net/require_ct_delegate.h"
#include "chrome/browser/net/chrome_mojo_proxy_resolver_factory.h" #include "chrome/browser/net/chrome_mojo_proxy_resolver_factory.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
@ -317,7 +317,7 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
network_delegate_ = network_delegate.get(); network_delegate_ = network_delegate.get();
builder->set_network_delegate(std::move(network_delegate)); builder->set_network_delegate(std::move(network_delegate));
ct_delegate_.reset(new brightray::RequireCTDelegate); ct_delegate_.reset(new RequireCTDelegate);
auto cert_verifier = std::make_unique<AtomCertVerifier>(ct_delegate_.get()); auto cert_verifier = std::make_unique<AtomCertVerifier>(ct_delegate_.get());
builder->SetCertVerifier(std::move(cert_verifier)); builder->SetCertVerifier(std::move(cert_verifier));

View file

@ -19,15 +19,12 @@
#include "base/debug/leak_tracker.h" #include "base/debug/leak_tracker.h"
#endif #endif
namespace brightray {
class RequireCTDelegate;
} // namespace brightray
namespace atom { namespace atom {
class AtomBrowserContext; class AtomBrowserContext;
class AtomNetworkDelegate; class AtomNetworkDelegate;
class AtomURLRequestJobFactory; class AtomURLRequestJobFactory;
class RequireCTDelegate;
class ResourceContext; class ResourceContext;
class URLRequestContextGetter : public net::URLRequestContextGetter { class URLRequestContextGetter : public net::URLRequestContextGetter {
@ -96,7 +93,7 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
base::debug::LeakTracker<URLRequestContextGetter> leak_tracker_; base::debug::LeakTracker<URLRequestContextGetter> leak_tracker_;
#endif #endif
std::unique_ptr<brightray::RequireCTDelegate> ct_delegate_; std::unique_ptr<RequireCTDelegate> ct_delegate_;
std::unique_ptr<AtomURLRequestJobFactory> top_job_factory_; std::unique_ptr<AtomURLRequestJobFactory> top_job_factory_;
std::unique_ptr<network::mojom::NetworkContext> network_context_; std::unique_ptr<network::mojom::NetworkContext> network_context_;

View file

@ -9,12 +9,12 @@
#include <vector> #include <vector>
#include "atom/browser/notifications/notification_delegate.h" #include "atom/browser/notifications/notification_delegate.h"
#include "atom/common/platform_util.h"
#include "base/files/file_enumerator.h" #include "base/files/file_enumerator.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "brightray/common/application_info.h" #include "brightray/common/application_info.h"
#include "brightray/common/platform_util.h"
#include "chrome/browser/ui/libgtkui/gtk_util.h" #include "chrome/browser/ui/libgtkui/gtk_util.h"
#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h" #include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
@ -127,7 +127,7 @@ void LibnotifyNotification::Show(const NotificationOptions& options) {
// Send the desktop name to identify the application // Send the desktop name to identify the application
// The desktop-entry is the part before the .desktop // The desktop-entry is the part before the .desktop
std::string desktop_id; std::string desktop_id;
if (brightray::platform_util::GetDesktopName(&desktop_id)) { if (platform_util::GetDesktopName(&desktop_id)) {
const std::string suffix{".desktop"}; const std::string suffix{".desktop"};
if (base::EndsWith(desktop_id, suffix, if (base::EndsWith(desktop_id, suffix,
base::CompareCase::INSENSITIVE_ASCII)) { base::CompareCase::INSENSITIVE_ASCII)) {

View file

@ -9,8 +9,8 @@
#include <utility> #include <utility>
#include "atom/browser/atom_permission_manager.h" #include "atom/browser/atom_permission_manager.h"
#include "atom/browser/media/media_stream_devices_controller.h"
#include "atom/common/native_mate_converters/gurl_converter.h" #include "atom/common/native_mate_converters/gurl_converter.h"
#include "brightray/browser/media/media_stream_devices_controller.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
@ -38,8 +38,7 @@ namespace {
void MediaAccessAllowed(const content::MediaStreamRequest& request, void MediaAccessAllowed(const content::MediaStreamRequest& request,
content::MediaResponseCallback callback, content::MediaResponseCallback callback,
bool allowed) { bool allowed) {
brightray::MediaStreamDevicesController controller(request, MediaStreamDevicesController controller(request, std::move(callback));
std::move(callback));
if (allowed) if (allowed)
controller.TakeAction(); controller.TakeAction();
else else

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "brightray/browser/zoom_level_delegate.h" #include "atom/browser/zoom_level_delegate.h"
#include <functional> #include <functional>
#include <memory> #include <memory>
@ -19,7 +19,7 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/common/page_zoom.h" #include "content/public/common/page_zoom.h"
namespace brightray { namespace atom {
namespace { namespace {
@ -164,4 +164,4 @@ void ZoomLevelDelegate::InitHostZoomMap(content::HostZoomMap* host_zoom_map) {
&ZoomLevelDelegate::OnZoomLevelChanged, base::Unretained(this))); &ZoomLevelDelegate::OnZoomLevelChanged, base::Unretained(this)));
} }
} // namespace brightray } // namespace atom

View file

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef BRIGHTRAY_BROWSER_ZOOM_LEVEL_DELEGATE_H_ #ifndef ATOM_BROWSER_ZOOM_LEVEL_DELEGATE_H_
#define BRIGHTRAY_BROWSER_ZOOM_LEVEL_DELEGATE_H_ #define ATOM_BROWSER_ZOOM_LEVEL_DELEGATE_H_
#include <memory> #include <memory>
#include <string> #include <string>
@ -20,7 +20,7 @@ class DictionaryValue;
class PrefRegistrySimple; class PrefRegistrySimple;
namespace brightray { namespace atom {
// A class to manage per-partition default and per-host zoom levels. // A class to manage per-partition default and per-host zoom levels.
// It implements an interface between the content/ zoom // It implements an interface between the content/ zoom
@ -59,6 +59,6 @@ class ZoomLevelDelegate : public content::ZoomLevelDelegate {
DISALLOW_COPY_AND_ASSIGN(ZoomLevelDelegate); DISALLOW_COPY_AND_ASSIGN(ZoomLevelDelegate);
}; };
} // namespace brightray } // namespace atom
#endif // BRIGHTRAY_BROWSER_ZOOM_LEVEL_DELEGATE_H_ #endif // ATOM_BROWSER_ZOOM_LEVEL_DELEGATE_H_

View file

@ -11,9 +11,9 @@
#include <string> #include <string>
#include "atom/common/atom_version.h" #include "atom/common/atom_version.h"
#include "atom/common/platform_util.h"
#include "base/environment.h" #include "base/environment.h"
#include "base/logging.h" #include "base/logging.h"
#include "brightray/common/platform_util.h"
#include "chrome/browser/ui/libgtkui/gtk_util.h" #include "chrome/browser/ui/libgtkui/gtk_util.h"
namespace { namespace {
@ -22,7 +22,7 @@ GDesktopAppInfo* get_desktop_app_info() {
GDesktopAppInfo* ret = nullptr; GDesktopAppInfo* ret = nullptr;
std::string desktop_id; std::string desktop_id;
if (brightray::platform_util::GetDesktopName(&desktop_id)) if (platform_util::GetDesktopName(&desktop_id))
ret = g_desktop_app_info_new(desktop_id.c_str()); ret = g_desktop_app_info_new(desktop_id.c_str());
return ret; return ret;

View file

@ -64,6 +64,12 @@ bool GetLoginItemEnabled();
void SetLoginItemEnabled(bool enabled); void SetLoginItemEnabled(bool enabled);
#endif #endif
#if defined(OS_LINUX)
// Returns a success flag.
// Unlike libgtkui, does *not* use "chromium-browser.desktop" as a fallback.
bool GetDesktopName(std::string* setme);
#endif
} // namespace platform_util } // namespace platform_util
#endif // ATOM_COMMON_PLATFORM_UTIL_H_ #endif // ATOM_COMMON_PLATFORM_UTIL_H_

View file

@ -12,6 +12,7 @@
#include "base/nix/xdg_util.h" #include "base/nix/xdg_util.h"
#include "base/process/kill.h" #include "base/process/kill.h"
#include "base/process/launch.h" #include "base/process/launch.h"
#include "chrome/browser/ui/libgtkui/gtk_util.h"
#include "url/gurl.h" #include "url/gurl.h"
#define ELECTRON_TRASH "ELECTRON_TRASH" #define ELECTRON_TRASH "ELECTRON_TRASH"
@ -145,4 +146,18 @@ void Beep() {
fclose(console); fclose(console);
} }
bool GetDesktopName(std::string* setme) {
bool found = false;
std::unique_ptr<base::Environment> env(base::Environment::Create());
std::string desktop_id = libgtkui::GetDesktopName(env.get());
constexpr char const* libcc_default_id = "chromium-browser.desktop";
if (!desktop_id.empty() && (desktop_id != libcc_default_id)) {
*setme = desktop_id;
found = true;
}
return found;
}
} // namespace platform_util } // namespace platform_util

View file

@ -24,18 +24,8 @@ static_library("brightray") {
"browser/browser_main_parts.cc", "browser/browser_main_parts.cc",
"browser/browser_main_parts.h", "browser/browser_main_parts.h",
"browser/browser_main_parts_mac.mm", "browser/browser_main_parts_mac.mm",
"browser/media/media_capture_devices_dispatcher.cc",
"browser/media/media_capture_devices_dispatcher.h",
"browser/media/media_device_id_salt.cc",
"browser/media/media_device_id_salt.h",
"browser/media/media_stream_devices_controller.cc",
"browser/media/media_stream_devices_controller.h",
"browser/net/require_ct_delegate.cc",
"browser/net/require_ct_delegate.h",
"browser/win/scoped_hstring.cc", "browser/win/scoped_hstring.cc",
"browser/win/scoped_hstring.h", "browser/win/scoped_hstring.h",
"browser/zoom_level_delegate.cc",
"browser/zoom_level_delegate.h",
"common/application_info.cc", "common/application_info.cc",
"common/application_info.h", "common/application_info.h",
"common/application_info_mac.mm", "common/application_info_mac.mm",
@ -47,7 +37,5 @@ static_library("brightray") {
"common/main_delegate.cc", "common/main_delegate.cc",
"common/main_delegate.h", "common/main_delegate.h",
"common/main_delegate_mac.mm", "common/main_delegate_mac.mm",
"common/platform_util.h",
"common/platform_util_linux.cc",
] ]
} }

View file

@ -8,7 +8,6 @@
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "brightray/browser/browser_main_parts.h" #include "brightray/browser/browser_main_parts.h"
#include "brightray/browser/media/media_capture_devices_dispatcher.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
@ -68,10 +67,6 @@ content::BrowserMainParts* BrowserClient::CreateBrowserMainParts(
return browser_main_parts_; return browser_main_parts_;
} }
content::MediaObserver* BrowserClient::GetMediaObserver() {
return MediaCaptureDevicesDispatcher::GetInstance();
}
base::FilePath BrowserClient::GetDefaultDownloadDirectory() { base::FilePath BrowserClient::GetDefaultDownloadDirectory() {
// ~/Downloads // ~/Downloads
base::FilePath path; base::FilePath path;

View file

@ -29,7 +29,6 @@ class BrowserClient : public content::ContentBrowserClient {
// handlers) should call this implementation after doing their own work. // handlers) should call this implementation after doing their own work.
content::BrowserMainParts* CreateBrowserMainParts( content::BrowserMainParts* CreateBrowserMainParts(
const content::MainFunctionParams&) override; const content::MainFunctionParams&) override;
content::MediaObserver* GetMediaObserver() override;
base::FilePath GetDefaultDownloadDirectory() override; base::FilePath GetDefaultDownloadDirectory() override;
std::string GetApplicationLocale() override; std::string GetApplicationLocale() override;

View file

@ -23,7 +23,6 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "brightray/browser/browser_client.h" #include "brightray/browser/browser_client.h"
#include "brightray/browser/media/media_capture_devices_dispatcher.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"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
@ -303,9 +302,6 @@ 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

@ -1,24 +0,0 @@
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef BRIGHTRAY_COMMON_PLATFORM_UTIL_H_
#define BRIGHTRAY_COMMON_PLATFORM_UTIL_H_
#include <string>
namespace brightray {
namespace platform_util {
#if defined(OS_LINUX)
// Returns a success flag.
// Unlike libgtkui, does *not* use "chromium-browser.desktop" as a fallback.
bool GetDesktopName(std::string* setme);
#endif
} // namespace platform_util
} // namespace brightray
#endif // BRIGHTRAY_COMMON_PLATFORM_UTIL_H_

View file

@ -1,30 +0,0 @@
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "brightray/common/platform_util.h"
#include "base/environment.h"
#include "chrome/browser/ui/libgtkui/gtk_util.h"
namespace brightray {
namespace platform_util {
bool GetDesktopName(std::string* setme) {
bool found = false;
std::unique_ptr<base::Environment> env(base::Environment::Create());
std::string desktop_id = libgtkui::GetDesktopName(env.get());
constexpr char const* libcc_default_id = "chromium-browser.desktop";
if (!desktop_id.empty() && (desktop_id != libcc_default_id)) {
*setme = desktop_id;
found = true;
}
return found;
}
} // namespace platform_util
} // namespace brightray

View file

@ -288,6 +288,12 @@ filenames = {
"atom/browser/native_window_mac.h", "atom/browser/native_window_mac.h",
"atom/browser/native_window_mac.mm", "atom/browser/native_window_mac.mm",
"atom/browser/native_window_observer.h", "atom/browser/native_window_observer.h",
"atom/browser/media/media_capture_devices_dispatcher.cc",
"atom/browser/media/media_capture_devices_dispatcher.h",
"atom/browser/media/media_device_id_salt.cc",
"atom/browser/media/media_device_id_salt.h",
"atom/browser/media/media_stream_devices_controller.cc",
"atom/browser/media/media_stream_devices_controller.h",
"atom/browser/net/about_protocol_handler.cc", "atom/browser/net/about_protocol_handler.cc",
"atom/browser/net/about_protocol_handler.h", "atom/browser/net/about_protocol_handler.h",
"atom/browser/net/asar/asar_protocol_handler.cc", "atom/browser/net/asar/asar_protocol_handler.cc",
@ -306,6 +312,8 @@ filenames = {
"atom/browser/net/http_protocol_handler.h", "atom/browser/net/http_protocol_handler.h",
"atom/browser/net/js_asker.cc", "atom/browser/net/js_asker.cc",
"atom/browser/net/js_asker.h", "atom/browser/net/js_asker.h",
"atom/browser/net/require_ct_delegate.cc",
"atom/browser/net/require_ct_delegate.h",
"atom/browser/net/resolve_proxy_helper.cc", "atom/browser/net/resolve_proxy_helper.cc",
"atom/browser/net/resolve_proxy_helper.h", "atom/browser/net/resolve_proxy_helper.h",
"atom/browser/net/url_request_about_job.cc", "atom/browser/net/url_request_about_job.cc",
@ -503,6 +511,8 @@ filenames = {
"atom/browser/window_list.cc", "atom/browser/window_list.cc",
"atom/browser/window_list.h", "atom/browser/window_list.h",
"atom/browser/window_list_observer.h", "atom/browser/window_list_observer.h",
"atom/browser/zoom_level_delegate.cc",
"atom/browser/zoom_level_delegate.h",
"atom/common/api/api_messages.h", "atom/common/api/api_messages.h",
"atom/common/api/atom_api_asar.cc", "atom/common/api/atom_api_asar.cc",
"atom/common/api/atom_api_clipboard.cc", "atom/common/api/atom_api_clipboard.cc",