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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_plugin/browser_plugin_guest.cc
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index 3248afdfb54b856da8d5e4bdc2dd847938571b1b..30cbf6e2c8aab94013a429dc54b4f006f9414e04 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -539,14 +539,16 @@ void BrowserPluginGuest::AskEmbedderForGeolocationPermission(
int bridge_id,
const GURL& requesting_frame,
const GeolocationCallback& callback) {
- if (geolocation_request_callback_map_.size() >=
- kNumMaxOutstandingPermissionRequests) {
+ if (geolocation_request_map_.size() >= kNumMaxOutstandingPermissionRequests) {
// Deny the geolocation request.
callback.Run(false);
return;
}
int request_id = next_permission_request_id_++;
- geolocation_request_callback_map_[request_id] = callback;
+ geolocation_request_map_[request_id] = std::make_pair(callback, bridge_id);
+ DCHECK(bridge_id_to_request_id_map_.find(bridge_id) ==
+ bridge_id_to_request_id_map_.end());
+ bridge_id_to_request_id_map_[bridge_id] = request_id;
base::DictionaryValue request_info;
request_info.Set(browser_plugin::kURL,
@@ -558,19 +560,27 @@ void BrowserPluginGuest::AskEmbedderForGeolocationPermission(
}
void BrowserPluginGuest::CancelGeolocationRequest(int bridge_id) {
+ std::map<int, int>::iterator iter =
+ bridge_id_to_request_id_map_.find(bridge_id);
+ if (iter == bridge_id_to_request_id_map_.end())
+ return;
+
+ int request_id = iter->second;
GeolocationRequestsMap::iterator callback_iter =
- geolocation_request_callback_map_.find(bridge_id);
- if (callback_iter != geolocation_request_callback_map_.end())
- geolocation_request_callback_map_.erase(callback_iter);
+ geolocation_request_map_.find(request_id);
+ if (callback_iter != geolocation_request_map_.end())
+ geolocation_request_map_.erase(callback_iter);
}
void BrowserPluginGuest::SetGeolocationPermission(int request_id,
bool allowed) {
GeolocationRequestsMap::iterator callback_iter =
- geolocation_request_callback_map_.find(request_id);
- if (callback_iter != geolocation_request_callback_map_.end()) {
- callback_iter->second.Run(allowed);
- geolocation_request_callback_map_.erase(callback_iter);
+ geolocation_request_map_.find(request_id);
+ if (callback_iter != geolocation_request_map_.end()) {
+ GeolocationRequestItem& item = callback_iter->second;
+ item.first.Run(allowed);
+ bridge_id_to_request_id_map_.erase(item.second);
+ geolocation_request_map_.erase(callback_iter);
}
}
« 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