| 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 namespace content { | 55 namespace content { |
| 56 | 56 |
| 57 // static | 57 // static |
| 58 BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL; | 58 BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL; |
| 59 | 59 |
| 60 // Parent class for the various types of permission requests, each of which | 60 // Parent class for the various types of permission requests, each of which |
| 61 // should be able to handle the response to their permission request. | 61 // should be able to handle the response to their permission request. |
| 62 class BrowserPluginGuest::PermissionRequest { | 62 class BrowserPluginGuest::PermissionRequest { |
| 63 public: | 63 public: |
| 64 virtual void Respond(bool should_allow) = 0; | 64 virtual void Respond(bool should_allow, const std::string& user_input) = 0; |
| 65 virtual ~PermissionRequest() {} | 65 virtual ~PermissionRequest() {} |
| 66 virtual BrowserPluginPermissionType GetType() const = 0; | 66 virtual BrowserPluginPermissionType GetType() const = 0; |
| 67 protected: | 67 protected: |
| 68 PermissionRequest() { | 68 PermissionRequest() { |
| 69 RecordAction(UserMetricsAction("BrowserPlugin.Guest.PermissionRequest")); | 69 RecordAction(UserMetricsAction("BrowserPlugin.Guest.PermissionRequest")); |
| 70 } | 70 } |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 class BrowserPluginGuest::DownloadRequest : public PermissionRequest { | 73 class BrowserPluginGuest::DownloadRequest : public PermissionRequest { |
| 74 public: | 74 public: |
| 75 explicit DownloadRequest(base::Callback<void(bool)> callback) | 75 explicit DownloadRequest(base::Callback<void(bool)> callback) |
| 76 : callback_(callback) { | 76 : callback_(callback) { |
| 77 RecordAction( | 77 RecordAction( |
| 78 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Download")); | 78 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Download")); |
| 79 } | 79 } |
| 80 | 80 virtual void Respond(bool should_allow, |
| 81 virtual void Respond(bool should_allow) OVERRIDE { | 81 const std::string& user_input) OVERRIDE { |
| 82 callback_.Run(should_allow); | 82 callback_.Run(should_allow); |
| 83 } | 83 } |
| 84 | 84 |
| 85 virtual BrowserPluginPermissionType GetType() const OVERRIDE { | 85 virtual BrowserPluginPermissionType GetType() const OVERRIDE { |
| 86 return BrowserPluginPermissionTypeDownload; | 86 return BrowserPluginPermissionTypeDownload; |
| 87 } | 87 } |
| 88 | 88 |
| 89 virtual ~DownloadRequest() {} | 89 virtual ~DownloadRequest() {} |
| 90 private: | 90 private: |
| 91 base::Callback<void(bool)> callback_; | 91 base::Callback<void(bool)> callback_; |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 class BrowserPluginGuest::GeolocationRequest : public PermissionRequest { | 94 class BrowserPluginGuest::GeolocationRequest : public PermissionRequest { |
| 95 public: | 95 public: |
| 96 GeolocationRequest(GeolocationCallback callback, | 96 GeolocationRequest(GeolocationCallback callback, |
| 97 int bridge_id, | 97 int bridge_id, |
| 98 BrowserPluginGuest* guest, | 98 BrowserPluginGuest* guest, |
| 99 base::WeakPtrFactory<BrowserPluginGuest>* weak_ptr_factory) | 99 base::WeakPtrFactory<BrowserPluginGuest>* weak_ptr_factory) |
| 100 : callback_(callback), | 100 : callback_(callback), |
| 101 bridge_id_(bridge_id), | 101 bridge_id_(bridge_id), |
| 102 guest_(guest), | 102 guest_(guest), |
| 103 weak_ptr_factory_(weak_ptr_factory) { | 103 weak_ptr_factory_(weak_ptr_factory) { |
| 104 RecordAction( | 104 RecordAction( |
| 105 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Geolocation")); | 105 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Geolocation")); |
| 106 } | 106 } |
| 107 | 107 |
| 108 virtual void Respond(bool should_allow) OVERRIDE { | 108 virtual void Respond(bool should_allow, |
| 109 const std::string& user_input) OVERRIDE { |
| 109 WebContents* web_contents = guest_->embedder_web_contents(); | 110 WebContents* web_contents = guest_->embedder_web_contents(); |
| 110 if (should_allow && web_contents) { | 111 if (should_allow && web_contents) { |
| 111 // If renderer side embedder decides to allow gelocation, we need to check | 112 // If renderer side embedder decides to allow gelocation, we need to check |
| 112 // if the app/embedder itself has geolocation access. | 113 // if the app/embedder itself has geolocation access. |
| 113 BrowserContext* browser_context = web_contents->GetBrowserContext(); | 114 BrowserContext* browser_context = web_contents->GetBrowserContext(); |
| 114 if (browser_context) { | 115 if (browser_context) { |
| 115 GeolocationPermissionContext* geolocation_context = | 116 GeolocationPermissionContext* geolocation_context = |
| 116 browser_context->GetGeolocationPermissionContext(); | 117 browser_context->GetGeolocationPermissionContext(); |
| 117 if (geolocation_context) { | 118 if (geolocation_context) { |
| 118 base::Callback<void(bool)> geolocation_callback = base::Bind( | 119 base::Callback<void(bool)> geolocation_callback = base::Bind( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 MediaRequest(const MediaStreamRequest& request, | 155 MediaRequest(const MediaStreamRequest& request, |
| 155 const MediaResponseCallback& callback, | 156 const MediaResponseCallback& callback, |
| 156 BrowserPluginGuest* guest) | 157 BrowserPluginGuest* guest) |
| 157 : request_(request), | 158 : request_(request), |
| 158 callback_(callback), | 159 callback_(callback), |
| 159 guest_(guest) { | 160 guest_(guest) { |
| 160 RecordAction( | 161 RecordAction( |
| 161 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Media")); | 162 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Media")); |
| 162 } | 163 } |
| 163 | 164 |
| 164 virtual void Respond(bool should_allow) OVERRIDE { | 165 virtual void Respond(bool should_allow, |
| 166 const std::string& user_input) OVERRIDE { |
| 165 WebContentsImpl* web_contents = guest_->embedder_web_contents(); | 167 WebContentsImpl* web_contents = guest_->embedder_web_contents(); |
| 166 if (should_allow && web_contents) { | 168 if (should_allow && web_contents) { |
| 167 // Re-route the request to the embedder's WebContents; the guest gets the | 169 // Re-route the request to the embedder's WebContents; the guest gets the |
| 168 // permission this way. | 170 // permission this way. |
| 169 web_contents->RequestMediaAccessPermission(request_, callback_); | 171 web_contents->RequestMediaAccessPermission(request_, callback_); |
| 170 } else { | 172 } else { |
| 171 // Deny the request. | 173 // Deny the request. |
| 172 callback_.Run(MediaStreamDevices(), scoped_ptr<MediaStreamUI>()); | 174 callback_.Run(MediaStreamDevices(), scoped_ptr<MediaStreamUI>()); |
| 173 } | 175 } |
| 174 } | 176 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 186 | 188 |
| 187 class BrowserPluginGuest::NewWindowRequest : public PermissionRequest { | 189 class BrowserPluginGuest::NewWindowRequest : public PermissionRequest { |
| 188 public: | 190 public: |
| 189 NewWindowRequest(int instance_id, BrowserPluginGuest* guest) | 191 NewWindowRequest(int instance_id, BrowserPluginGuest* guest) |
| 190 : instance_id_(instance_id), | 192 : instance_id_(instance_id), |
| 191 guest_(guest) { | 193 guest_(guest) { |
| 192 RecordAction( | 194 RecordAction( |
| 193 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.NewWindow")); | 195 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.NewWindow")); |
| 194 } | 196 } |
| 195 | 197 |
| 196 virtual void Respond(bool should_allow) OVERRIDE { | 198 virtual void Respond(bool should_allow, |
| 199 const std::string& user_input) OVERRIDE { |
| 197 int embedder_render_process_id = | 200 int embedder_render_process_id = |
| 198 guest_->embedder_web_contents()->GetRenderProcessHost()->GetID(); | 201 guest_->embedder_web_contents()->GetRenderProcessHost()->GetID(); |
| 199 BrowserPluginGuest* guest = | 202 BrowserPluginGuest* guest = |
| 200 guest_->GetWebContents()->GetBrowserPluginGuestManager()-> | 203 guest_->GetWebContents()->GetBrowserPluginGuestManager()-> |
| 201 GetGuestByInstanceID(instance_id_, embedder_render_process_id); | 204 GetGuestByInstanceID(instance_id_, embedder_render_process_id); |
| 202 if (!guest) { | 205 if (!guest) { |
| 203 LOG(INFO) << "Guest not found. Instance ID: " << instance_id_; | 206 LOG(INFO) << "Guest not found. Instance ID: " << instance_id_; |
| 204 return; | 207 return; |
| 205 } | 208 } |
| 206 | 209 |
| 207 // If we do not destroy the guest then we allow the new window. | 210 // If we do not destroy the guest then we allow the new window. |
| 208 if (!should_allow) | 211 if (!should_allow) |
| 209 guest->Destroy(); | 212 guest->Destroy(); |
| 210 } | 213 } |
| 211 | 214 |
| 212 virtual BrowserPluginPermissionType GetType() const OVERRIDE { | 215 virtual BrowserPluginPermissionType GetType() const OVERRIDE { |
| 213 return BrowserPluginPermissionTypeNewWindow; | 216 return BrowserPluginPermissionTypeNewWindow; |
| 214 } | 217 } |
| 215 | 218 |
| 216 virtual ~NewWindowRequest() {} | 219 virtual ~NewWindowRequest() {} |
| 217 private: | 220 private: |
| 218 int instance_id_; | 221 int instance_id_; |
| 219 BrowserPluginGuest* guest_; | 222 BrowserPluginGuest* guest_; |
| 220 }; | 223 }; |
| 221 | 224 |
| 225 class BrowserPluginGuest::JavaScriptDialogRequest : public PermissionRequest { |
| 226 public: |
| 227 JavaScriptDialogRequest(const DialogClosedCallback& callback) |
| 228 : callback_(callback) { |
| 229 RecordAction( |
| 230 UserMetricsAction( |
| 231 "BrowserPlugin.Guest.PermissionRequest.JavaScriptDialog")); |
| 232 } |
| 233 |
| 234 virtual void Respond(bool should_allow, |
| 235 const std::string& user_input) OVERRIDE { |
| 236 callback_.Run(should_allow, UTF8ToUTF16(user_input)); |
| 237 } |
| 238 |
| 239 virtual BrowserPluginPermissionType GetType() const OVERRIDE { |
| 240 return BrowserPluginPermissionTypeJavaScriptDialog; |
| 241 } |
| 242 |
| 243 virtual ~JavaScriptDialogRequest() {} |
| 244 private: |
| 245 DialogClosedCallback callback_; |
| 246 }; |
| 247 |
| 222 class BrowserPluginGuest::PointerLockRequest : public PermissionRequest { | 248 class BrowserPluginGuest::PointerLockRequest : public PermissionRequest { |
| 223 public: | 249 public: |
| 224 PointerLockRequest(BrowserPluginGuest* guest) | 250 PointerLockRequest(BrowserPluginGuest* guest) |
| 225 : guest_(guest) { | 251 : guest_(guest) { |
| 226 RecordAction( | 252 RecordAction( |
| 227 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.PointerLock")); | 253 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.PointerLock")); |
| 228 } | 254 } |
| 229 | 255 |
| 230 virtual void Respond(bool should_allow) OVERRIDE { | 256 virtual void Respond(bool should_allow, |
| 257 const std::string& user_input) OVERRIDE { |
| 231 guest_->SendMessageToEmbedder( | 258 guest_->SendMessageToEmbedder( |
| 232 new BrowserPluginMsg_SetMouseLock(guest_->instance_id(), should_allow)); | 259 new BrowserPluginMsg_SetMouseLock(guest_->instance_id(), should_allow)); |
| 233 } | 260 } |
| 234 | 261 |
| 235 virtual BrowserPluginPermissionType GetType() const OVERRIDE { | 262 virtual BrowserPluginPermissionType GetType() const OVERRIDE { |
| 236 return BrowserPluginPermissionTypePointerLock; | 263 return BrowserPluginPermissionTypePointerLock; |
| 237 } | 264 } |
| 238 | 265 |
| 239 virtual ~PointerLockRequest() {} | 266 virtual ~PointerLockRequest() {} |
| 240 private: | 267 private: |
| 241 BrowserPluginGuest* guest_; | 268 BrowserPluginGuest* guest_; |
| 242 }; | 269 }; |
| 243 | 270 |
| 244 namespace { | 271 namespace { |
| 245 const size_t kNumMaxOutstandingPermissionRequests = 1024; | 272 const size_t kNumMaxOutstandingPermissionRequests = 1024; |
| 246 | 273 |
| 247 static std::string WindowOpenDispositionToString( | 274 std::string WindowOpenDispositionToString( |
| 248 WindowOpenDisposition window_open_disposition) { | 275 WindowOpenDisposition window_open_disposition) { |
| 249 switch (window_open_disposition) { | 276 switch (window_open_disposition) { |
| 250 case IGNORE_ACTION: | 277 case IGNORE_ACTION: |
| 251 return "ignore"; | 278 return "ignore"; |
| 252 case SAVE_TO_DISK: | 279 case SAVE_TO_DISK: |
| 253 return "save_to_disk"; | 280 return "save_to_disk"; |
| 254 case CURRENT_TAB: | 281 case CURRENT_TAB: |
| 255 return "current_tab"; | 282 return "current_tab"; |
| 256 case NEW_BACKGROUND_TAB: | 283 case NEW_BACKGROUND_TAB: |
| 257 return "new_background_tab"; | 284 return "new_background_tab"; |
| 258 case NEW_FOREGROUND_TAB: | 285 case NEW_FOREGROUND_TAB: |
| 259 return "new_foreground_tab"; | 286 return "new_foreground_tab"; |
| 260 case NEW_WINDOW: | 287 case NEW_WINDOW: |
| 261 return "new_window"; | 288 return "new_window"; |
| 262 case NEW_POPUP: | 289 case NEW_POPUP: |
| 263 return "new_popup"; | 290 return "new_popup"; |
| 264 default: | 291 default: |
| 265 NOTREACHED() << "Unknown Window Open Disposition"; | 292 NOTREACHED() << "Unknown Window Open Disposition"; |
| 266 return "ignore"; | 293 return "ignore"; |
| 267 } | 294 } |
| 268 } | 295 } |
| 269 | 296 |
| 297 std::string JavaScriptMessageTypeToString(JavaScriptMessageType message_type) { |
| 298 switch (message_type) { |
| 299 case JAVASCRIPT_MESSAGE_TYPE_ALERT: |
| 300 return "alert"; |
| 301 case JAVASCRIPT_MESSAGE_TYPE_CONFIRM: |
| 302 return "confirm"; |
| 303 case JAVASCRIPT_MESSAGE_TYPE_PROMPT: |
| 304 return "prompt"; |
| 305 default: |
| 306 NOTREACHED() << "Unknown JavaScript Message Type."; |
| 307 return "unknown"; |
| 308 } |
| 309 } |
| 310 |
| 270 // Called on IO thread. | 311 // Called on IO thread. |
| 271 static std::string RetrieveDownloadURLFromRequestId( | 312 static std::string RetrieveDownloadURLFromRequestId( |
| 272 RenderViewHost* render_view_host, | 313 RenderViewHost* render_view_host, |
| 273 int url_request_id) { | 314 int url_request_id) { |
| 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 275 | 316 |
| 276 int render_process_id = render_view_host->GetProcess()->GetID(); | 317 int render_process_id = render_view_host->GetProcess()->GetID(); |
| 277 GlobalRequestID global_id(render_process_id, url_request_id); | 318 GlobalRequestID global_id(render_process_id, url_request_id); |
| 278 net::URLRequest* url_request = | 319 net::URLRequest* url_request = |
| 279 ResourceDispatcherHostImpl::Get()->GetURLRequest(global_id); | 320 ResourceDispatcherHostImpl::Get()->GetURLRequest(global_id); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 permission_request_id)); | 645 permission_request_id)); |
| 605 } | 646 } |
| 606 | 647 |
| 607 void BrowserPluginGuest::CloseContents(WebContents* source) { | 648 void BrowserPluginGuest::CloseContents(WebContents* source) { |
| 608 if (!delegate_) | 649 if (!delegate_) |
| 609 return; | 650 return; |
| 610 | 651 |
| 611 delegate_->Close(); | 652 delegate_->Close(); |
| 612 } | 653 } |
| 613 | 654 |
| 655 JavaScriptDialogManager* BrowserPluginGuest::GetJavaScriptDialogManager() { |
| 656 return this; |
| 657 } |
| 658 |
| 614 bool BrowserPluginGuest::HandleContextMenu(const ContextMenuParams& params) { | 659 bool BrowserPluginGuest::HandleContextMenu(const ContextMenuParams& params) { |
| 615 // TODO(fsamuel): We show the regular page context menu handler for now until | 660 // TODO(fsamuel): We show the regular page context menu handler for now until |
| 616 // we implement the Apps Context Menu API for Browser Plugin (see | 661 // we implement the Apps Context Menu API for Browser Plugin (see |
| 617 // http://crbug.com/140315). | 662 // http://crbug.com/140315). |
| 618 return false; // Will be handled by WebContentsViewGuest. | 663 return false; // Will be handled by WebContentsViewGuest. |
| 619 } | 664 } |
| 620 | 665 |
| 621 void BrowserPluginGuest::HandleKeyboardEvent( | 666 void BrowserPluginGuest::HandleKeyboardEvent( |
| 622 WebContents* source, | 667 WebContents* source, |
| 623 const NativeWebKeyboardEvent& event) { | 668 const NativeWebKeyboardEvent& event) { |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 guest_visible_ = visible; | 1382 guest_visible_ = visible; |
| 1338 if (embedder_visible_ && guest_visible_) | 1383 if (embedder_visible_ && guest_visible_) |
| 1339 GetWebContents()->WasShown(); | 1384 GetWebContents()->WasShown(); |
| 1340 else | 1385 else |
| 1341 GetWebContents()->WasHidden(); | 1386 GetWebContents()->WasHidden(); |
| 1342 } | 1387 } |
| 1343 | 1388 |
| 1344 void BrowserPluginGuest::OnRespondPermission( | 1389 void BrowserPluginGuest::OnRespondPermission( |
| 1345 int instance_id, | 1390 int instance_id, |
| 1346 int request_id, | 1391 int request_id, |
| 1347 bool should_allow) { | 1392 bool should_allow, |
| 1393 const std::string& user_input) { |
| 1348 RequestMap::iterator request_itr = permission_request_map_.find(request_id); | 1394 RequestMap::iterator request_itr = permission_request_map_.find(request_id); |
| 1349 if (request_itr == permission_request_map_.end()) { | 1395 if (request_itr == permission_request_map_.end()) { |
| 1350 LOG(INFO) << "Not a valid request ID."; | 1396 LOG(INFO) << "Not a valid request ID."; |
| 1351 return; | 1397 return; |
| 1352 } | 1398 } |
| 1353 BrowserPluginPermissionType permission_type = request_itr->second->GetType(); | 1399 BrowserPluginPermissionType permission_type = request_itr->second->GetType(); |
| 1354 request_itr->second->Respond(should_allow); | 1400 request_itr->second->Respond(should_allow, user_input); |
| 1355 | 1401 |
| 1356 // Geolocation requests have to hang around for a while, so we don't delete | 1402 // Geolocation requests have to hang around for a while, so we don't delete |
| 1357 // them here. | 1403 // them here. |
| 1358 if (permission_type != BrowserPluginPermissionTypeGeolocation) { | 1404 if (permission_type != BrowserPluginPermissionTypeGeolocation) { |
| 1359 delete request_itr->second; | 1405 delete request_itr->second; |
| 1360 permission_request_map_.erase(request_itr); | 1406 permission_request_map_.erase(request_itr); |
| 1361 } | 1407 } |
| 1362 } | 1408 } |
| 1363 | 1409 |
| 1364 void BrowserPluginGuest::OnSwapBuffersACK(int instance_id, | 1410 void BrowserPluginGuest::OnSwapBuffersACK(int instance_id, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 | 1518 |
| 1473 base::DictionaryValue request_info; | 1519 base::DictionaryValue request_info; |
| 1474 request_info.Set( | 1520 request_info.Set( |
| 1475 browser_plugin::kURL, | 1521 browser_plugin::kURL, |
| 1476 base::Value::CreateStringValue(request.security_origin.spec())); | 1522 base::Value::CreateStringValue(request.security_origin.spec())); |
| 1477 SendMessageToEmbedder(new BrowserPluginMsg_RequestPermission( | 1523 SendMessageToEmbedder(new BrowserPluginMsg_RequestPermission( |
| 1478 instance_id(), BrowserPluginPermissionTypeMedia, | 1524 instance_id(), BrowserPluginPermissionTypeMedia, |
| 1479 request_id, request_info)); | 1525 request_id, request_info)); |
| 1480 } | 1526 } |
| 1481 | 1527 |
| 1528 void BrowserPluginGuest::RunJavaScriptDialog( |
| 1529 WebContents* web_contents, |
| 1530 const GURL& origin_url, |
| 1531 const std::string& accept_lang, |
| 1532 JavaScriptMessageType javascript_message_type, |
| 1533 const string16& message_text, |
| 1534 const string16& default_prompt_text, |
| 1535 const DialogClosedCallback& callback, |
| 1536 bool* did_suppress_message) { |
| 1537 if (permission_request_map_.size() >= kNumMaxOutstandingPermissionRequests) { |
| 1538 // Cancel the dialog. |
| 1539 callback.Run(false, string16()); |
| 1540 return; |
| 1541 } |
| 1542 int request_id = next_permission_request_id_++; |
| 1543 permission_request_map_[request_id] = new JavaScriptDialogRequest(callback); |
| 1544 base::DictionaryValue request_info; |
| 1545 request_info.Set( |
| 1546 browser_plugin::kDefaultPromptText, |
| 1547 base::Value::CreateStringValue(UTF16ToUTF8(default_prompt_text))); |
| 1548 request_info.Set( |
| 1549 browser_plugin::kMessageText, |
| 1550 base::Value::CreateStringValue(UTF16ToUTF8(message_text))); |
| 1551 request_info.Set( |
| 1552 browser_plugin::kMessageType, |
| 1553 base::Value::CreateStringValue( |
| 1554 JavaScriptMessageTypeToString(javascript_message_type))); |
| 1555 request_info.Set( |
| 1556 browser_plugin::kURL, |
| 1557 base::Value::CreateStringValue(origin_url.spec())); |
| 1558 SendMessageToEmbedder(new BrowserPluginMsg_RequestPermission( |
| 1559 instance_id(), BrowserPluginPermissionTypeJavaScriptDialog, |
| 1560 request_id, request_info)); |
| 1561 } |
| 1562 |
| 1563 void BrowserPluginGuest::RunBeforeUnloadDialog( |
| 1564 WebContents* web_contents, |
| 1565 const string16& message_text, |
| 1566 bool is_reload, |
| 1567 const DialogClosedCallback& callback) { |
| 1568 // This is called if the guest has a beforeunload event handler. |
| 1569 // This callback allows navigation to proceed. |
| 1570 callback.Run(true, string16()); |
| 1571 } |
| 1572 |
| 1573 bool BrowserPluginGuest::HandleJavaScriptDialog( |
| 1574 WebContents* web_contents, |
| 1575 bool accept, |
| 1576 const string16* prompt_override) { |
| 1577 return false; |
| 1578 } |
| 1579 |
| 1580 void BrowserPluginGuest::ResetJavaScriptState(WebContents* web_contents) { |
| 1581 } |
| 1582 |
| 1482 void BrowserPluginGuest::OnUpdateRect( | 1583 void BrowserPluginGuest::OnUpdateRect( |
| 1483 const ViewHostMsg_UpdateRect_Params& params) { | 1584 const ViewHostMsg_UpdateRect_Params& params) { |
| 1484 BrowserPluginMsg_UpdateRect_Params relay_params; | 1585 BrowserPluginMsg_UpdateRect_Params relay_params; |
| 1485 relay_params.view_size = params.view_size; | 1586 relay_params.view_size = params.view_size; |
| 1486 relay_params.scale_factor = params.scale_factor; | 1587 relay_params.scale_factor = params.scale_factor; |
| 1487 relay_params.is_resize_ack = ViewHostMsg_UpdateRect_Flags::is_resize_ack( | 1588 relay_params.is_resize_ack = ViewHostMsg_UpdateRect_Flags::is_resize_ack( |
| 1488 params.flags); | 1589 params.flags); |
| 1489 relay_params.needs_ack = params.needs_ack; | 1590 relay_params.needs_ack = params.needs_ack; |
| 1490 | 1591 |
| 1491 // HW accelerated case, acknowledge resize only | 1592 // HW accelerated case, acknowledge resize only |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1531 | 1632 |
| 1532 SendMessageToEmbedder( | 1633 SendMessageToEmbedder( |
| 1533 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params)); | 1634 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params)); |
| 1534 } | 1635 } |
| 1535 | 1636 |
| 1536 void BrowserPluginGuest::DidRetrieveDownloadURLFromRequestId( | 1637 void BrowserPluginGuest::DidRetrieveDownloadURLFromRequestId( |
| 1537 const std::string& request_method, | 1638 const std::string& request_method, |
| 1538 int permission_request_id, | 1639 int permission_request_id, |
| 1539 const std::string& url) { | 1640 const std::string& url) { |
| 1540 if (url.empty()) { | 1641 if (url.empty()) { |
| 1541 OnRespondPermission(instance_id(), permission_request_id, false); | 1642 OnRespondPermission(instance_id(), permission_request_id, |
| 1643 false, std::string()); |
| 1542 return; | 1644 return; |
| 1543 } | 1645 } |
| 1544 | 1646 |
| 1545 base::DictionaryValue request_info; | 1647 base::DictionaryValue request_info; |
| 1546 request_info.Set(browser_plugin::kRequestMethod, | 1648 request_info.Set(browser_plugin::kRequestMethod, |
| 1547 base::Value::CreateStringValue(request_method)); | 1649 base::Value::CreateStringValue(request_method)); |
| 1548 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); | 1650 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); |
| 1549 | 1651 |
| 1550 SendMessageToEmbedder( | 1652 SendMessageToEmbedder( |
| 1551 new BrowserPluginMsg_RequestPermission(instance_id(), | 1653 new BrowserPluginMsg_RequestPermission(instance_id(), |
| 1552 BrowserPluginPermissionTypeDownload, permission_request_id, | 1654 BrowserPluginPermissionTypeDownload, permission_request_id, |
| 1553 request_info)); | 1655 request_info)); |
| 1554 } | 1656 } |
| 1555 | 1657 |
| 1556 } // namespace content | 1658 } // namespace content |
| OLD | NEW |