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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 13712002: Fix Guest geolocation API, we were using |bridge_id| and |request_id| interchangeably which is wron… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 9 #include "base/message_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 new BrowserPluginMsg_LoadRedirect(instance_id(), 532 new BrowserPluginMsg_LoadRedirect(instance_id(),
533 old_url, 533 old_url,
534 new_url, 534 new_url,
535 is_top_level)); 535 is_top_level));
536 } 536 }
537 537
538 void BrowserPluginGuest::AskEmbedderForGeolocationPermission( 538 void BrowserPluginGuest::AskEmbedderForGeolocationPermission(
539 int bridge_id, 539 int bridge_id,
540 const GURL& requesting_frame, 540 const GURL& requesting_frame,
541 const GeolocationCallback& callback) { 541 const GeolocationCallback& callback) {
542 if (geolocation_request_callback_map_.size() >= 542 if (geolocation_request_map_.size() >= kNumMaxOutstandingPermissionRequests) {
543 kNumMaxOutstandingPermissionRequests) {
544 // Deny the geolocation request. 543 // Deny the geolocation request.
545 callback.Run(false); 544 callback.Run(false);
546 return; 545 return;
547 } 546 }
548 int request_id = next_permission_request_id_++; 547 int request_id = next_permission_request_id_++;
549 geolocation_request_callback_map_[request_id] = callback; 548 geolocation_request_map_[request_id] = std::make_pair(callback, bridge_id);
549 DCHECK(bridge_id_to_request_id_map_.find(bridge_id) ==
550 bridge_id_to_request_id_map_.end());
551 bridge_id_to_request_id_map_[bridge_id] = request_id;
550 552
551 base::DictionaryValue request_info; 553 base::DictionaryValue request_info;
552 request_info.Set(browser_plugin::kURL, 554 request_info.Set(browser_plugin::kURL,
553 base::Value::CreateStringValue(requesting_frame.spec())); 555 base::Value::CreateStringValue(requesting_frame.spec()));
554 556
555 SendMessageToEmbedder( 557 SendMessageToEmbedder(
556 new BrowserPluginMsg_RequestPermission(instance_id(), 558 new BrowserPluginMsg_RequestPermission(instance_id(),
557 BrowserPluginPermissionTypeGeolocation, request_id, request_info)); 559 BrowserPluginPermissionTypeGeolocation, request_id, request_info));
558 } 560 }
559 561
560 void BrowserPluginGuest::CancelGeolocationRequest(int bridge_id) { 562 void BrowserPluginGuest::CancelGeolocationRequest(int bridge_id) {
563 std::map<int, int>::iterator iter =
564 bridge_id_to_request_id_map_.find(bridge_id);
565 if (iter == bridge_id_to_request_id_map_.end())
566 return;
567
568 int request_id = iter->second;
561 GeolocationRequestsMap::iterator callback_iter = 569 GeolocationRequestsMap::iterator callback_iter =
562 geolocation_request_callback_map_.find(bridge_id); 570 geolocation_request_map_.find(request_id);
563 if (callback_iter != geolocation_request_callback_map_.end()) 571 if (callback_iter != geolocation_request_map_.end())
564 geolocation_request_callback_map_.erase(callback_iter); 572 geolocation_request_map_.erase(callback_iter);
565 } 573 }
566 574
567 void BrowserPluginGuest::SetGeolocationPermission(int request_id, 575 void BrowserPluginGuest::SetGeolocationPermission(int request_id,
568 bool allowed) { 576 bool allowed) {
569 GeolocationRequestsMap::iterator callback_iter = 577 GeolocationRequestsMap::iterator callback_iter =
570 geolocation_request_callback_map_.find(request_id); 578 geolocation_request_map_.find(request_id);
571 if (callback_iter != geolocation_request_callback_map_.end()) { 579 if (callback_iter != geolocation_request_map_.end()) {
572 callback_iter->second.Run(allowed); 580 GeolocationRequestItem& item = callback_iter->second;
573 geolocation_request_callback_map_.erase(callback_iter); 581 item.first.Run(allowed);
582 bridge_id_to_request_id_map_.erase(item.second);
583 geolocation_request_map_.erase(callback_iter);
574 } 584 }
575 } 585 }
576 586
577 void BrowserPluginGuest::DidCommitProvisionalLoadForFrame( 587 void BrowserPluginGuest::DidCommitProvisionalLoadForFrame(
578 int64 frame_id, 588 int64 frame_id,
579 bool is_main_frame, 589 bool is_main_frame,
580 const GURL& url, 590 const GURL& url,
581 PageTransition transition_type, 591 PageTransition transition_type,
582 RenderViewHost* render_view_host) { 592 RenderViewHost* render_view_host) {
583 // Inform its embedder of the updated URL. 593 // Inform its embedder of the updated URL.
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 base::Value::CreateStringValue(request_method)); 1314 base::Value::CreateStringValue(request_method));
1305 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); 1315 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url));
1306 1316
1307 SendMessageToEmbedder( 1317 SendMessageToEmbedder(
1308 new BrowserPluginMsg_RequestPermission(instance_id(), 1318 new BrowserPluginMsg_RequestPermission(instance_id(),
1309 BrowserPluginPermissionTypeDownload, permission_request_id, 1319 BrowserPluginPermissionTypeDownload, permission_request_id,
1310 request_info)); 1320 request_info));
1311 } 1321 }
1312 1322
1313 } // namespace content 1323 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698