Chromium Code Reviews| 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.h" | 10 #include "base/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 protected: | 67 protected: |
| 67 PermissionRequest() { | 68 PermissionRequest() { |
| 68 RecordAction(UserMetricsAction("BrowserPlugin.Guest.PermissionRequest")); | 69 RecordAction(UserMetricsAction("BrowserPlugin.Guest.PermissionRequest")); |
| 69 } | 70 } |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 class BrowserPluginGuest::DownloadRequest : public PermissionRequest { | 73 class BrowserPluginGuest::DownloadRequest : public PermissionRequest { |
| 73 public: | 74 public: |
| 74 explicit DownloadRequest(base::Callback<void(bool)> callback) | 75 explicit DownloadRequest(base::Callback<void(bool)> callback) |
| 75 : callback_(callback) { | 76 : callback_(callback) { |
| 76 RecordAction( | 77 RecordAction( |
| 77 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Download")); | 78 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Download")); |
| 78 } | 79 } |
| 79 virtual void Respond(bool should_allow) OVERRIDE { | 80 virtual void Respond(bool should_allow, |
| 81 const std::string& user_input) OVERRIDE { | |
| 80 callback_.Run(should_allow); | 82 callback_.Run(should_allow); |
| 81 } | 83 } |
| 84 virtual BrowserPluginPermissionType GetType() const OVERRIDE { | |
| 85 return BrowserPluginPermissionTypeDownload; | |
| 86 } | |
| 82 virtual ~DownloadRequest() {} | 87 virtual ~DownloadRequest() {} |
| 83 private: | 88 private: |
| 84 base::Callback<void(bool)> callback_; | 89 base::Callback<void(bool)> callback_; |
| 85 }; | 90 }; |
| 86 | 91 |
| 87 class BrowserPluginGuest::GeolocationRequest : public PermissionRequest { | 92 class BrowserPluginGuest::GeolocationRequest : public PermissionRequest { |
| 88 public: | 93 public: |
| 89 GeolocationRequest(GeolocationCallback callback, | 94 GeolocationRequest(GeolocationCallback callback, |
| 90 int bridge_id, | 95 int bridge_id, |
| 91 BrowserPluginGuest* guest, | 96 BrowserPluginGuest* guest, |
| 92 base::WeakPtrFactory<BrowserPluginGuest>* weak_ptr_factory) | 97 base::WeakPtrFactory<BrowserPluginGuest>* weak_ptr_factory) |
| 93 : callback_(callback), | 98 : callback_(callback), |
| 94 bridge_id_(bridge_id), | 99 bridge_id_(bridge_id), |
| 95 guest_(guest), | 100 guest_(guest), |
| 96 weak_ptr_factory_(weak_ptr_factory) { | 101 weak_ptr_factory_(weak_ptr_factory) { |
| 97 RecordAction( | 102 RecordAction( |
| 98 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Geolocation")); | 103 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Geolocation")); |
| 99 } | 104 } |
| 100 | 105 |
| 101 virtual void Respond(bool should_allow) OVERRIDE { | 106 virtual void Respond(bool should_allow, |
| 107 const std::string& user_input) OVERRIDE { | |
| 102 WebContents* web_contents = guest_->embedder_web_contents(); | 108 WebContents* web_contents = guest_->embedder_web_contents(); |
| 103 if (should_allow && web_contents) { | 109 if (should_allow && web_contents) { |
| 104 // If renderer side embedder decides to allow gelocation, we need to check | 110 // If renderer side embedder decides to allow gelocation, we need to check |
| 105 // if the app/embedder itself has geolocation access. | 111 // if the app/embedder itself has geolocation access. |
| 106 BrowserContext* browser_context = web_contents->GetBrowserContext(); | 112 BrowserContext* browser_context = web_contents->GetBrowserContext(); |
| 107 if (browser_context) { | 113 if (browser_context) { |
| 108 GeolocationPermissionContext* geolocation_context = | 114 GeolocationPermissionContext* geolocation_context = |
| 109 browser_context->GetGeolocationPermissionContext(); | 115 browser_context->GetGeolocationPermissionContext(); |
| 110 if (geolocation_context) { | 116 if (geolocation_context) { |
| 111 base::Callback<void(bool)> geolocation_callback = base::Bind( | 117 base::Callback<void(bool)> geolocation_callback = base::Bind( |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 122 // permission. Therefore we use an invalid |bridge_id|. | 128 // permission. Therefore we use an invalid |bridge_id|. |
| 123 -1 /* bridge_id */, | 129 -1 /* bridge_id */, |
| 124 web_contents->GetURL(), | 130 web_contents->GetURL(), |
| 125 geolocation_callback); | 131 geolocation_callback); |
| 126 return; | 132 return; |
| 127 } | 133 } |
| 128 } | 134 } |
| 129 } | 135 } |
| 130 guest_->SetGeolocationPermission(callback_, bridge_id_, false); | 136 guest_->SetGeolocationPermission(callback_, bridge_id_, false); |
| 131 } | 137 } |
| 138 virtual BrowserPluginPermissionType GetType() const OVERRIDE { | |
| 139 return BrowserPluginPermissionTypeGeolocation; | |
| 140 } | |
| 132 virtual ~GeolocationRequest() {} | 141 virtual ~GeolocationRequest() {} |
| 133 private: | 142 private: |
| 134 base::Callback<void(bool)> callback_; | 143 base::Callback<void(bool)> callback_; |
| 135 int bridge_id_; | 144 int bridge_id_; |
| 136 BrowserPluginGuest* guest_; | 145 BrowserPluginGuest* guest_; |
| 137 base::WeakPtrFactory<BrowserPluginGuest>* weak_ptr_factory_; | 146 base::WeakPtrFactory<BrowserPluginGuest>* weak_ptr_factory_; |
| 138 }; | 147 }; |
| 139 | 148 |
| 140 class BrowserPluginGuest::MediaRequest : public PermissionRequest { | 149 class BrowserPluginGuest::MediaRequest : public PermissionRequest { |
| 141 public: | 150 public: |
| 142 MediaRequest(const MediaStreamRequest& request, | 151 MediaRequest(const MediaStreamRequest& request, |
| 143 const MediaResponseCallback& callback, | 152 const MediaResponseCallback& callback, |
| 144 BrowserPluginGuest* guest) | 153 BrowserPluginGuest* guest) |
| 145 : request_(request), | 154 : request_(request), |
| 146 callback_(callback), | 155 callback_(callback), |
| 147 guest_(guest) { | 156 guest_(guest) { |
| 148 RecordAction( | 157 RecordAction( |
| 149 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Media")); | 158 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Media")); |
| 150 } | 159 } |
| 151 | 160 |
| 152 virtual void Respond(bool should_allow) OVERRIDE { | 161 virtual void Respond(bool should_allow, |
| 162 const std::string& user_input) OVERRIDE { | |
| 153 WebContentsImpl* web_contents = guest_->embedder_web_contents(); | 163 WebContentsImpl* web_contents = guest_->embedder_web_contents(); |
| 154 if (should_allow && web_contents) { | 164 if (should_allow && web_contents) { |
| 155 // Re-route the request to the embedder's WebContents; the guest gets the | 165 // Re-route the request to the embedder's WebContents; the guest gets the |
| 156 // permission this way. | 166 // permission this way. |
| 157 web_contents->RequestMediaAccessPermission(request_, callback_); | 167 web_contents->RequestMediaAccessPermission(request_, callback_); |
| 158 } else { | 168 } else { |
| 159 // Deny the request. | 169 // Deny the request. |
| 160 callback_.Run(MediaStreamDevices(), scoped_ptr<MediaStreamUI>()); | 170 callback_.Run(MediaStreamDevices(), scoped_ptr<MediaStreamUI>()); |
| 161 } | 171 } |
| 162 | 172 } |
| 173 virtual BrowserPluginPermissionType GetType() const OVERRIDE { | |
| 174 return BrowserPluginPermissionTypeMedia; | |
| 163 } | 175 } |
| 164 virtual ~MediaRequest() {} | 176 virtual ~MediaRequest() {} |
| 165 private: | 177 private: |
| 166 MediaStreamRequest request_; | 178 MediaStreamRequest request_; |
| 167 MediaResponseCallback callback_; | 179 MediaResponseCallback callback_; |
| 168 BrowserPluginGuest* guest_; | 180 BrowserPluginGuest* guest_; |
| 169 }; | 181 }; |
| 170 | 182 |
| 171 class BrowserPluginGuest::NewWindowRequest : public PermissionRequest { | 183 class BrowserPluginGuest::NewWindowRequest : public PermissionRequest { |
| 172 public: | 184 public: |
| 173 NewWindowRequest(int instance_id, BrowserPluginGuest* guest) | 185 NewWindowRequest(int instance_id, BrowserPluginGuest* guest) |
| 174 : instance_id_(instance_id), | 186 : instance_id_(instance_id), |
| 175 guest_(guest) { | 187 guest_(guest) { |
| 176 RecordAction( | 188 RecordAction( |
| 177 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.NewWindow")); | 189 UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.NewWindow")); |
| 178 } | 190 } |
| 179 | 191 |
| 180 virtual void Respond(bool should_allow) OVERRIDE { | 192 virtual void Respond(bool should_allow, |
| 193 const std::string& user_input) OVERRIDE { | |
| 181 int embedder_render_process_id = | 194 int embedder_render_process_id = |
| 182 guest_->embedder_web_contents()->GetRenderProcessHost()->GetID(); | 195 guest_->embedder_web_contents()->GetRenderProcessHost()->GetID(); |
| 183 BrowserPluginGuest* guest = | 196 BrowserPluginGuest* guest = |
| 184 guest_->GetWebContents()->GetBrowserPluginGuestManager()-> | 197 guest_->GetWebContents()->GetBrowserPluginGuestManager()-> |
| 185 GetGuestByInstanceID(instance_id_, embedder_render_process_id); | 198 GetGuestByInstanceID(instance_id_, embedder_render_process_id); |
| 186 if (!guest) { | 199 if (!guest) { |
| 187 LOG(INFO) << "Guest not found. Instance ID: " << instance_id_; | 200 LOG(INFO) << "Guest not found. Instance ID: " << instance_id_; |
| 188 return; | 201 return; |
| 189 } | 202 } |
| 190 | 203 |
| 191 // If we do not destroy the guest then we allow the new window. | 204 // If we do not destroy the guest then we allow the new window. |
| 192 if (!should_allow) | 205 if (!should_allow) |
| 193 guest->Destroy(); | 206 guest->Destroy(); |
| 194 } | 207 } |
| 208 virtual BrowserPluginPermissionType GetType() const OVERRIDE { | |
| 209 return BrowserPluginPermissionTypeNewWindow; | |
| 210 } | |
| 195 virtual ~NewWindowRequest() {} | 211 virtual ~NewWindowRequest() {} |
| 196 private: | 212 private: |
| 197 int instance_id_; | 213 int instance_id_; |
| 198 BrowserPluginGuest* guest_; | 214 BrowserPluginGuest* guest_; |
| 199 }; | 215 }; |
| 200 | 216 |
| 217 class BrowserPluginGuest::JavaScriptDialogRequest : public PermissionRequest { | |
| 218 public: | |
| 219 JavaScriptDialogRequest(const DialogClosedCallback& callback, | |
| 220 BrowserPluginGuest* guest) | |
| 221 : callback_(callback), | |
| 222 guest_(guest) { | |
| 223 RecordAction( | |
| 224 UserMetricsAction( | |
| 225 "BrowserPlugin.Guest.PermissionRequest.JavaScriptDialog")); | |
| 226 } | |
| 227 | |
| 228 virtual void Respond(bool should_allow, | |
| 229 const std::string& user_input) OVERRIDE { | |
| 230 if (!guest_) | |
|
lazyboy
2013/07/19 21:43:16
How could this turn to null?
Fady Samuel
2013/07/23 15:41:10
Hmm, with the cleanup I recently added for pointer
Fady Samuel
2013/07/23 15:41:10
Hmm, it can't removed.
| |
| 231 return; | |
| 232 callback_.Run(should_allow, UTF8ToUTF16(user_input)); | |
| 233 } | |
| 234 virtual BrowserPluginPermissionType GetType() const OVERRIDE { | |
| 235 return BrowserPluginPermissionTypeJavaScriptDialog; | |
| 236 } | |
| 237 | |
| 238 virtual ~JavaScriptDialogRequest() {} | |
| 239 private: | |
| 240 DialogClosedCallback callback_; | |
| 241 BrowserPluginGuest* guest_; | |
|
lazyboy
2013/07/19 21:43:16
A raw pointer is probably not ok here.
Also what
Fady Samuel
2013/07/23 15:41:10
Removed pointer. This request goes away when Brows
| |
| 242 }; | |
| 243 | |
| 201 namespace { | 244 namespace { |
| 202 const size_t kNumMaxOutstandingPermissionRequests = 1024; | 245 const size_t kNumMaxOutstandingPermissionRequests = 1024; |
| 203 | 246 |
| 204 static std::string WindowOpenDispositionToString( | 247 static std::string WindowOpenDispositionToString( |
| 205 WindowOpenDisposition window_open_disposition) { | 248 WindowOpenDisposition window_open_disposition) { |
| 206 switch (window_open_disposition) { | 249 switch (window_open_disposition) { |
| 207 case IGNORE_ACTION: | 250 case IGNORE_ACTION: |
| 208 return "ignore"; | 251 return "ignore"; |
| 209 case SAVE_TO_DISK: | 252 case SAVE_TO_DISK: |
| 210 return "save_to_disk"; | 253 return "save_to_disk"; |
| 211 case CURRENT_TAB: | 254 case CURRENT_TAB: |
| 212 return "current_tab"; | 255 return "current_tab"; |
| 213 case NEW_BACKGROUND_TAB: | 256 case NEW_BACKGROUND_TAB: |
| 214 return "new_background_tab"; | 257 return "new_background_tab"; |
| 215 case NEW_FOREGROUND_TAB: | 258 case NEW_FOREGROUND_TAB: |
| 216 return "new_foreground_tab"; | 259 return "new_foreground_tab"; |
| 217 case NEW_WINDOW: | 260 case NEW_WINDOW: |
| 218 return "new_window"; | 261 return "new_window"; |
| 219 case NEW_POPUP: | 262 case NEW_POPUP: |
| 220 return "new_popup"; | 263 return "new_popup"; |
| 221 default: | 264 default: |
| 222 NOTREACHED() << "Unknown Window Open Disposition"; | 265 NOTREACHED() << "Unknown Window Open Disposition"; |
| 223 return "ignore"; | 266 return "ignore"; |
| 224 } | 267 } |
| 225 } | 268 } |
| 226 | 269 |
| 270 static std::string JavaScriptMessageTypeToString( | |
| 271 JavaScriptMessageType message_type) { | |
| 272 switch (message_type) { | |
| 273 case JAVASCRIPT_MESSAGE_TYPE_ALERT: | |
| 274 return "alert"; | |
| 275 case JAVASCRIPT_MESSAGE_TYPE_CONFIRM: | |
| 276 return "confirm"; | |
| 277 case JAVASCRIPT_MESSAGE_TYPE_PROMPT: | |
| 278 return "prompt"; | |
| 279 default: | |
| 280 NOTREACHED() << "Unknown JavaScript Message Type."; | |
| 281 return "unknown"; | |
| 282 } | |
| 283 } | |
| 284 | |
| 227 // Called on IO thread. | 285 // Called on IO thread. |
| 228 static std::string RetrieveDownloadURLFromRequestId( | 286 static std::string RetrieveDownloadURLFromRequestId( |
| 229 RenderViewHost* render_view_host, | 287 RenderViewHost* render_view_host, |
| 230 int url_request_id) { | 288 int url_request_id) { |
| 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 232 | 290 |
| 233 int render_process_id = render_view_host->GetProcess()->GetID(); | 291 int render_process_id = render_view_host->GetProcess()->GetID(); |
| 234 GlobalRequestID global_id(render_process_id, url_request_id); | 292 GlobalRequestID global_id(render_process_id, url_request_id); |
| 235 net::URLRequest* url_request = | 293 net::URLRequest* url_request = |
| 236 ResourceDispatcherHostImpl::Get()->GetURLRequest(global_id); | 294 ResourceDispatcherHostImpl::Get()->GetURLRequest(global_id); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 permission_request_id)); | 614 permission_request_id)); |
| 557 } | 615 } |
| 558 | 616 |
| 559 void BrowserPluginGuest::CloseContents(WebContents* source) { | 617 void BrowserPluginGuest::CloseContents(WebContents* source) { |
| 560 if (!delegate_) | 618 if (!delegate_) |
| 561 return; | 619 return; |
| 562 | 620 |
| 563 delegate_->Close(); | 621 delegate_->Close(); |
| 564 } | 622 } |
| 565 | 623 |
| 624 JavaScriptDialogManager* BrowserPluginGuest::GetJavaScriptDialogManager() { | |
| 625 return this; | |
| 626 } | |
| 627 | |
| 566 bool BrowserPluginGuest::HandleContextMenu(const ContextMenuParams& params) { | 628 bool BrowserPluginGuest::HandleContextMenu(const ContextMenuParams& params) { |
| 567 // TODO(fsamuel): We show the regular page context menu handler for now until | 629 // TODO(fsamuel): We show the regular page context menu handler for now until |
| 568 // we implement the Apps Context Menu API for Browser Plugin (see | 630 // we implement the Apps Context Menu API for Browser Plugin (see |
| 569 // http://crbug.com/140315). | 631 // http://crbug.com/140315). |
| 570 return false; // Will be handled by WebContentsViewGuest. | 632 return false; // Will be handled by WebContentsViewGuest. |
| 571 } | 633 } |
| 572 | 634 |
| 573 void BrowserPluginGuest::HandleKeyboardEvent( | 635 void BrowserPluginGuest::HandleKeyboardEvent( |
| 574 WebContents* source, | 636 WebContents* source, |
| 575 const NativeWebKeyboardEvent& event) { | 637 const NativeWebKeyboardEvent& event) { |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1283 void BrowserPluginGuest::OnSetVisibility(int instance_id, bool visible) { | 1345 void BrowserPluginGuest::OnSetVisibility(int instance_id, bool visible) { |
| 1284 guest_visible_ = visible; | 1346 guest_visible_ = visible; |
| 1285 if (embedder_visible_ && guest_visible_) | 1347 if (embedder_visible_ && guest_visible_) |
| 1286 GetWebContents()->WasShown(); | 1348 GetWebContents()->WasShown(); |
| 1287 else | 1349 else |
| 1288 GetWebContents()->WasHidden(); | 1350 GetWebContents()->WasHidden(); |
| 1289 } | 1351 } |
| 1290 | 1352 |
| 1291 void BrowserPluginGuest::OnRespondPermission( | 1353 void BrowserPluginGuest::OnRespondPermission( |
| 1292 int instance_id, | 1354 int instance_id, |
| 1293 BrowserPluginPermissionType permission_type, | |
| 1294 int request_id, | 1355 int request_id, |
| 1295 bool should_allow) { | 1356 bool should_allow, |
| 1357 const std::string& user_input) { | |
| 1296 RequestMap::iterator request_itr = permission_request_map_.find(request_id); | 1358 RequestMap::iterator request_itr = permission_request_map_.find(request_id); |
| 1297 if (request_itr == permission_request_map_.end()) { | 1359 if (request_itr == permission_request_map_.end()) { |
| 1298 LOG(INFO) << "Not a valid request ID."; | 1360 LOG(INFO) << "Not a valid request ID."; |
| 1299 return; | 1361 return; |
| 1300 } | 1362 } |
| 1301 request_itr->second->Respond(should_allow); | 1363 BrowserPluginPermissionType permission_type = request_itr->second->GetType(); |
| 1364 request_itr->second->Respond(should_allow, user_input); | |
| 1302 | 1365 |
| 1303 // Geolocation requests have to hang around for a while, so we don't delete | 1366 // Geolocation requests have to hang around for a while, so we don't delete |
| 1304 // them here. | 1367 // them here. |
| 1305 if (permission_type != BrowserPluginPermissionTypeGeolocation) { | 1368 if (permission_type != BrowserPluginPermissionTypeGeolocation) { |
| 1306 delete request_itr->second; | 1369 delete request_itr->second; |
| 1307 permission_request_map_.erase(request_itr); | 1370 permission_request_map_.erase(request_itr); |
| 1308 } | 1371 } |
| 1309 } | 1372 } |
| 1310 | 1373 |
| 1311 void BrowserPluginGuest::OnSwapBuffersACK(int instance_id, | 1374 void BrowserPluginGuest::OnSwapBuffersACK(int instance_id, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1418 | 1481 |
| 1419 base::DictionaryValue request_info; | 1482 base::DictionaryValue request_info; |
| 1420 request_info.Set( | 1483 request_info.Set( |
| 1421 browser_plugin::kURL, | 1484 browser_plugin::kURL, |
| 1422 base::Value::CreateStringValue(request.security_origin.spec())); | 1485 base::Value::CreateStringValue(request.security_origin.spec())); |
| 1423 SendMessageToEmbedder(new BrowserPluginMsg_RequestPermission( | 1486 SendMessageToEmbedder(new BrowserPluginMsg_RequestPermission( |
| 1424 instance_id(), BrowserPluginPermissionTypeMedia, | 1487 instance_id(), BrowserPluginPermissionTypeMedia, |
| 1425 request_id, request_info)); | 1488 request_id, request_info)); |
| 1426 } | 1489 } |
| 1427 | 1490 |
| 1491 void BrowserPluginGuest::RunJavaScriptDialog( | |
| 1492 WebContents* web_contents, | |
| 1493 const GURL& origin_url, | |
| 1494 const std::string& accept_lang, | |
| 1495 JavaScriptMessageType javascript_message_type, | |
| 1496 const string16& message_text, | |
| 1497 const string16& default_prompt_text, | |
| 1498 const DialogClosedCallback& callback, | |
| 1499 bool* did_suppress_message) { | |
| 1500 if (permission_request_map_.size() >= kNumMaxOutstandingPermissionRequests) { | |
| 1501 // Cancel the dialog. | |
| 1502 callback.Run(false, string16()); | |
| 1503 return; | |
| 1504 } | |
| 1505 int request_id = next_permission_request_id_++; | |
| 1506 permission_request_map_[request_id] = | |
| 1507 new JavaScriptDialogRequest(callback, this); | |
| 1508 base::DictionaryValue request_info; | |
| 1509 request_info.Set( | |
| 1510 browser_plugin::kDefaultPromptText, | |
| 1511 base::Value::CreateStringValue(UTF16ToUTF8(default_prompt_text))); | |
| 1512 request_info.Set( | |
| 1513 browser_plugin::kMessageText, | |
| 1514 base::Value::CreateStringValue(UTF16ToUTF8(message_text))); | |
| 1515 request_info.Set( | |
| 1516 browser_plugin::kMessageType, | |
| 1517 base::Value::CreateStringValue( | |
| 1518 JavaScriptMessageTypeToString(javascript_message_type))); | |
| 1519 request_info.Set( | |
| 1520 browser_plugin::kURL, | |
| 1521 base::Value::CreateStringValue(origin_url.spec())); | |
| 1522 SendMessageToEmbedder(new BrowserPluginMsg_RequestPermission( | |
| 1523 instance_id(), BrowserPluginPermissionTypeJavaScriptDialog, | |
| 1524 request_id, request_info)); | |
| 1525 } | |
| 1526 | |
| 1527 void BrowserPluginGuest::RunBeforeUnloadDialog( | |
| 1528 WebContents* web_contents, | |
| 1529 const string16& message_text, | |
| 1530 bool is_reload, | |
| 1531 const DialogClosedCallback& callback) { | |
| 1532 callback.Run(true, string16()); | |
|
lazyboy
2013/07/19 21:43:16
What does this do? Can you add a comment.
| |
| 1533 } | |
| 1534 | |
| 1535 bool BrowserPluginGuest::HandleJavaScriptDialog( | |
| 1536 WebContents* web_contents, | |
|
lazyboy
2013/07/19 21:43:16
nit: can fit in previous line.
Fady Samuel
2013/07/23 15:41:10
The third line cannot.
| |
| 1537 bool accept, | |
| 1538 const string16* prompt_override) { | |
| 1539 return false; | |
| 1540 } | |
| 1541 | |
| 1542 void BrowserPluginGuest::ResetJavaScriptState( | |
| 1543 WebContents* web_contents) { | |
|
lazyboy
2013/07/19 21:43:16
nit: can fit in previous line.
Fady Samuel
2013/07/23 15:41:10
Done.
| |
| 1544 } | |
| 1545 | |
| 1428 void BrowserPluginGuest::OnUpdateRect( | 1546 void BrowserPluginGuest::OnUpdateRect( |
| 1429 const ViewHostMsg_UpdateRect_Params& params) { | 1547 const ViewHostMsg_UpdateRect_Params& params) { |
| 1430 | 1548 |
| 1431 BrowserPluginMsg_UpdateRect_Params relay_params; | 1549 BrowserPluginMsg_UpdateRect_Params relay_params; |
| 1432 relay_params.view_size = params.view_size; | 1550 relay_params.view_size = params.view_size; |
| 1433 relay_params.scale_factor = params.scale_factor; | 1551 relay_params.scale_factor = params.scale_factor; |
| 1434 relay_params.is_resize_ack = ViewHostMsg_UpdateRect_Flags::is_resize_ack( | 1552 relay_params.is_resize_ack = ViewHostMsg_UpdateRect_Flags::is_resize_ack( |
| 1435 params.flags); | 1553 params.flags); |
| 1436 relay_params.needs_ack = params.needs_ack; | 1554 relay_params.needs_ack = params.needs_ack; |
| 1437 | 1555 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1478 | 1596 |
| 1479 SendMessageToEmbedder( | 1597 SendMessageToEmbedder( |
| 1480 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params)); | 1598 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params)); |
| 1481 } | 1599 } |
| 1482 | 1600 |
| 1483 void BrowserPluginGuest::DidRetrieveDownloadURLFromRequestId( | 1601 void BrowserPluginGuest::DidRetrieveDownloadURLFromRequestId( |
| 1484 const std::string& request_method, | 1602 const std::string& request_method, |
| 1485 int permission_request_id, | 1603 int permission_request_id, |
| 1486 const std::string& url) { | 1604 const std::string& url) { |
| 1487 if (url.empty()) { | 1605 if (url.empty()) { |
| 1488 OnRespondPermission(instance_id(), BrowserPluginPermissionTypeDownload, | 1606 OnRespondPermission(instance_id(), permission_request_id, |
| 1489 permission_request_id, false); | 1607 false, std::string()); |
| 1490 return; | 1608 return; |
| 1491 } | 1609 } |
| 1492 | 1610 |
| 1493 base::DictionaryValue request_info; | 1611 base::DictionaryValue request_info; |
| 1494 request_info.Set(browser_plugin::kRequestMethod, | 1612 request_info.Set(browser_plugin::kRequestMethod, |
| 1495 base::Value::CreateStringValue(request_method)); | 1613 base::Value::CreateStringValue(request_method)); |
| 1496 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); | 1614 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); |
| 1497 | 1615 |
| 1498 SendMessageToEmbedder( | 1616 SendMessageToEmbedder( |
| 1499 new BrowserPluginMsg_RequestPermission(instance_id(), | 1617 new BrowserPluginMsg_RequestPermission(instance_id(), |
| 1500 BrowserPluginPermissionTypeDownload, permission_request_id, | 1618 BrowserPluginPermissionTypeDownload, permission_request_id, |
| 1501 request_info)); | 1619 request_info)); |
| 1502 } | 1620 } |
| 1503 | 1621 |
| 1504 } // namespace content | 1622 } // namespace content |
| OLD | NEW |