"browser/mime_override_manager_efl.h",
"browser/navigation_policy_handler_efl.cc",
"browser/navigation_policy_handler_efl.h",
- "browser/permission_manager_efl.cc",
- "browser/permission_manager_efl.h",
"browser/policy_response_delegate_efl.cc",
"browser/policy_response_delegate_efl.h",
"browser/quota_permission_context_efl.cc",
"network_delegate_efl.h",
"notification_permission_popup.cc",
"notification_permission_popup.h",
+ "permission_controller_delegate_efl.cc",
+ "permission_controller_delegate_efl.h",
"permission_popup.h",
"permission_popup_manager.cc",
"permission_popup_manager.h",
"browser/favicon/favicon_database_p.h",
"browser/favicon/favicon_downloader.cc",
"browser/favicon/favicon_downloader.h",
- "browser/geolocation/access_token_store_efl.cc",
- "browser/geolocation/access_token_store_efl.h",
"browser/geolocation/geolocation_permission_context_efl.cc",
"browser/geolocation/geolocation_permission_context_efl.h",
"browser/geolocation/location_provider_efl.cc",
# FIXME: Followings are guarded just for bringup.
if (ewk_bringup) {
sources -= [
- "browser/geolocation/access_token_store_efl.cc",
- "browser/geolocation/access_token_store_efl.h",
- "browser/geolocation/geolocation_permission_context_efl.cc",
- "browser/geolocation/geolocation_permission_context_efl.h",
"browser/geolocation/location_provider_efl.cc",
"browser/geolocation/location_provider_efl.h",
"browser/vibration/vibration_provider_client.cc",
+++ /dev/null
-// Copyright 2013 Samsung Electronics. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "browser/geolocation/access_token_store_efl.h"
-
-#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
-#include "base/strings/utf_string_conversions.h"
-#include "content/public/browser/browser_thread.h"
-#include "eweb_context.h"
-#include "ewk_global_data.h"
-#include "private/ewk_context_private.h"
-
-namespace device {
-
-AccessTokenStoreEfl::AccessTokenStoreEfl()
- : system_request_context_(NULL)
-{
-}
-
-AccessTokenStoreEfl::~AccessTokenStoreEfl()
-{
-}
-
-void AccessTokenStoreEfl::LoadAccessTokens(const LoadAccessTokensCallback& callback)
-{
- content::BrowserThread::PostTaskAndReply(
- content::BrowserThread::UI, FROM_HERE,
- base::Bind(&AccessTokenStoreEfl::GetRequestContextOnUIThread, this),
- base::Bind(&AccessTokenStoreEfl::RespondOnOriginatingThread, this,
- callback));
-}
-
-void AccessTokenStoreEfl::GetRequestContextOnUIThread()
-{
- system_request_context_ = EwkGlobalData::GetInstance()->GetSystemRequestContextGetter();
-}
-
-void AccessTokenStoreEfl::RespondOnOriginatingThread(const LoadAccessTokensCallback& callback)
-{
- AccessTokenMap access_token_map;
- callback.Run(access_token_map, system_request_context_);
-}
-
-void AccessTokenStoreEfl::SaveAccessToken(const GURL& /*server_url*/, const base::string16& /*access_token*/)
-{
-}
-
-} // namespace device
+++ /dev/null
-// Copyright 2013 Samsung Electronics. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ACCESS_TOKEN_STORE_EFL_H_
-#define ACCESS_TOKEN_STORE_EFL_H_
-
-#include "browser_context_efl.h"
-#include "device/geolocation/access_token_store.h"
-
-namespace content {
-class BrowserContextEfl;
-}
-
-namespace device {
-
-class AccessTokenStoreEfl : public device::AccessTokenStore {
- public:
- AccessTokenStoreEfl();
-
- // AccessTokenStore
- virtual void LoadAccessTokens(const LoadAccessTokensCallback& callback) override;
- virtual void SaveAccessToken(const GURL& server_url, const base::string16& access_token) override;
-
- private:
- virtual ~AccessTokenStoreEfl();
-
- void GetRequestContextOnUIThread();
- void RespondOnOriginatingThread(const LoadAccessTokensCallback& callback);
-
- net::URLRequestContextGetter* system_request_context_;
-
- DISALLOW_COPY_AND_ASSIGN(AccessTokenStoreEfl);
-};
-
-} // namespace device
-
-#endif // ACCESS_TOKEN_STORE_EFL_H_
-
: weak_ptr_factory_(this) {
}
+GeolocationPermissionContextEfl::~GeolocationPermissionContextEfl() {}
+
void GeolocationPermissionContextEfl::RequestPermissionOnUIThread(
int render_process_id,
int render_frame_id,
base::Callback<void(PermissionStatus)> callback) const {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
WebContents* web_contents = WebContentsFromFrameID(render_process_id, render_frame_id);
- if (!web_contents)
+ if (!web_contents) {
+ callback.Run(PermissionStatus::DENIED);
return;
+ }
EWebView* web_view = WebViewFromWebContents(web_contents);
int render_frame_id,
const GURL& requesting_frame,
base::Callback<void(PermissionStatus)> callback) const {
- base::PostTaskWithTraits(
+ base::PostTask(
FROM_HERE, {BrowserThread::UI},
base::Bind(&GeolocationPermissionContextEfl::RequestPermissionOnUIThread,
weak_ptr_factory_.GetWeakPtr(), render_process_id,
class GeolocationPermissionContextEfl final {
public:
GeolocationPermissionContextEfl();
+ ~GeolocationPermissionContextEfl();
// The renderer is requesting permission to use Geolocation.
// When the answer to a permission request has been determined, |callback|
+++ /dev/null
-// Copyright 2015 Samsung Electronics. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "permission_manager_efl.h"
-
-#include "base/callback.h"
-#include "browser/geolocation/geolocation_permission_context_efl.h"
-#include "browser/notification/notification_controller_efl.h"
-#include "browser_context_efl.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/permission_controller.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/web_contents.h"
-#include "content_browser_client_efl.h"
-#include "content_main_delegate_efl.h"
-#include "ewk_global_data.h"
-
-using namespace blink::mojom;
-
-namespace content {
-
-PermissionManagerEfl::PermissionManagerEfl() {
-}
-
-PermissionManagerEfl::~PermissionManagerEfl() {
-}
-
-int PermissionManagerEfl::RequestPermission(
- PermissionType permission,
- content::RenderFrameHost* render_frame_host,
- const GURL& requesting_origin,
- bool user_gesture,
- base::OnceCallback<void(PermissionStatus)> callback) {
-#if !defined(EWK_BRINGUP) // FIXME: m67 bringup
- // [M48_2564] Temporary disabling the codes for switching to new chromium
- // FIXME: http://web.sec.samsung.net/bugzilla/show_bug.cgi?id=15387
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- content::WebContents* web_contents =
- content::WebContents::FromRenderFrameHost(render_frame_host);
-
- switch (permission) {
- case PermissionType::GEOLOCATION: {
- BrowserContextEfl* browser_context =
- static_cast<BrowserContextEfl*>(web_contents->GetBrowserContext());
- if (!browser_context) {
- LOG(ERROR) << "Dropping GeolocationPermission request";
- callback.Run(PermissionStatus::PERMISSION_STATUS_DENIED);
- return;
- }
-
- const GeolocationPermissionContextEfl& geolocation_permission_context =
- browser_context->GetGeolocationPermissionContext();
-
- int render_process_id = render_frame_host->GetProcess()->GetID();
- int render_frame_id = render_frame_host->GetRoutingID();
-
- geolocation_permission_context.RequestPermission(render_process_id,
- render_frame_id,
- requesting_origin,
- callback);
- break;
- }
- case PermissionType::NOTIFICATIONS:
- {
-#if defined(ENABLE_NOTIFICATIONS)
- ContentMainDelegateEfl& cmde =
- EwkGlobalData::GetInstance()->GetContentMainDelegateEfl();
- ContentBrowserClientEfl* cbce =
- static_cast<ContentBrowserClientEfl*>(cmde.GetContentBrowserClient());
- if (!cbce) {
- LOG(ERROR) << "Dropping NotificationPermission request";
- callback.Run(PermissionStatus::PERMISSION_STATUS_DENIED);
- return;
- }
-
- cbce->GetNotificationController()->RequestPermission(web_contents,
- requesting_origin,
- callback);
-
-#else
- callback.Run(PermissionStatus::PERMISSION_STATUS_DENIED);
-#endif
- break;
- }
- case PermissionType::PROTECTED_MEDIA_IDENTIFIER:
- case PermissionType::MIDI_SYSEX:
- case PermissionType::PUSH_MESSAGING: {
- NOTIMPLEMENTED() << "RequestPermission not implemented for "
- << static_cast<int>(permission);
- callback.Run(PermissionStatus::PERMISSION_STATUS_DENIED);
- break;
- }
- default: {
- NOTREACHED() << "Invalid RequestPermission for "
- << static_cast<int>(permission);
- }
- }
-#else
- NOTIMPLEMENTED();
- return PermissionController::kNoPendingOperation;
-#endif
-}
-
-int PermissionManagerEfl::RequestPermissions(
- const std::vector<PermissionType>& permission,
- RenderFrameHost* render_frame_host,
- const GURL& requesting_origin,
- bool user_gesture,
- base::OnceCallback<void(const std::vector<PermissionStatus>&)> callback) {
- NOTIMPLEMENTED();
- return PermissionController::kNoPendingOperation;
-}
-
-PermissionStatus PermissionManagerEfl::GetPermissionStatus(
- PermissionType permission,
- const GURL& requesting_origin,
- const GURL& embedding_origin) {
- return PermissionStatus::DENIED;
-}
-
-blink::mojom::PermissionStatus
-PermissionManagerEfl::GetPermissionStatusForFrame(
- PermissionType permission,
- content::RenderFrameHost* render_frame_host,
- const GURL& requesting_origin) {
- return GetPermissionStatus(
- permission, requesting_origin,
- content::WebContents::FromRenderFrameHost(render_frame_host)
- ->GetLastCommittedURL()
- .GetOrigin());
-}
-
-void PermissionManagerEfl::ResetPermission(PermissionType permission,
- const GURL& requesting_origin,
- const GURL& embedding_origin) {
-}
-
-int PermissionManagerEfl::SubscribePermissionStatusChange(
- PermissionType permission,
- content::RenderFrameHost* render_frame_host,
- const GURL& requesting_origin,
- base::RepeatingCallback<void(PermissionStatus)> callback) {
- return -1;
-}
-
-void PermissionManagerEfl::UnsubscribePermissionStatusChange(
- int subscription_id) {
-}
-
-}
+++ /dev/null
-// Copyright 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 file.
-
-#ifndef PERMISSION_MANAGER_EFL_H_
-#define PERMISSION_MANAGER_EFL_H_
-
-#include "base/callback_forward.h"
-#include "base/macros.h"
-#include "content/public/browser/permission_controller_delegate.h"
-
-namespace content {
-
-class CONTENT_EXPORT PermissionManagerEfl
- : public PermissionControllerDelegate {
- public:
-
- PermissionManagerEfl();
- ~PermissionManagerEfl() override;
-
- int RequestPermission(PermissionType permission,
- RenderFrameHost* render_frame_host,
- const GURL& requesting_origin,
- bool user_gesture,
- base::OnceCallback<void(blink::mojom::PermissionStatus)>
- callback) override;
-
- int RequestPermissions(
- const std::vector<PermissionType>& permission,
- RenderFrameHost* render_frame_host,
- const GURL& requesting_origin,
- bool user_gesture,
- base::OnceCallback<
- void(const std::vector<blink::mojom::PermissionStatus>&)> callback)
- override;
-
- blink::mojom::PermissionStatus GetPermissionStatus(
- PermissionType permission,
- const GURL& requesting_origin,
- const GURL& embedding_origin) override;
-
- blink::mojom::PermissionStatus GetPermissionStatusForFrame(
- PermissionType permission,
- RenderFrameHost* render_frame_host,
- const GURL& requesting_origin) override;
-
- void ResetPermission(PermissionType permission,
- const GURL& requesting_origin,
- const GURL& embedding_origin) override;
-
- // Runs the given |callback| whenever the |permission| associated with the
- // pair { requesting_origin, embedding_origin } changes.
- // Returns the subscription_id to be used to unsubscribe.
- int SubscribePermissionStatusChange(
- PermissionType permission,
- content::RenderFrameHost* render_frame_host,
- const GURL& requesting_origin,
- base::RepeatingCallback<void(blink::mojom::PermissionStatus)> callback)
- override;
-
- void UnsubscribePermissionStatusChange(int subscription_id) override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(PermissionManagerEfl);
-};
-
-}
-
-#endif // PERMISSION_MANAGER_EFL_H_
#include "base/synchronization/waitable_event.h"
#include "browser/autofill/personal_data_manager_factory.h"
#include "browser/geolocation/geolocation_permission_context_efl.h"
-#include "browser/permission_manager_efl.h"
#include "browser/webdata/web_data_service_factory.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "content/public/browser/web_contents.h"
#include "eweb_context.h"
#include "network_delegate_efl.h"
+#include "permission_controller_delegate_efl.h"
using namespace prefs;
using namespace password_manager::prefs;
PermissionControllerDelegate*
BrowserContextEfl::GetPermissionControllerDelegate() {
- return nullptr;
+ if (!permission_controller_delegate_.get())
+ permission_controller_delegate_.reset(new PermissionControllerDelegateEfl());
+
+ return permission_controller_delegate_.get();
}
const GeolocationPermissionContextEfl&
const bool incognito_;
std::unique_ptr<net::NetworkDelegate> network_delegate_for_getter_;
std::unique_ptr<SSLHostStateDelegateEfl> ssl_host_state_delegate_;
+ std::unique_ptr<PermissionControllerDelegate> permission_controller_delegate_;
DISALLOW_COPY_AND_ASSIGN(BrowserContextEfl);
};
--- /dev/null
+// Copyright 2015 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "permission_controller_delegate_efl.h"
+
+#include "base/callback.h"
+#include "browser_context_efl.h"
+#include "browser/geolocation/geolocation_permission_context_efl.h"
+#include "browser/notification/notification_controller_efl.h"
+#include "content_browser_client_efl.h"
+#include "content_main_delegate_efl.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/permission_controller.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/web_contents.h"
+#include "ewk_global_data.h"
+
+using namespace blink::mojom;
+
+namespace content {
+
+struct PermissionControllerDelegateEfl::PendingRequest {
+ PendingRequest(const std::vector<PermissionType>& permission_types,
+ content::RenderFrameHost* render_frame_host,
+ PermissionStatusVectorCallback callback)
+ : permission_types_(permission_types),
+ render_process_id_(render_frame_host->GetProcess()->GetID()),
+ render_frame_id_(render_frame_host->GetRoutingID()),
+ callback_(std::move(callback)),
+ results_(permission_types.size(), PermissionStatus::DENIED),
+ remaining_results_(permission_types.size()) {}
+
+ void SetPermissionStatus(int permission_id,
+ PermissionStatus permission_status) {
+ DCHECK(!IsComplete());
+
+ results_[permission_id] = permission_status;
+ --remaining_results_;
+ }
+
+ bool IsComplete() const { return remaining_results_ == 0; }
+
+ PermissionStatusVectorCallback callback() { return std::move(callback_); }
+
+ std::vector<PermissionStatus> results() const { return results_; }
+
+ std::vector<PermissionType> permission_types_;
+ int render_process_id_;
+ int render_frame_id_;
+ PermissionStatusVectorCallback callback_;
+ std::vector<PermissionStatus> results_;
+ size_t remaining_results_;
+};
+
+PermissionControllerDelegateEfl::PermissionControllerDelegateEfl() : weak_ptr_factory_(this) {
+}
+
+PermissionControllerDelegateEfl::~PermissionControllerDelegateEfl() {
+}
+
+void PermissionStatusCallbackWrapper(
+ PermissionStatusCallback callback,
+ const std::vector<PermissionStatus>& permission_status_list) {
+ DCHECK_EQ(1ul, permission_status_list.size());
+ std::move(callback).Run(permission_status_list[0]);
+}
+
+int PermissionControllerDelegateEfl::RequestPermission(
+ PermissionType permission,
+ content::RenderFrameHost* render_frame_host,
+ const GURL& requesting_origin,
+ bool user_gesture,
+ PermissionStatusCallback callback) {
+ return RequestPermissions(
+ std::vector<PermissionType>(1, permission), render_frame_host,
+ requesting_origin, user_gesture,
+ base::BindOnce(&PermissionStatusCallbackWrapper, std::move(callback)));
+}
+
+int PermissionControllerDelegateEfl::RequestPermissions(
+ const std::vector<PermissionType>& permissions,
+ RenderFrameHost* render_frame_host,
+ const GURL& requesting_origin,
+ bool user_gesture,
+ PermissionStatusVectorCallback callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (permissions.empty()) {
+ std::move(callback).Run(std::vector<PermissionStatus>());
+ return content::PermissionController::kNoPendingOperation;
+ }
+
+ content::WebContents* web_contents =
+ content::WebContents::FromRenderFrameHost(render_frame_host);
+
+ PendingRequest* pending_request =
+ new PendingRequest(permissions, render_frame_host, std::move(callback));
+ int request_id = pending_requests_.Add(pending_request);
+
+ for (auto i = 0; i < permissions.size(); ++i) {
+ const auto& permission = permissions[i];
+ switch (permission) {
+ case PermissionType::GEOLOCATION: {
+ BrowserContextEfl* browser_context =
+ static_cast<BrowserContextEfl*>(web_contents->GetBrowserContext());
+ if (!browser_context) {
+ LOG(ERROR) << "Dropping GeolocationPermission request";
+ OnPermissionRequestResponse(request_id, i, PermissionStatus::DENIED);
+ continue;
+ }
+
+ const GeolocationPermissionContextEfl& geolocation_permission_context =
+ browser_context->GetGeolocationPermissionContext();
+
+ geolocation_permission_context.RequestPermission(
+ pending_request->render_process_id_,
+ pending_request->render_frame_id_, requesting_origin,
+ base::Bind(&PermissionControllerDelegateEfl::OnPermissionRequestResponse,
+ weak_ptr_factory_.GetWeakPtr(), request_id, i));
+ break;
+ }
+#if defined(ENABLE_NOTIFICATIONS)
+ case PermissionType::NOTIFICATIONS: {
+ ContentMainDelegateEfl& cmde =
+ EwkGlobalData::GetInstance()->GetContentMainDelegatEfl();
+ ContentBrowserClientEfl* cbce = static_cast<ContentBrowserClientEfl*>(
+ cmde.GetContentBrowserClient());
+ if (!cbce) {
+ LOG(ERROR) << "Dropping NotificationPermission request";
+ OnPermissionRequestResponse(request_id, i, PermissionStatus::DENIED);
+ continue;
+ }
+
+ cbce->GetNotificationController()->RequestPermission(
+ web_contents, requesting_origin,
+ base::Bind(&PermissionControllerDelegateEfl::OnPermissionRequestResponse,
+ weak_ptr_factory_.GetWeakPtr(), request_id, i));
+ break;
+ }
+#endif
+ case PermissionType::PROTECTED_MEDIA_IDENTIFIER:
+ case PermissionType::MIDI_SYSEX: {
+ NOTIMPLEMENTED() << "RequestPermission not implemented for "
+ << static_cast<int>(permission);
+ OnPermissionRequestResponse(request_id, i, PermissionStatus::DENIED);
+ break;
+ }
+ case PermissionType::SENSORS: {
+ NOTIMPLEMENTED() << "RequestPermission not implemented for "
+ << static_cast<int>(permission);
+ // TODO(gajendra.n): Implement SensorPermissionContextEfl similar to
+ // GeolocationPermissionContextEfl. For now, by default permission is
+ // set as GRANTED to enable the feature funtionality working.
+ OnPermissionRequestResponse(request_id, i, PermissionStatus::GRANTED);
+ break;
+ }
+ default: {
+ NOTREACHED() << "Invalid RequestPermission for "
+ << static_cast<int>(permission);
+ }
+ }
+ }
+
+ return request_id;
+}
+
+void PermissionControllerDelegateEfl::OnPermissionRequestResponse(
+ int request_id,
+ int permission_id,
+ PermissionStatus permission_status) {
+ PendingRequest* pending_request = pending_requests_.Lookup(request_id);
+ if (!pending_request)
+ return;
+
+ pending_request->SetPermissionStatus(permission_id, permission_status);
+
+ if (!pending_request->IsComplete())
+ return;
+
+ pending_requests_.Remove(request_id);
+ pending_request->callback().Run(pending_request->results());
+}
+
+PermissionStatus PermissionControllerDelegateEfl::GetPermissionStatus(
+ PermissionType permission,
+ const GURL& requesting_origin,
+ const GURL& embedding_origin) {
+ switch (permission) {
+#if defined(ENABLE_NOTIFICATIONS)
+ case PermissionType::NOTIFICATIONS: {
+ // requesting_origin should be the same as embedding_origin
+ // using push API from iframes are not allowed
+ if (requesting_origin != embedding_origin)
+ return PermissionStatus::DENIED;
+
+ ContentMainDelegateEfl& cmde =
+ EwkGlobalData::GetInstance()->GetContentMainDelegatEfl();
+ ContentBrowserClientEfl* cbce =
+ static_cast<ContentBrowserClientEfl*>(cmde.GetContentBrowserClient());
+ if (!cbce) {
+ LOG(ERROR) << "Dropping NotificationPermission request";
+ return PermissionStatus::DENIED;
+ }
+
+ PermissionStatus notification_status =
+ cbce->GetNotificationController()->CheckPermissionOnIOThread(
+ nullptr, requesting_origin, 0);
+
+ LOG(INFO) << "GetPermissionStatus() type:" << static_cast<int>(permission)
+ << ", status: " << notification_status;
+
+ return notification_status;
+ }
+#endif
+ case PermissionType::PROTECTED_MEDIA_IDENTIFIER:
+ return PermissionStatus::GRANTED;
+ default:
+ return PermissionStatus::DENIED;
+ }
+}
+
+blink::mojom::PermissionStatus
+PermissionControllerDelegateEfl::GetPermissionStatusForFrame(
+ PermissionType permission,
+ content::RenderFrameHost* render_frame_host,
+ const GURL& requesting_origin) {
+ return GetPermissionStatus(
+ permission, requesting_origin,
+ content::WebContents::FromRenderFrameHost(render_frame_host)
+ ->GetLastCommittedURL()
+ .GetOrigin());
+}
+
+void PermissionControllerDelegateEfl::ResetPermission(PermissionType permission,
+ const GURL& requesting_origin,
+ const GURL& embedding_origin) {
+ NOTIMPLEMENTED();
+}
+
+int PermissionControllerDelegateEfl::SubscribePermissionStatusChange(
+ PermissionType permission,
+ content::RenderFrameHost* render_frame_host,
+ const GURL& embedding_origin,
+ base::RepeatingCallback<void(blink::mojom::PermissionStatus)>
+ callback) {
+ NOTIMPLEMENTED();
+ return -1;
+}
+
+void PermissionControllerDelegateEfl::UnsubscribePermissionStatusChange(
+ int subscription_id) {
+ NOTIMPLEMENTED();
+}
+
+} // namespace content
--- /dev/null
+// Copyright 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 file.
+
+#ifndef PERMISSION_CONTROLLER_DELEGATE_EFL_H_
+#define PERMISSION_CONTROLLER_DELEGATE_EFL_H_
+
+#include "base/callback_forward.h"
+#include "base/containers/id_map.h"
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "content/public/browser/permission_controller_delegate.h"
+
+namespace content {
+
+using PermissionStatusCallback = base::OnceCallback<void(blink::mojom::PermissionStatus)>;
+using PermissionStatusVectorCallback =
+ base::OnceCallback<void(const std::vector<blink::mojom::PermissionStatus>&)>;
+
+class CONTENT_EXPORT PermissionControllerDelegateEfl : public PermissionControllerDelegate {
+ public:
+
+ PermissionControllerDelegateEfl();
+ ~PermissionControllerDelegateEfl() override;
+
+ int RequestPermission(PermissionType permission,
+ content::RenderFrameHost* render_frame_host,
+ const GURL& requesting_origin,
+ bool user_gesture,
+ PermissionStatusCallback callback) override;
+
+ int RequestPermissions(
+ const std::vector<PermissionType>& permissions,
+ RenderFrameHost* render_frame_host,
+ const GURL& requesting_origin,
+ bool user_gesture,
+ PermissionStatusVectorCallback callback) override;
+
+ blink::mojom::PermissionStatus GetPermissionStatus(PermissionType permission,
+ const GURL& requesting_origin,
+ const GURL& embedding_origin) override;
+
+ blink::mojom::PermissionStatus GetPermissionStatusForFrame(
+ PermissionType permission,
+ RenderFrameHost* render_frame_host,
+ const GURL& requesting_origin) override;
+
+ void ResetPermission(PermissionType permission,
+ const GURL& requesting_origin,
+ const GURL& embedding_origin) override;
+
+ // Runs the given |callback| whenever the |permission| associated with the
+ // pair { requesting_origin, embedding_origin } changes.
+ // Returns the subscription_id to be used to unsubscribe.
+ int SubscribePermissionStatusChange(
+ PermissionType permission,
+ RenderFrameHost* render_frame_host,
+ const GURL& embedding_origin,
+ base::RepeatingCallback<void(blink::mojom::PermissionStatus)>
+ callback) override;
+
+ void UnsubscribePermissionStatusChange(int subscription_id) override;
+
+ private:
+ struct PendingRequest;
+ using PendingRequestsMap = base::IDMap<PendingRequest*>;
+
+ void OnPermissionRequestResponse(int request_id,
+ int permission_id,
+ blink::mojom::PermissionStatus permission_status);
+
+ PendingRequestsMap pending_requests_;
+ base::WeakPtrFactory<PermissionControllerDelegateEfl> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PermissionControllerDelegateEfl);
+};
+
+}
+
+#endif // PERMISSION_CONTROLLER_DELEGATE_EFL_H_
+