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

Unified Diff: chrome/browser/geolocation/geolocation_permission_context_android.cc

Issue 2835923002: Don't show the Location Settings Dialog if the tab isn't interactable. (Closed)
Patch Set: Created 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/geolocation/geolocation_permission_context_android.cc
diff --git a/chrome/browser/geolocation/geolocation_permission_context_android.cc b/chrome/browser/geolocation/geolocation_permission_context_android.cc
index 64e49f69665988aa3c540524e798a2b2f55d2377..b2438226154fc1f22dbc481fe882f151016a4dba 100644
--- a/chrome/browser/geolocation/geolocation_permission_context_android.cc
+++ b/chrome/browser/geolocation/geolocation_permission_context_android.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/android/location_settings_impl.h"
#include "chrome/browser/android/search_geolocation/search_geolocation_disclosure_tab_helper.h"
#include "chrome/browser/android/search_geolocation/search_geolocation_service.h"
+#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/permissions/permission_request_id.h"
#include "chrome/browser/permissions/permission_update_infobar_delegate_android.h"
#include "chrome/browser/profiles/profile.h"
@@ -237,6 +238,23 @@ void GeolocationPermissionContextAndroid::NotifyPermissionSet(
content::WebContents::FromRenderFrameHost(
content::RenderFrameHost::FromID(id.render_process_id(),
id.render_frame_id()));
+
+ // Only show the location settings dialog if the tab for |web_contents| is
+ // user-interactable (i.e. is the current tab, and Chrome is active and not
+ // in tab-switching mode).
+ TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
+ if (tab && !tab->IsUserInteractable()) {
+ FinishNotifyPermissionSet(id, requesting_origin, embedding_origin,
+ callback, false /* persist */,
+ CONTENT_SETTING_BLOCK);
+ // This case should be very rare, so just pretend it was a denied prompt
+ // for metrics purposes.
+ LogLocationSettingsMetric(
+ kLocationSettingsDenyMetricBase, is_default_search,
+ LocationSettingsBackOffLevel(is_default_search));
+ return;
+ }
+
location_settings_->PromptToEnableSystemLocationSetting(
is_default_search ? SEARCH : DEFAULT, web_contents,
base::BindOnce(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698