From 636fb338a366464d38810618abb06a605f6da4da Mon Sep 17 00:00:00 2001 From: bridiver Date: Mon, 11 Sep 2017 10:09:56 -0700 Subject: [PATCH] handle permission requests for multiple permissions prereq for https://github.com/brave/browser-laptop/issues/10864 --- atom/browser/BUILD.gn | 2 - atom/browser/atom_browser_context.cc | 7 - atom/browser/atom_browser_context.h | 3 - atom/browser/atom_permission_manager.cc | 148 ------------------ atom/browser/atom_permission_manager.h | 91 ----------- .../browser/web_contents_permission_helper.cc | 4 +- brave/browser/brave_permission_manager.cc | 96 +++++++++--- brave/browser/brave_permission_manager.h | 47 ++++-- vendor/brightray/BUILD.gn | 2 - vendor/brightray/browser/browser_context.cc | 7 - vendor/brightray/browser/browser_context.h | 1 - .../brightray/browser/permission_manager.cc | 84 ---------- vendor/brightray/browser/permission_manager.h | 54 ------- 13 files changed, 111 insertions(+), 435 deletions(-) delete mode 100644 atom/browser/atom_permission_manager.cc delete mode 100644 atom/browser/atom_permission_manager.h delete mode 100644 vendor/brightray/browser/permission_manager.cc delete mode 100644 vendor/brightray/browser/permission_manager.h diff --git a/atom/browser/BUILD.gn b/atom/browser/BUILD.gn index 702ebde399..1c034ce0c8 100644 --- a/atom/browser/BUILD.gn +++ b/atom/browser/BUILD.gn @@ -97,8 +97,6 @@ source_set("browser") { "atom_download_manager_delegate.h", "atom_browser_main_parts.cc", "atom_browser_main_parts.h", - "atom_permission_manager.cc", - "atom_permission_manager.h", "atom_quota_permission_context.cc", "atom_quota_permission_context.h", "atom_resource_dispatcher_host_delegate.cc", diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index 8051a43182..d83f7c3f0b 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -9,7 +9,6 @@ #include "atom/browser/api/atom_api_protocol.h" #include "atom/browser/atom_browser_main_parts.h" #include "atom/browser/atom_download_manager_delegate.h" -#include "atom/browser/atom_permission_manager.h" #include "atom/browser/browser.h" #include "atom/browser/net/asar/asar_protocol_handler.h" #include "atom/browser/net/atom_cert_verifier.h" @@ -137,12 +136,6 @@ AtomBrowserContext::GetDownloadManagerDelegate() { return download_manager_delegate_.get(); } -content::PermissionManager* AtomBrowserContext::GetPermissionManager() { - if (!permission_manager_.get()) - permission_manager_.reset(new AtomPermissionManager); - return permission_manager_.get(); -} - std::unique_ptr AtomBrowserContext::CreateCertVerifier() { return base::WrapUnique(new AtomCertVerifier); } diff --git a/atom/browser/atom_browser_context.h b/atom/browser/atom_browser_context.h index 17718a98d5..083c6f20a6 100644 --- a/atom/browser/atom_browser_context.h +++ b/atom/browser/atom_browser_context.h @@ -15,7 +15,6 @@ namespace atom { class AtomDownloadManagerDelegate; -class AtomPermissionManager; class AtomBrowserContext : public brightray::BrowserContext { public: @@ -38,7 +37,6 @@ class AtomBrowserContext : public brightray::BrowserContext { // content::BrowserContext: content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; - content::PermissionManager* GetPermissionManager() override; // brightray::BrowserContext: void RegisterPrefs(PrefRegistrySimple* pref_registry) override; @@ -53,7 +51,6 @@ class AtomBrowserContext : public brightray::BrowserContext { private: std::unique_ptr download_manager_delegate_; - std::unique_ptr permission_manager_; bool use_cache_; // Managed by brightray::BrowserContext. diff --git a/atom/browser/atom_permission_manager.cc b/atom/browser/atom_permission_manager.cc deleted file mode 100644 index 1555e645a2..0000000000 --- a/atom/browser/atom_permission_manager.cc +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (c) 2016 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "atom/browser/atom_permission_manager.h" - -#include - -#include "atom/browser/web_contents_preferences.h" -#include "content/public/browser/child_process_security_policy.h" -#include "content/public/browser/permission_type.h" -#include "content/public/browser/render_frame_host.h" -#include "content/public/browser/render_process_host.h" -#include "content/public/browser/render_view_host.h" -#include "content/public/browser/web_contents.h" - -namespace atom { - -namespace { - -bool WebContentsDestroyed(int process_id) { - auto contents = - WebContentsPreferences::GetWebContentsFromProcessID(process_id); - if (!contents) - return true; - return contents->IsBeingDestroyed(); -} - -} // namespace - -AtomPermissionManager::AtomPermissionManager() - : request_id_(0) { -} - -AtomPermissionManager::~AtomPermissionManager() { -} - -void AtomPermissionManager::SetPermissionRequestHandler( - const RequestHandler& handler) { - if (handler.is_null() && !pending_requests_.empty()) { - for (const auto& request : pending_requests_) { - if (!WebContentsDestroyed(request.second.render_process_id)) - request.second.callback.Run(blink::mojom::PermissionStatus::DENIED); - } - pending_requests_.clear(); - } - request_handler_ = handler; -} - -int AtomPermissionManager::RequestPermission( - content::PermissionType permission, - content::RenderFrameHost* render_frame_host, - const GURL& requesting_origin, - bool user_gesture, - const ResponseCallback& response_callback) { - int process_id = render_frame_host->GetProcess()->GetID(); - - if (permission == content::PermissionType::MIDI_SYSEX) { - content::ChildProcessSecurityPolicy::GetInstance()-> - GrantSendMidiSysExMessage(process_id); - } - - if (!request_handler_.is_null()) { - auto web_contents = - content::WebContents::FromRenderFrameHost(render_frame_host); - ++request_id_; - auto callback = base::Bind(&AtomPermissionManager::OnPermissionResponse, - base::Unretained(this), - request_id_, - requesting_origin, - response_callback); - pending_requests_[request_id_] = { process_id, callback }; - request_handler_.Run(web_contents, permission, callback); - return request_id_; - } - - response_callback.Run(blink::mojom::PermissionStatus::GRANTED); - return kNoPendingOperation; -} - -int AtomPermissionManager::RequestPermissions( - const std::vector& permissions, - content::RenderFrameHost* render_frame_host, - const GURL& requesting_origin, - bool user_gesture, - const base::Callback&)>& callback) { - // FIXME(zcbenz): Just ignore multiple permissions request for now. - std::vector permissionStatuses; - for (auto permission : permissions) { - if (permission == content::PermissionType::MIDI_SYSEX) { - content::ChildProcessSecurityPolicy::GetInstance()-> - GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID()); - } - permissionStatuses.push_back(blink::mojom::PermissionStatus::GRANTED); - } - callback.Run(permissionStatuses); - return kNoPendingOperation; -} - -void AtomPermissionManager::OnPermissionResponse( - int request_id, - const GURL& origin, - const ResponseCallback& callback, - blink::mojom::PermissionStatus status) { - auto request = pending_requests_.find(request_id); - if (request != pending_requests_.end()) { - if (!WebContentsDestroyed(request->second.render_process_id)) - callback.Run(status); - pending_requests_.erase(request); - } -} - -void AtomPermissionManager::CancelPermissionRequest(int request_id) { - auto request = pending_requests_.find(request_id); - if (request != pending_requests_.end()) { - if (!WebContentsDestroyed(request->second.render_process_id)) - request->second.callback.Run(blink::mojom::PermissionStatus::DENIED); - pending_requests_.erase(request); - } -} - -void AtomPermissionManager::ResetPermission( - content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin) { -} - -blink::mojom::PermissionStatus AtomPermissionManager::GetPermissionStatus( - content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin) { - return blink::mojom::PermissionStatus::GRANTED; -} - -int AtomPermissionManager::SubscribePermissionStatusChange( - content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin, - const ResponseCallback& callback) { - return -1; -} - -void AtomPermissionManager::UnsubscribePermissionStatusChange( - int subscription_id) { -} - -} // namespace atom diff --git a/atom/browser/atom_permission_manager.h b/atom/browser/atom_permission_manager.h deleted file mode 100644 index 9928a4ea04..0000000000 --- a/atom/browser/atom_permission_manager.h +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2016 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef ATOM_BROWSER_ATOM_PERMISSION_MANAGER_H_ -#define ATOM_BROWSER_ATOM_PERMISSION_MANAGER_H_ - -#include -#include - -#include "base/callback.h" -#include "content/public/browser/permission_manager.h" - -namespace content { -class WebContents; -} - -namespace atom { - -class AtomPermissionManager : public content::PermissionManager { - public: - AtomPermissionManager(); - ~AtomPermissionManager() override; - - using ResponseCallback = - base::Callback; - using RequestHandler = - base::Callback; - - // Handler to dispatch permission requests in JS. - void SetPermissionRequestHandler(const RequestHandler& handler); - - // content::PermissionManager: - int RequestPermission( - content::PermissionType permission, - content::RenderFrameHost* render_frame_host, - const GURL& requesting_origin, - bool user_gesture, - const base::Callback& callback) override; - int RequestPermissions( - const std::vector& permissions, - content::RenderFrameHost* render_frame_host, - const GURL& requesting_origin, - bool user_gesture, - const base::Callback&)>& callback) override; - - protected: - void OnPermissionResponse(int request_id, - const GURL& url, - const ResponseCallback& callback, - blink::mojom::PermissionStatus status); - - // content::PermissionManager: - void CancelPermissionRequest(int request_id) override; - void ResetPermission(content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin) override; - blink::mojom::PermissionStatus GetPermissionStatus( - content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin) override; - int SubscribePermissionStatusChange( - content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin, - const base::Callback& callback) - override; - void UnsubscribePermissionStatusChange(int subscription_id) override; - - private: - struct RequestInfo { - int render_process_id; - ResponseCallback callback; - }; - - RequestHandler request_handler_; - - std::map pending_requests_; - - int request_id_; - - DISALLOW_COPY_AND_ASSIGN(AtomPermissionManager); -}; - -} // namespace atom - -#endif // ATOM_BROWSER_ATOM_PERMISSION_MANAGER_H_ diff --git a/atom/browser/web_contents_permission_helper.cc b/atom/browser/web_contents_permission_helper.cc index bc48e1034e..423412bc58 100644 --- a/atom/browser/web_contents_permission_helper.cc +++ b/atom/browser/web_contents_permission_helper.cc @@ -6,7 +6,7 @@ #include -#include "atom/browser/atom_permission_manager.h" +#include "brave/browser/brave_permission_manager.h" #include "brightray/browser/media/media_stream_devices_controller.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/render_process_host.h" @@ -57,7 +57,7 @@ void WebContentsPermissionHelper::RequestPermission( const base::Callback& callback, const GURL& security_origin, bool user_gesture) { auto rfh = web_contents_->GetMainFrame(); - auto permission_manager = static_cast( + auto permission_manager = static_cast( web_contents_->GetBrowserContext()->GetPermissionManager()); GURL origin; if (security_origin.is_empty()) { diff --git a/brave/browser/brave_permission_manager.cc b/brave/browser/brave_permission_manager.cc index b9efe88fdb..49defbff83 100644 --- a/brave/browser/brave_permission_manager.cc +++ b/brave/browser/brave_permission_manager.cc @@ -35,6 +35,12 @@ bool WebContentsDestroyed(int render_process_id, int render_frame_id) { return contents->IsBeingDestroyed(); } +void PermissionStatusCallbackWrapper(const base::Callback& callback, + const std::vector& status) { + callback.Run(status.front()); +} + } // namespace BravePermissionManager::BravePermissionManager() @@ -47,11 +53,8 @@ BravePermissionManager::~BravePermissionManager() { void BravePermissionManager::SetPermissionRequestHandler( const RequestHandler& handler) { if (handler.is_null() && !pending_requests_.empty()) { - for (const auto& request : pending_requests_) { - if (!WebContentsDestroyed( - request.second.render_process_id, request.second.render_frame_id)) - request.second.callback.Run(blink::mojom::PermissionStatus::DENIED); - } + for (const auto& request : pending_requests_) + CancelPermissionRequest(request.first); pending_requests_.clear(); } request_handler_ = handler; @@ -63,19 +66,30 @@ int BravePermissionManager::RequestPermission( const GURL& requesting_origin, bool user_gesture, const base::Callback& response_callback) { + blink::mojom::PermissionStatus)>& response_callback) { + LOG(ERROR) << "request permission " << (permission == content::PermissionType::GEOLOCATION); + + auto callback = + base::Bind(PermissionStatusCallbackWrapper, response_callback); + return RequestPermissions({ permission }, render_frame_host, + requesting_origin, user_gesture, callback); +} + +int BravePermissionManager::RequestPermissions( + const std::vector& permissions, + content::RenderFrameHost* render_frame_host, + const GURL& requesting_origin, + bool user_gesture, + const base::Callback&)>& response_callback) { int render_frame_id = MSG_ROUTING_NONE; int render_process_id = MSG_ROUTING_NONE; GURL url; // web notifications do not currently have an available render_frame_host if (render_frame_host) { + LOG(ERROR) << "got render frame host"; render_process_id = render_frame_host->GetProcess()->GetID(); - if (permission == content::PermissionType::MIDI_SYSEX) { - content::ChildProcessSecurityPolicy::GetInstance()-> - GrantSendMidiSysExMessage(render_process_id); - } - content::WebContents* web_contents = content::WebContents::FromRenderFrameHost(render_frame_host); @@ -84,7 +98,17 @@ int BravePermissionManager::RequestPermission( url = web_contents->GetURL(); } } + std::vector permissionStatuses; + for (auto permission : permissions) { + LOG(ERROR) << "request permissions " << (permission == content::PermissionType::GEOLOCATION); + if (permission == content::PermissionType::MIDI_SYSEX) { + content::ChildProcessSecurityPolicy::GetInstance()-> + GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID()); + } + permissionStatuses.push_back(blink::mojom::PermissionStatus::GRANTED); + } + LOG(ERROR) << "request " << request_handler_.is_null(); if (!request_handler_.is_null()) { ++request_id_; auto callback = base::Bind(&BravePermissionManager::OnPermissionResponse, @@ -92,28 +116,27 @@ int BravePermissionManager::RequestPermission( request_id_, requesting_origin, response_callback); - pending_requests_[request_id_] = - { render_process_id, render_frame_id, callback }; - - request_handler_.Run(requesting_origin, url, permission, callback); + { render_process_id, render_frame_id, callback, permissions.size() }; + request_handler_.Run(requesting_origin, url, permissions, callback); return request_id_; } - response_callback.Run(blink::mojom::PermissionStatus::GRANTED); + response_callback.Run(permissionStatuses); return kNoPendingOperation; } void BravePermissionManager::OnPermissionResponse( int request_id, const GURL& origin, - const base::Callback& callback, - blink::mojom::PermissionStatus status) { + const ResponseCallback& callback, + const std::vector& status) { auto request = pending_requests_.find(request_id); if (request != pending_requests_.end()) { if (!WebContentsDestroyed( - request->second.render_process_id, request->second.render_frame_id)) + request->second.render_process_id, request->second.render_frame_id)) { callback.Run(status); + } pending_requests_.erase(request); } } @@ -123,11 +146,40 @@ void BravePermissionManager::CancelPermissionRequest(int request_id) { if (request != pending_requests_.end()) { if (!WebContentsDestroyed( request->second.render_process_id, request->second.render_frame_id)) { - request->second.callback.Run(blink::mojom::PermissionStatus::DENIED); - } else { - pending_requests_.erase(request); + std::vector permissionStatuses; + for (int i = 0; i < request->second.size; i++) { + permissionStatuses.push_back(blink::mojom::PermissionStatus::DENIED); + } + request->second.callback.Run(permissionStatuses); } + pending_requests_.erase(request); } } +void BravePermissionManager::ResetPermission( + content::PermissionType permission, + const GURL& requesting_origin, + const GURL& embedding_origin) { +} + +blink::mojom::PermissionStatus BravePermissionManager::GetPermissionStatus( + content::PermissionType permission, + const GURL& requesting_origin, + const GURL& embedding_origin) { + LOG(ERROR) << "get state for " << (permission == content::PermissionType::GEOLOCATION); + return blink::mojom::PermissionStatus::GRANTED; +} + +int BravePermissionManager::SubscribePermissionStatusChange( + content::PermissionType permission, + const GURL& requesting_origin, + const GURL& embedding_origin, + const base::Callback& callback) { + return -1; +} + +void BravePermissionManager::UnsubscribePermissionStatusChange( + int subscription_id) { +} + } // namespace brave diff --git a/brave/browser/brave_permission_manager.h b/brave/browser/brave_permission_manager.h index 19e303ecf5..a4dd036ed7 100644 --- a/brave/browser/brave_permission_manager.h +++ b/brave/browser/brave_permission_manager.h @@ -2,14 +2,14 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#ifndef BRAVE_BROWSER_BRAVE_PERMISSION_MANAGER_H_ -#define BRAVE_BROWSER_BRAVE_PERMISSION_MANAGER_H_ +#ifndef BRAVE_BROWSER_ATOM_PERMISSION_MANAGER_H_ +#define BRAVE_BROWSER_ATOM_PERMISSION_MANAGER_H_ #include #include -#include "atom/browser/atom_permission_manager.h" #include "base/callback.h" +#include "content/public/browser/permission_manager.h" namespace content { class WebContents; @@ -17,18 +17,19 @@ class WebContents; namespace brave { -class BravePermissionManager : public atom::AtomPermissionManager { +class BravePermissionManager : public content::PermissionManager { public: BravePermissionManager(); ~BravePermissionManager() override; using ResponseCallback = - base::Callback; + base::Callback& status)>; using RequestHandler = base::Callback; + const GURL&, + const std::vector& permissions, + const ResponseCallback&)>; // Handler to dispatch permission requests in JS. void SetPermissionRequestHandler(const RequestHandler& handler); @@ -41,21 +42,43 @@ class BravePermissionManager : public atom::AtomPermissionManager { bool user_gesture, const base::Callback& callback) override; + int RequestPermissions( + const std::vector& permissions, + content::RenderFrameHost* render_frame_host, + const GURL& requesting_origin, + bool user_gesture, + const base::Callback&)>& callback) override; protected: void OnPermissionResponse(int request_id, - const GURL& url, - const ResponseCallback& callback, - blink::mojom::PermissionStatus status); + const GURL& url, + const ResponseCallback& callback, + const std::vector& status); // content::PermissionManager: void CancelPermissionRequest(int request_id) override; + void ResetPermission(content::PermissionType permission, + const GURL& requesting_origin, + const GURL& embedding_origin) override; + blink::mojom::PermissionStatus GetPermissionStatus( + content::PermissionType permission, + const GURL& requesting_origin, + const GURL& embedding_origin) override; + int SubscribePermissionStatusChange( + content::PermissionType permission, + const GURL& requesting_origin, + const GURL& embedding_origin, + const base::Callback& callback) + override; + void UnsubscribePermissionStatusChange(int subscription_id) override; private: struct RequestInfo { int render_process_id; int render_frame_id; ResponseCallback callback; + size_t size; }; RequestHandler request_handler_; @@ -69,4 +92,4 @@ class BravePermissionManager : public atom::AtomPermissionManager { } // namespace brave -#endif // BRAVE_BROWSER_BRAVE_PERMISSION_MANAGER_H_ +#endif // BRAVE_BROWSER_ATOM_PERMISSION_MANAGER_H_ diff --git a/vendor/brightray/BUILD.gn b/vendor/brightray/BUILD.gn index 8e04fd3eec..cad9df03b9 100644 --- a/vendor/brightray/BUILD.gn +++ b/vendor/brightray/BUILD.gn @@ -122,8 +122,6 @@ source_set("browser") { "browser/notification_presenter.h", "browser/notification.cc", "browser/notification.h", - "browser/permission_manager.cc", - "browser/permission_manager.h", "browser/platform_notification_service.cc", "browser/platform_notification_service.h", "browser/linux/libnotify_loader.h", diff --git a/vendor/brightray/browser/browser_context.cc b/vendor/brightray/browser/browser_context.cc index 0084280342..30259d1483 100644 --- a/vendor/brightray/browser/browser_context.cc +++ b/vendor/brightray/browser/browser_context.cc @@ -8,7 +8,6 @@ #include "browser/browser_client.h" #include "browser/inspectable_web_contents_impl.h" #include "browser/network_delegate.h" -#include "browser/permission_manager.h" #include "browser/special_storage_policy.h" #include "common/application_info.h" @@ -181,12 +180,6 @@ content::SSLHostStateDelegate* BrowserContext::GetSSLHostStateDelegate() { return nullptr; } -content::PermissionManager* BrowserContext::GetPermissionManager() { - if (!permission_manager_.get()) - permission_manager_.reset(new PermissionManager); - return permission_manager_.get(); -} - content::BackgroundSyncController* BrowserContext::GetBackgroundSyncController() { return nullptr; } diff --git a/vendor/brightray/browser/browser_context.h b/vendor/brightray/browser/browser_context.h index a1696eb1cf..9e0f2d1b04 100644 --- a/vendor/brightray/browser/browser_context.h +++ b/vendor/brightray/browser/browser_context.h @@ -47,7 +47,6 @@ class BrowserContext : public content::BrowserContext, storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; content::PushMessagingService* GetPushMessagingService() override; content::SSLHostStateDelegate* GetSSLHostStateDelegate() override; - content::PermissionManager* GetPermissionManager() override; content::BackgroundSyncController* GetBackgroundSyncController() override; net::URLRequestContextGetter* CreateRequestContext( content::ProtocolHandlerMap* protocol_handlers, diff --git a/vendor/brightray/browser/permission_manager.cc b/vendor/brightray/browser/permission_manager.cc deleted file mode 100644 index 198e35d8c3..0000000000 --- a/vendor/brightray/browser/permission_manager.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE-CHROMIUM file. - -#include "browser/permission_manager.h" - -#include "base/callback.h" -#include "content/public/browser/child_process_security_policy.h" -#include "content/public/browser/permission_type.h" -#include "content/public/browser/render_frame_host.h" -#include "content/public/browser/render_process_host.h" - -namespace brightray { - -PermissionManager::PermissionManager() { -} - -PermissionManager::~PermissionManager() { -} - -int PermissionManager::RequestPermission( - content::PermissionType permission, - content::RenderFrameHost* render_frame_host, - const GURL& requesting_origin, - bool user_gesture, - const base::Callback& callback) { - if (permission == content::PermissionType::MIDI_SYSEX) { - content::ChildProcessSecurityPolicy::GetInstance()-> - GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID()); - } - callback.Run(blink::mojom::PermissionStatus::GRANTED); - return kNoPendingOperation; -} - -int PermissionManager::RequestPermissions( - const std::vector& permissions, - content::RenderFrameHost* render_frame_host, - const GURL& requesting_origin, - bool user_gesture, - const base::Callback&)>& callback) { - std::vector permissionStatuses; - - for (auto permission : permissions) { - if (permission == content::PermissionType::MIDI_SYSEX) { - content::ChildProcessSecurityPolicy::GetInstance()-> - GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID()); - } - - permissionStatuses.push_back(blink::mojom::PermissionStatus::GRANTED); - } - - callback.Run(permissionStatuses); - return kNoPendingOperation; -} - -void PermissionManager::CancelPermissionRequest(int request_id) { -} - -void PermissionManager::ResetPermission( - content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin) { -} - -blink::mojom::PermissionStatus PermissionManager::GetPermissionStatus( - content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin) { - return blink::mojom::PermissionStatus::GRANTED; -} - -int PermissionManager::SubscribePermissionStatusChange( - content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin, - const base::Callback& callback) { - return -1; -} - -void PermissionManager::UnsubscribePermissionStatusChange(int subscription_id) { -} - -} // namespace brightray diff --git a/vendor/brightray/browser/permission_manager.h b/vendor/brightray/browser/permission_manager.h deleted file mode 100644 index 1b649d89e2..0000000000 --- a/vendor/brightray/browser/permission_manager.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE-CHROMIUM file. - -#ifndef BROWSER_PERMISSION_MANAGER_H_ -#define BROWSER_PERMISSION_MANAGER_H_ - -#include "base/callback_forward.h" -#include "base/macros.h" -#include "content/public/browser/permission_manager.h" - -namespace brightray { - -class PermissionManager : public content::PermissionManager { - public: - PermissionManager(); - ~PermissionManager() override; - - // content::PermissionManager: - int RequestPermission( - content::PermissionType permission, - content::RenderFrameHost* render_frame_host, - const GURL& requesting_origin, - bool user_gesture, - const base::Callback& callback) override; - int RequestPermissions( - const std::vector& permissions, - content::RenderFrameHost* render_frame_host, - const GURL& requesting_origin, - bool user_gesture, - const base::Callback&)>& callback) override; - void CancelPermissionRequest(int request_id) override; - void ResetPermission(content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin) override; - blink::mojom::PermissionStatus GetPermissionStatus( - content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin) override; - int SubscribePermissionStatusChange( - content::PermissionType permission, - const GURL& requesting_origin, - const GURL& embedding_origin, - const base::Callback& callback) override; - void UnsubscribePermissionStatusChange(int subscription_id) override; - - private: - DISALLOW_COPY_AND_ASSIGN(PermissionManager); -}; - -} // namespace brightray - -#endif // BROWSER_PERMISSION_MANAGER_H_