Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2223)

Unified Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 21297005: <webview>: Refactor Permission API to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_permissions
Patch Set: Fixed some bugs Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/browser_plugin/browser_plugin.cc
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc
index fe2679424263d0545d44e42a81c9d1ae51ebab82..5cf2c99fba0da5bbdcb3cb1ac2ff3facd54c87ca 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin.cc
@@ -59,28 +59,6 @@ static std::string GetInternalEventName(const char* event_name) {
return base::StringPrintf("-internal-%s", event_name);
}
-static std::string PermissionTypeToString(BrowserPluginPermissionType type) {
- switch (type) {
- case BrowserPluginPermissionTypeDownload:
- return browser_plugin::kPermissionTypeDownload;
- case BrowserPluginPermissionTypeGeolocation:
- return browser_plugin::kPermissionTypeGeolocation;
- case BrowserPluginPermissionTypeMedia:
- return browser_plugin::kPermissionTypeMedia;
- case BrowserPluginPermissionTypeNewWindow:
- return browser_plugin::kPermissionTypeNewWindow;
- case BrowserPluginPermissionTypePointerLock:
- return browser_plugin::kPermissionTypePointerLock;
- case BrowserPluginPermissionTypeJavaScriptDialog:
- return browser_plugin::kPermissionTypeDialog;
- case BrowserPluginPermissionTypeUnknown:
- default:
- NOTREACHED();
- break;
- }
- return std::string();
-}
-
typedef std::map<WebKit::WebPluginContainer*,
BrowserPlugin*> PluginContainerMap;
static base::LazyInstance<PluginContainerMap> g_plugin_container_map =
@@ -148,7 +126,6 @@ bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestContentWindowReady,
OnGuestContentWindowReady)
IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone)
- IPC_MESSAGE_HANDLER(BrowserPluginMsg_RequestPermission, OnRequestPermission)
IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor)
IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock)
IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents,
@@ -483,38 +460,6 @@ void BrowserPlugin::OnGuestGone(int guest_instance_id) {
weak_ptr_factory_.GetWeakPtr()));
}
-void BrowserPlugin::OnRequestPermission(
- int guest_instance_id,
- BrowserPluginPermissionType permission_type,
- int request_id,
- const base::DictionaryValue& request_info) {
- // The New Window API is very similiar to the permission API in structure,
- // but exposes a slightly different interface to the developer and so we put
- // it in a separate event.
- const char* event_name = NULL;
- if (permission_type == BrowserPluginPermissionTypeNewWindow) {
- event_name = browser_plugin::kEventNewWindow;
- } else if (permission_type == BrowserPluginPermissionTypeJavaScriptDialog) {
- event_name = browser_plugin::kEventDialog;
- } else {
- event_name = browser_plugin::kEventRequestPermission;
- }
- AddPermissionRequestToSet(request_id);
-
- std::map<std::string, base::Value*> props;
- props[browser_plugin::kPermission] =
- base::Value::CreateStringValue(PermissionTypeToString(permission_type));
- props[browser_plugin::kRequestId] =
- base::Value::CreateIntegerValue(request_id);
-
- // Fill in the info provided by the browser.
- for (DictionaryValue::Iterator iter(request_info); !iter.IsAtEnd();
- iter.Advance()) {
- props[iter.key()] = iter.value().DeepCopy();
- }
- TriggerEvent(event_name, &props);
-}
-
void BrowserPlugin::OnSetCursor(int guest_instance_id,
const WebCursor& cursor) {
cursor_ = cursor;
@@ -549,11 +494,6 @@ void BrowserPlugin::OnUpdatedName(int guest_instance_id,
UpdateDOMAttribute(browser_plugin::kAttributeName, name);
}
-void BrowserPlugin::AddPermissionRequestToSet(int request_id) {
- DCHECK(!pending_permission_requests_.count(request_id));
- pending_permission_requests_.insert(request_id);
-}
-
void BrowserPlugin::OnUpdateRect(
int guest_instance_id,
const BrowserPluginMsg_UpdateRect_Params& params) {
@@ -968,26 +908,6 @@ WebKit::WebPluginContainer* BrowserPlugin::container() const {
return container_;
}
-void BrowserPlugin::RespondPermission(
- int request_id, bool allow, const std::string& user_input) {
- browser_plugin_manager()->Send(
- new BrowserPluginHostMsg_RespondPermission(
- render_view_routing_id_, guest_instance_id_,
- request_id, allow, user_input));
-}
-
-bool BrowserPlugin::RespondPermissionIfRequestIsPending(
- int request_id, bool allow, const std::string& user_input) {
- PendingPermissionRequests::iterator iter =
- pending_permission_requests_.find(request_id);
- if (iter == pending_permission_requests_.end())
- return false;
-
- pending_permission_requests_.erase(iter);
- RespondPermission(request_id, allow, user_input);
- return true;
-}
-
bool BrowserPlugin::initialize(WebPluginContainer* container) {
if (!container)
return false;
@@ -1152,7 +1072,6 @@ bool BrowserPlugin::ShouldForwardToBrowserPlugin(
case BrowserPluginMsg_CompositorFrameSwapped::ID:
case BrowserPluginMsg_GuestContentWindowReady::ID:
case BrowserPluginMsg_GuestGone::ID:
- case BrowserPluginMsg_RequestPermission::ID:
case BrowserPluginMsg_SetCursor::ID:
case BrowserPluginMsg_SetMouseLock::ID:
case BrowserPluginMsg_ShouldAcceptTouchEvents::ID:

Powered by Google App Engine
This is Rietveld 408576698