| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 namespace content { | 56 namespace content { |
| 57 | 57 |
| 58 // static | 58 // static |
| 59 BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL; | 59 BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL; |
| 60 | 60 |
| 61 // Parent class for the various types of permission requests, each of which | 61 // Parent class for the various types of permission requests, each of which |
| 62 // should be able to handle the response to their permission request. | 62 // should be able to handle the response to their permission request. |
| 63 class BrowserPluginGuest::PermissionRequest : | 63 class BrowserPluginGuest::PermissionRequest : |
| 64 public base::RefCounted<BrowserPluginGuest::PermissionRequest> { | 64 public base::RefCounted<BrowserPluginGuest::PermissionRequest> { |
| 65 public: | 65 public: |
| 66 virtual void Respond(bool should_allow, const std::string& user_input) = 0; | 66 void Respond(bool should_allow, const std::string& user_input) { |
| 67 if (!guest_) |
| 68 return; |
| 69 RespondImpl(should_allow, user_input); |
| 70 } |
| 67 virtual bool AllowedByDefault() const { | 71 virtual bool AllowedByDefault() const { |
| 68 return false; | 72 return false; |
| 69 } | 73 } |
| 70 protected: | 74 protected: |
| 71 PermissionRequest() { | 75 explicit PermissionRequest(const base::WeakPtr<BrowserPluginGuest>& guest) |
| 76 : guest_(guest) { |
| 72 RecordAction( | 77 RecordAction( |
| 73 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest")); | 78 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest")); |
| 74 } | 79 } |
| 75 virtual ~PermissionRequest() {} | 80 virtual ~PermissionRequest() {} |
| 81 |
| 82 virtual void RespondImpl(bool should_allow, |
| 83 const std::string& user_input) = 0; |
| 76 // Friend RefCounted so that the dtor can be non-public. | 84 // Friend RefCounted so that the dtor can be non-public. |
| 77 friend class base::RefCounted<BrowserPluginGuest::PermissionRequest>; | 85 friend class base::RefCounted<BrowserPluginGuest::PermissionRequest>; |
| 86 |
| 87 base::WeakPtr<BrowserPluginGuest> guest_; |
| 78 }; | 88 }; |
| 79 | 89 |
| 80 class BrowserPluginGuest::DownloadRequest : public PermissionRequest { | 90 class BrowserPluginGuest::DownloadRequest : public PermissionRequest { |
| 81 public: | 91 public: |
| 82 explicit DownloadRequest(base::Callback<void(bool)> callback) | 92 DownloadRequest(const base::WeakPtr<BrowserPluginGuest>& guest, |
| 83 : callback_(callback) { | 93 const base::Callback<void(bool)>& callback) |
| 94 : PermissionRequest(guest), |
| 95 callback_(callback) { |
| 84 RecordAction( | 96 RecordAction( |
| 85 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Download"
)); | 97 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Download"
)); |
| 86 } | 98 } |
| 87 virtual void Respond(bool should_allow, | 99 virtual void RespondImpl(bool should_allow, |
| 88 const std::string& user_input) OVERRIDE { | 100 const std::string& user_input) OVERRIDE { |
| 89 callback_.Run(should_allow); | 101 callback_.Run(should_allow); |
| 90 } | 102 } |
| 91 | 103 |
| 92 private: | 104 private: |
| 93 virtual ~DownloadRequest() {} | 105 virtual ~DownloadRequest() {} |
| 94 base::Callback<void(bool)> callback_; | 106 base::Callback<void(bool)> callback_; |
| 95 }; | 107 }; |
| 96 | 108 |
| 97 class BrowserPluginGuest::GeolocationRequest : public PermissionRequest { | 109 class BrowserPluginGuest::GeolocationRequest : public PermissionRequest { |
| 98 public: | 110 public: |
| 99 GeolocationRequest(GeolocationCallback callback, | 111 GeolocationRequest(const base::WeakPtr<BrowserPluginGuest>& guest, |
| 100 int bridge_id, | 112 GeolocationCallback callback, |
| 101 base::WeakPtrFactory<BrowserPluginGuest>* weak_ptr_factory) | 113 int bridge_id) |
| 102 : callback_(callback), | 114 : PermissionRequest(guest), |
| 103 bridge_id_(bridge_id), | 115 callback_(callback), |
| 104 weak_ptr_factory_(weak_ptr_factory) { | 116 bridge_id_(bridge_id) { |
| 105 RecordAction( | 117 RecordAction( |
| 106 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Geolocati
on")); | 118 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Geolocati
on")); |
| 107 } | 119 } |
| 108 | 120 |
| 109 virtual void Respond(bool should_allow, | 121 virtual void RespondImpl(bool should_allow, |
| 110 const std::string& user_input) OVERRIDE { | 122 const std::string& user_input) OVERRIDE { |
| 111 base::WeakPtr<BrowserPluginGuest> guest(weak_ptr_factory_->GetWeakPtr()); | 123 WebContents* web_contents = guest_->embedder_web_contents(); |
| 112 | |
| 113 WebContents* web_contents = guest->embedder_web_contents(); | |
| 114 if (should_allow && web_contents) { | 124 if (should_allow && web_contents) { |
| 115 // If renderer side embedder decides to allow gelocation, we need to check | 125 // If renderer side embedder decides to allow gelocation, we need to check |
| 116 // if the app/embedder itself has geolocation access. | 126 // if the app/embedder itself has geolocation access. |
| 117 BrowserContext* browser_context = web_contents->GetBrowserContext(); | 127 BrowserContext* browser_context = web_contents->GetBrowserContext(); |
| 118 if (browser_context) { | 128 if (browser_context) { |
| 119 GeolocationPermissionContext* geolocation_context = | 129 GeolocationPermissionContext* geolocation_context = |
| 120 browser_context->GetGeolocationPermissionContext(); | 130 browser_context->GetGeolocationPermissionContext(); |
| 121 if (geolocation_context) { | 131 if (geolocation_context) { |
| 122 base::Callback<void(bool)> geolocation_callback = base::Bind( | 132 base::Callback<void(bool)> geolocation_callback = base::Bind( |
| 123 &BrowserPluginGuest::SetGeolocationPermission, | 133 &BrowserPluginGuest::SetGeolocationPermission, |
| 124 guest, | 134 guest_, |
| 125 callback_, | 135 callback_, |
| 126 bridge_id_); | 136 bridge_id_); |
| 127 geolocation_context->RequestGeolocationPermission( | 137 geolocation_context->RequestGeolocationPermission( |
| 128 web_contents->GetRenderProcessHost()->GetID(), | 138 web_contents->GetRenderProcessHost()->GetID(), |
| 129 web_contents->GetRoutingID(), | 139 web_contents->GetRoutingID(), |
| 130 // The geolocation permission request here is not initiated | 140 // The geolocation permission request here is not initiated |
| 131 // through WebGeolocationPermissionRequest. We are only interested | 141 // through WebGeolocationPermissionRequest. We are only interested |
| 132 // in the fact whether the embedder/app has geolocation | 142 // in the fact whether the embedder/app has geolocation |
| 133 // permission. Therefore we use an invalid |bridge_id|. | 143 // permission. Therefore we use an invalid |bridge_id|. |
| 134 -1 /* bridge_id */, | 144 -1 /* bridge_id */, |
| 135 web_contents->GetLastCommittedURL(), | 145 web_contents->GetLastCommittedURL(), |
| 136 geolocation_callback); | 146 geolocation_callback); |
| 137 return; | 147 return; |
| 138 } | 148 } |
| 139 } | 149 } |
| 140 } | 150 } |
| 141 guest->SetGeolocationPermission(callback_, bridge_id_, false); | 151 guest_->SetGeolocationPermission(callback_, bridge_id_, false); |
| 142 } | 152 } |
| 143 | 153 |
| 144 private: | 154 private: |
| 145 virtual ~GeolocationRequest() {} | 155 virtual ~GeolocationRequest() {} |
| 146 base::Callback<void(bool)> callback_; | 156 base::Callback<void(bool)> callback_; |
| 147 int bridge_id_; | 157 int bridge_id_; |
| 148 base::WeakPtrFactory<BrowserPluginGuest>* weak_ptr_factory_; | |
| 149 }; | 158 }; |
| 150 | 159 |
| 151 class BrowserPluginGuest::MediaRequest : public PermissionRequest { | 160 class BrowserPluginGuest::MediaRequest : public PermissionRequest { |
| 152 public: | 161 public: |
| 153 MediaRequest(const MediaStreamRequest& request, | 162 MediaRequest(const base::WeakPtr<BrowserPluginGuest>& guest, |
| 154 const MediaResponseCallback& callback, | 163 const MediaStreamRequest& request, |
| 155 BrowserPluginGuest* guest) | 164 const MediaResponseCallback& callback) |
| 156 : request_(request), | 165 : PermissionRequest(guest), |
| 157 callback_(callback), | 166 request_(request), |
| 158 guest_(guest) { | 167 callback_(callback) { |
| 159 RecordAction( | 168 RecordAction( |
| 160 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Media")); | 169 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Media")); |
| 161 } | 170 } |
| 162 | 171 |
| 163 virtual void Respond(bool should_allow, | 172 virtual void RespondImpl(bool should_allow, |
| 164 const std::string& user_input) OVERRIDE { | 173 const std::string& user_input) OVERRIDE { |
| 165 WebContentsImpl* web_contents = guest_->embedder_web_contents(); | 174 WebContentsImpl* web_contents = guest_->embedder_web_contents(); |
| 166 if (should_allow && web_contents) { | 175 if (should_allow && web_contents) { |
| 167 // Re-route the request to the embedder's WebContents; the guest gets the | 176 // Re-route the request to the embedder's WebContents; the guest gets the |
| 168 // permission this way. | 177 // permission this way. |
| 169 web_contents->RequestMediaAccessPermission(request_, callback_); | 178 web_contents->RequestMediaAccessPermission(request_, callback_); |
| 170 } else { | 179 } else { |
| 171 // Deny the request. | 180 // Deny the request. |
| 172 callback_.Run(MediaStreamDevices(), scoped_ptr<MediaStreamUI>()); | 181 callback_.Run(MediaStreamDevices(), scoped_ptr<MediaStreamUI>()); |
| 173 } | 182 } |
| 174 } | 183 } |
| 175 | 184 |
| 176 private: | 185 private: |
| 177 virtual ~MediaRequest() {} | 186 virtual ~MediaRequest() {} |
| 178 MediaStreamRequest request_; | 187 MediaStreamRequest request_; |
| 179 MediaResponseCallback callback_; | 188 MediaResponseCallback callback_; |
| 180 BrowserPluginGuest* guest_; | |
| 181 }; | 189 }; |
| 182 | 190 |
| 183 class BrowserPluginGuest::NewWindowRequest : public PermissionRequest { | 191 class BrowserPluginGuest::NewWindowRequest : public PermissionRequest { |
| 184 public: | 192 public: |
| 185 NewWindowRequest(int instance_id, BrowserPluginGuest* guest) | 193 NewWindowRequest(const base::WeakPtr<BrowserPluginGuest>& guest, |
| 186 : instance_id_(instance_id), | 194 int instance_id) |
| 187 guest_(guest) { | 195 : PermissionRequest(guest), |
| 196 instance_id_(instance_id) { |
| 188 RecordAction( | 197 RecordAction( |
| 189 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.NewWindow
")); | 198 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.NewWindow
")); |
| 190 } | 199 } |
| 191 | 200 |
| 192 virtual void Respond(bool should_allow, | 201 virtual void RespondImpl(bool should_allow, |
| 193 const std::string& user_input) OVERRIDE { | 202 const std::string& user_input) OVERRIDE { |
| 194 int embedder_render_process_id = | 203 int embedder_render_process_id = |
| 195 guest_->embedder_web_contents()->GetRenderProcessHost()->GetID(); | 204 guest_->embedder_web_contents()->GetRenderProcessHost()->GetID(); |
| 196 BrowserPluginGuest* guest = | 205 BrowserPluginGuest* guest = |
| 197 guest_->GetWebContents()->GetBrowserPluginGuestManager()-> | 206 guest_->GetWebContents()->GetBrowserPluginGuestManager()-> |
| 198 GetGuestByInstanceID(instance_id_, embedder_render_process_id); | 207 GetGuestByInstanceID(instance_id_, embedder_render_process_id); |
| 199 if (!guest) { | 208 if (!guest) { |
| 200 VLOG(0) << "Guest not found. Instance ID: " << instance_id_; | 209 VLOG(0) << "Guest not found. Instance ID: " << instance_id_; |
| 201 return; | 210 return; |
| 202 } | 211 } |
| 203 | 212 |
| 204 // If we do not destroy the guest then we allow the new window. | 213 // If we do not destroy the guest then we allow the new window. |
| 205 if (!should_allow) | 214 if (!should_allow) |
| 206 guest->Destroy(); | 215 guest->Destroy(); |
| 207 } | 216 } |
| 208 | 217 |
| 209 private: | 218 private: |
| 210 virtual ~NewWindowRequest() {} | 219 virtual ~NewWindowRequest() {} |
| 211 int instance_id_; | 220 int instance_id_; |
| 212 BrowserPluginGuest* guest_; | |
| 213 }; | 221 }; |
| 214 | 222 |
| 215 class BrowserPluginGuest::JavaScriptDialogRequest : public PermissionRequest { | 223 class BrowserPluginGuest::JavaScriptDialogRequest : public PermissionRequest { |
| 216 public: | 224 public: |
| 217 JavaScriptDialogRequest(const DialogClosedCallback& callback) | 225 JavaScriptDialogRequest(const base::WeakPtr<BrowserPluginGuest>& guest, |
| 218 : callback_(callback) { | 226 const DialogClosedCallback& callback) |
| 227 : PermissionRequest(guest), |
| 228 callback_(callback) { |
| 219 RecordAction( | 229 RecordAction( |
| 220 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.JSDialog"
)); | 230 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.JSDialog"
)); |
| 221 } | 231 } |
| 222 | 232 |
| 223 virtual void Respond(bool should_allow, | 233 virtual void RespondImpl(bool should_allow, |
| 224 const std::string& user_input) OVERRIDE { | 234 const std::string& user_input) OVERRIDE { |
| 225 callback_.Run(should_allow, base::UTF8ToUTF16(user_input)); | 235 callback_.Run(should_allow, base::UTF8ToUTF16(user_input)); |
| 226 } | 236 } |
| 227 | 237 |
| 228 private: | 238 private: |
| 229 virtual ~JavaScriptDialogRequest() {} | 239 virtual ~JavaScriptDialogRequest() {} |
| 230 DialogClosedCallback callback_; | 240 DialogClosedCallback callback_; |
| 231 }; | 241 }; |
| 232 | 242 |
| 233 class BrowserPluginGuest::PointerLockRequest : public PermissionRequest { | 243 class BrowserPluginGuest::PointerLockRequest : public PermissionRequest { |
| 234 public: | 244 public: |
| 235 PointerLockRequest(BrowserPluginGuest* guest) | 245 explicit PointerLockRequest(const base::WeakPtr<BrowserPluginGuest>& guest) |
| 236 : guest_(guest) { | 246 : PermissionRequest(guest) { |
| 237 RecordAction( | 247 RecordAction( |
| 238 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.PointerLo
ck")); | 248 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.PointerLo
ck")); |
| 239 } | 249 } |
| 240 | 250 |
| 241 virtual void Respond(bool should_allow, | 251 virtual void RespondImpl(bool should_allow, |
| 242 const std::string& user_input) OVERRIDE { | 252 const std::string& user_input) OVERRIDE { |
| 243 guest_->SendMessageToEmbedder( | 253 guest_->SendMessageToEmbedder( |
| 244 new BrowserPluginMsg_SetMouseLock(guest_->instance_id(), should_allow)); | 254 new BrowserPluginMsg_SetMouseLock(guest_->instance_id(), should_allow)); |
| 245 } | 255 } |
| 246 | 256 |
| 247 private: | 257 private: |
| 248 virtual ~PointerLockRequest() {} | 258 virtual ~PointerLockRequest() {} |
| 249 BrowserPluginGuest* guest_; | |
| 250 }; | 259 }; |
| 251 | 260 |
| 252 namespace { | 261 namespace { |
| 253 std::string WindowOpenDispositionToString( | 262 std::string WindowOpenDispositionToString( |
| 254 WindowOpenDisposition window_open_disposition) { | 263 WindowOpenDisposition window_open_disposition) { |
| 255 switch (window_open_disposition) { | 264 switch (window_open_disposition) { |
| 256 case IGNORE_ACTION: | 265 case IGNORE_ACTION: |
| 257 return "ignore"; | 266 return "ignore"; |
| 258 case SAVE_TO_DISK: | 267 case SAVE_TO_DISK: |
| 259 return "save_to_disk"; | 268 return "save_to_disk"; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 } | 428 } |
| 420 request_itr->second->Respond(should_allow, user_input); | 429 request_itr->second->Respond(should_allow, user_input); |
| 421 permission_request_map_.erase(request_itr); | 430 permission_request_map_.erase(request_itr); |
| 422 } | 431 } |
| 423 | 432 |
| 424 int BrowserPluginGuest::RequestPermission( | 433 int BrowserPluginGuest::RequestPermission( |
| 425 BrowserPluginPermissionType permission_type, | 434 BrowserPluginPermissionType permission_type, |
| 426 scoped_refptr<BrowserPluginGuest::PermissionRequest> request, | 435 scoped_refptr<BrowserPluginGuest::PermissionRequest> request, |
| 427 const base::DictionaryValue& request_info) { | 436 const base::DictionaryValue& request_info) { |
| 428 if (!delegate_) { | 437 if (!delegate_) { |
| 429 request->Respond(false, ""); | 438 // Let the stack unwind before we deny the permission request so that |
| 439 // objects held by the permission request are not destroyed immediately |
| 440 // after creation. This is to allow those same objects to be accessed again |
| 441 // in the same scope without fear of use after freeing. |
| 442 base::MessageLoop::current()->PostTask( |
| 443 FROM_HERE, |
| 444 base::Bind(&BrowserPluginGuest::PermissionRequest::Respond, |
| 445 request, false, "")); |
| 430 return browser_plugin::kInvalidPermissionRequestID; | 446 return browser_plugin::kInvalidPermissionRequestID; |
| 431 } | 447 } |
| 432 | 448 |
| 433 int request_id = ++next_permission_request_id_; | 449 int request_id = ++next_permission_request_id_; |
| 434 permission_request_map_[request_id] = request; | 450 permission_request_map_[request_id] = request; |
| 435 | 451 |
| 436 BrowserPluginGuestDelegate::PermissionResponseCallback callback = | 452 BrowserPluginGuestDelegate::PermissionResponseCallback callback = |
| 437 base::Bind(&BrowserPluginGuest::RespondToPermissionRequest, | 453 base::Bind(&BrowserPluginGuest::RespondToPermissionRequest, |
| 438 AsWeakPtr(), | 454 AsWeakPtr(), |
| 439 request_id); | 455 request_id); |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 base::Value::CreateStringValue(new_window_info.url.spec())); | 959 base::Value::CreateStringValue(new_window_info.url.spec())); |
| 944 request_info.Set(browser_plugin::kName, | 960 request_info.Set(browser_plugin::kName, |
| 945 base::Value::CreateStringValue(new_window_info.name)); | 961 base::Value::CreateStringValue(new_window_info.name)); |
| 946 request_info.Set(browser_plugin::kWindowID, | 962 request_info.Set(browser_plugin::kWindowID, |
| 947 base::Value::CreateIntegerValue(guest->instance_id())); | 963 base::Value::CreateIntegerValue(guest->instance_id())); |
| 948 request_info.Set(browser_plugin::kWindowOpenDisposition, | 964 request_info.Set(browser_plugin::kWindowOpenDisposition, |
| 949 base::Value::CreateStringValue( | 965 base::Value::CreateStringValue( |
| 950 WindowOpenDispositionToString(disposition))); | 966 WindowOpenDispositionToString(disposition))); |
| 951 | 967 |
| 952 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_NEW_WINDOW, | 968 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_NEW_WINDOW, |
| 953 new NewWindowRequest(guest->instance_id(), this), | 969 new NewWindowRequest(weak_ptr_factory_.GetWeakPtr(), |
| 970 guest->instance_id()), |
| 954 request_info); | 971 request_info); |
| 955 } | 972 } |
| 956 | 973 |
| 957 bool BrowserPluginGuest::UnlockMouseIfNecessary( | 974 bool BrowserPluginGuest::UnlockMouseIfNecessary( |
| 958 const NativeWebKeyboardEvent& event) { | 975 const NativeWebKeyboardEvent& event) { |
| 959 if (!mouse_locked_) | 976 if (!mouse_locked_) |
| 960 return false; | 977 return false; |
| 961 | 978 |
| 962 embedder_web_contents()->GotResponseToLockMouseRequest(false); | 979 embedder_web_contents()->GotResponseToLockMouseRequest(false); |
| 963 return true; | 980 return true; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 void BrowserPluginGuest::AskEmbedderForGeolocationPermission( | 1025 void BrowserPluginGuest::AskEmbedderForGeolocationPermission( |
| 1009 int bridge_id, | 1026 int bridge_id, |
| 1010 const GURL& requesting_frame, | 1027 const GURL& requesting_frame, |
| 1011 const GeolocationCallback& callback) { | 1028 const GeolocationCallback& callback) { |
| 1012 base::DictionaryValue request_info; | 1029 base::DictionaryValue request_info; |
| 1013 request_info.Set(browser_plugin::kURL, | 1030 request_info.Set(browser_plugin::kURL, |
| 1014 base::Value::CreateStringValue(requesting_frame.spec())); | 1031 base::Value::CreateStringValue(requesting_frame.spec())); |
| 1015 | 1032 |
| 1016 int request_id = | 1033 int request_id = |
| 1017 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_GEOLOCATION, | 1034 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_GEOLOCATION, |
| 1018 new GeolocationRequest( | 1035 new GeolocationRequest(weak_ptr_factory_.GetWeakPtr(), |
| 1019 callback, bridge_id, &weak_ptr_factory_), | 1036 callback, |
| 1037 bridge_id), |
| 1020 request_info); | 1038 request_info); |
| 1021 | 1039 |
| 1022 DCHECK(bridge_id_to_request_id_map_.find(bridge_id) == | 1040 DCHECK(bridge_id_to_request_id_map_.find(bridge_id) == |
| 1023 bridge_id_to_request_id_map_.end()); | 1041 bridge_id_to_request_id_map_.end()); |
| 1024 bridge_id_to_request_id_map_[bridge_id] = request_id; | 1042 bridge_id_to_request_id_map_[bridge_id] = request_id; |
| 1025 } | 1043 } |
| 1026 | 1044 |
| 1027 int BrowserPluginGuest::RemoveBridgeID(int bridge_id) { | 1045 int BrowserPluginGuest::RemoveBridgeID(int bridge_id) { |
| 1028 std::map<int, int>::iterator bridge_itr = | 1046 std::map<int, int>::iterator bridge_itr = |
| 1029 bridge_id_to_request_id_map_.find(bridge_id); | 1047 bridge_id_to_request_id_map_.find(bridge_id); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 base::DictionaryValue request_info; | 1425 base::DictionaryValue request_info; |
| 1408 request_info.Set(browser_plugin::kUserGesture, | 1426 request_info.Set(browser_plugin::kUserGesture, |
| 1409 base::Value::CreateBooleanValue(user_gesture)); | 1427 base::Value::CreateBooleanValue(user_gesture)); |
| 1410 request_info.Set(browser_plugin::kLastUnlockedBySelf, | 1428 request_info.Set(browser_plugin::kLastUnlockedBySelf, |
| 1411 base::Value::CreateBooleanValue(last_unlocked_by_target)); | 1429 base::Value::CreateBooleanValue(last_unlocked_by_target)); |
| 1412 request_info.Set(browser_plugin::kURL, | 1430 request_info.Set(browser_plugin::kURL, |
| 1413 base::Value::CreateStringValue( | 1431 base::Value::CreateStringValue( |
| 1414 web_contents()->GetLastCommittedURL().spec())); | 1432 web_contents()->GetLastCommittedURL().spec())); |
| 1415 | 1433 |
| 1416 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_POINTER_LOCK, | 1434 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_POINTER_LOCK, |
| 1417 new PointerLockRequest(this), | 1435 new PointerLockRequest(weak_ptr_factory_.GetWeakPtr()), |
| 1418 request_info); | 1436 request_info); |
| 1419 } | 1437 } |
| 1420 | 1438 |
| 1421 void BrowserPluginGuest::OnLockMouseAck(int instance_id, bool succeeded) { | 1439 void BrowserPluginGuest::OnLockMouseAck(int instance_id, bool succeeded) { |
| 1422 Send(new ViewMsg_LockMouse_ACK(routing_id(), succeeded)); | 1440 Send(new ViewMsg_LockMouse_ACK(routing_id(), succeeded)); |
| 1423 pending_lock_request_ = false; | 1441 pending_lock_request_ = false; |
| 1424 if (succeeded) | 1442 if (succeeded) |
| 1425 mouse_locked_ = true; | 1443 mouse_locked_ = true; |
| 1426 } | 1444 } |
| 1427 | 1445 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 void BrowserPluginGuest::RequestMediaAccessPermission( | 1705 void BrowserPluginGuest::RequestMediaAccessPermission( |
| 1688 WebContents* web_contents, | 1706 WebContents* web_contents, |
| 1689 const MediaStreamRequest& request, | 1707 const MediaStreamRequest& request, |
| 1690 const MediaResponseCallback& callback) { | 1708 const MediaResponseCallback& callback) { |
| 1691 base::DictionaryValue request_info; | 1709 base::DictionaryValue request_info; |
| 1692 request_info.Set( | 1710 request_info.Set( |
| 1693 browser_plugin::kURL, | 1711 browser_plugin::kURL, |
| 1694 base::Value::CreateStringValue(request.security_origin.spec())); | 1712 base::Value::CreateStringValue(request.security_origin.spec())); |
| 1695 | 1713 |
| 1696 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_MEDIA, | 1714 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_MEDIA, |
| 1697 new MediaRequest(request, callback, this), | 1715 new MediaRequest(weak_ptr_factory_.GetWeakPtr(), |
| 1716 request, |
| 1717 callback), |
| 1698 request_info); | 1718 request_info); |
| 1699 } | 1719 } |
| 1700 | 1720 |
| 1701 void BrowserPluginGuest::RunJavaScriptDialog( | 1721 void BrowserPluginGuest::RunJavaScriptDialog( |
| 1702 WebContents* web_contents, | 1722 WebContents* web_contents, |
| 1703 const GURL& origin_url, | 1723 const GURL& origin_url, |
| 1704 const std::string& accept_lang, | 1724 const std::string& accept_lang, |
| 1705 JavaScriptMessageType javascript_message_type, | 1725 JavaScriptMessageType javascript_message_type, |
| 1706 const base::string16& message_text, | 1726 const base::string16& message_text, |
| 1707 const base::string16& default_prompt_text, | 1727 const base::string16& default_prompt_text, |
| 1708 const DialogClosedCallback& callback, | 1728 const DialogClosedCallback& callback, |
| 1709 bool* did_suppress_message) { | 1729 bool* did_suppress_message) { |
| 1710 base::DictionaryValue request_info; | 1730 base::DictionaryValue request_info; |
| 1711 request_info.Set( | 1731 request_info.Set( |
| 1712 browser_plugin::kDefaultPromptText, | 1732 browser_plugin::kDefaultPromptText, |
| 1713 base::Value::CreateStringValue(base::UTF16ToUTF8(default_prompt_text))); | 1733 base::Value::CreateStringValue(base::UTF16ToUTF8(default_prompt_text))); |
| 1714 request_info.Set( | 1734 request_info.Set( |
| 1715 browser_plugin::kMessageText, | 1735 browser_plugin::kMessageText, |
| 1716 base::Value::CreateStringValue(base::UTF16ToUTF8(message_text))); | 1736 base::Value::CreateStringValue(base::UTF16ToUTF8(message_text))); |
| 1717 request_info.Set( | 1737 request_info.Set( |
| 1718 browser_plugin::kMessageType, | 1738 browser_plugin::kMessageType, |
| 1719 base::Value::CreateStringValue( | 1739 base::Value::CreateStringValue( |
| 1720 JavaScriptMessageTypeToString(javascript_message_type))); | 1740 JavaScriptMessageTypeToString(javascript_message_type))); |
| 1721 request_info.Set( | 1741 request_info.Set( |
| 1722 browser_plugin::kURL, | 1742 browser_plugin::kURL, |
| 1723 base::Value::CreateStringValue(origin_url.spec())); | 1743 base::Value::CreateStringValue(origin_url.spec())); |
| 1724 | 1744 |
| 1725 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_JAVASCRIPT_DIALOG, | 1745 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_JAVASCRIPT_DIALOG, |
| 1726 new JavaScriptDialogRequest(callback), | 1746 new JavaScriptDialogRequest(weak_ptr_factory_.GetWeakPtr(), |
| 1747 callback), |
| 1727 request_info); | 1748 request_info); |
| 1728 } | 1749 } |
| 1729 | 1750 |
| 1730 void BrowserPluginGuest::RunBeforeUnloadDialog( | 1751 void BrowserPluginGuest::RunBeforeUnloadDialog( |
| 1731 WebContents* web_contents, | 1752 WebContents* web_contents, |
| 1732 const base::string16& message_text, | 1753 const base::string16& message_text, |
| 1733 bool is_reload, | 1754 bool is_reload, |
| 1734 const DialogClosedCallback& callback) { | 1755 const DialogClosedCallback& callback) { |
| 1735 // This is called if the guest has a beforeunload event handler. | 1756 // This is called if the guest has a beforeunload event handler. |
| 1736 // This callback allows navigation to proceed. | 1757 // This callback allows navigation to proceed. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1846 callback.Run(false); | 1867 callback.Run(false); |
| 1847 return; | 1868 return; |
| 1848 } | 1869 } |
| 1849 | 1870 |
| 1850 base::DictionaryValue request_info; | 1871 base::DictionaryValue request_info; |
| 1851 request_info.Set(browser_plugin::kRequestMethod, | 1872 request_info.Set(browser_plugin::kRequestMethod, |
| 1852 base::Value::CreateStringValue(request_method)); | 1873 base::Value::CreateStringValue(request_method)); |
| 1853 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); | 1874 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); |
| 1854 | 1875 |
| 1855 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, | 1876 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, |
| 1856 new DownloadRequest(callback), | 1877 new DownloadRequest(weak_ptr_factory_.GetWeakPtr(), |
| 1878 callback), |
| 1857 request_info); | 1879 request_info); |
| 1858 } | 1880 } |
| 1859 | 1881 |
| 1860 } // namespace content | 1882 } // namespace content |
| OLD | NEW |