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

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

Issue 2817873002: Don't show the Location Settings Dialog if the tab isn't interactable. (Closed)
Patch Set: Fix tests 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..83327847ab54881d1b2e23024224803978d93729 100644
--- a/chrome/browser/geolocation/geolocation_permission_context_android.cc
+++ b/chrome/browser/geolocation/geolocation_permission_context_android.cc
@@ -18,6 +18,8 @@
#include "chrome/browser/permissions/permission_update_infobar_delegate_android.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/ui/android/tab_model/tab_model.h"
+#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "components/infobars/core/infobar.h"
@@ -237,6 +239,22 @@ 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 current tab is for
+ // |web_contents|. Note, the TabModel will be null in unit tests.
+ TabModel* tab_model = TabModelList::GetTabModelForWebContents(web_contents);
+ if (tab_model && tab_model->GetActiveWebContents() != web_contents) {
Ted C 2017/04/13 15:47:08 I wonder if this should be !tab_model || Though t
benwells 2017/04/14 00:13:53 It was like this originally, but it broke some tes
+ 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