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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/geolocation/geolocation_permission_context_android.h" 5 #include "chrome/browser/geolocation/geolocation_permission_context_android.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/feature_list.h" 11 #include "base/feature_list.h"
12 #include "base/metrics/histogram_functions.h" 12 #include "base/metrics/histogram_functions.h"
13 #include "chrome/browser/android/location_settings.h" 13 #include "chrome/browser/android/location_settings.h"
14 #include "chrome/browser/android/location_settings_impl.h" 14 #include "chrome/browser/android/location_settings_impl.h"
15 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur e_tab_helper.h" 15 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur e_tab_helper.h"
16 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h " 16 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h "
17 #include "chrome/browser/android/tab_android.h"
17 #include "chrome/browser/permissions/permission_request_id.h" 18 #include "chrome/browser/permissions/permission_request_id.h"
18 #include "chrome/browser/permissions/permission_update_infobar_delegate_android. h" 19 #include "chrome/browser/permissions/permission_update_infobar_delegate_android. h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/search_engines/template_url_service_factory.h" 21 #include "chrome/browser/search_engines/template_url_service_factory.h"
21 #include "chrome/common/chrome_features.h" 22 #include "chrome/common/chrome_features.h"
22 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
23 #include "components/infobars/core/infobar.h" 24 #include "components/infobars/core/infobar.h"
24 #include "components/prefs/pref_registry_simple.h" 25 #include "components/prefs/pref_registry_simple.h"
25 #include "components/prefs/pref_service.h" 26 #include "components/prefs/pref_service.h"
26 #include "components/search_engines/template_url.h" 27 #include "components/search_engines/template_url.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return; 231 return;
231 } 232 }
232 233
233 LogLocationSettingsMetric(kLocationSettingsShowMetricBase, 234 LogLocationSettingsMetric(kLocationSettingsShowMetricBase,
234 is_default_search, 235 is_default_search,
235 LocationSettingsBackOffLevel(is_default_search)); 236 LocationSettingsBackOffLevel(is_default_search));
236 content::WebContents* web_contents = 237 content::WebContents* web_contents =
237 content::WebContents::FromRenderFrameHost( 238 content::WebContents::FromRenderFrameHost(
238 content::RenderFrameHost::FromID(id.render_process_id(), 239 content::RenderFrameHost::FromID(id.render_process_id(),
239 id.render_frame_id())); 240 id.render_frame_id()));
241
242 // Only show the location settings dialog if the tab for |web_contents| is
243 // user-interactable (i.e. is the current tab, and Chrome is active and not
244 // in tab-switching mode).
245 TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
246 if (tab && !tab->IsUserInteractable()) {
247 FinishNotifyPermissionSet(id, requesting_origin, embedding_origin,
248 callback, false /* persist */,
249 CONTENT_SETTING_BLOCK);
250 // This case should be very rare, so just pretend it was a denied prompt
251 // for metrics purposes.
252 LogLocationSettingsMetric(
253 kLocationSettingsDenyMetricBase, is_default_search,
254 LocationSettingsBackOffLevel(is_default_search));
255 return;
256 }
257
240 location_settings_->PromptToEnableSystemLocationSetting( 258 location_settings_->PromptToEnableSystemLocationSetting(
241 is_default_search ? SEARCH : DEFAULT, web_contents, 259 is_default_search ? SEARCH : DEFAULT, web_contents,
242 base::BindOnce( 260 base::BindOnce(
243 &GeolocationPermissionContextAndroid::OnLocationSettingsDialogShown, 261 &GeolocationPermissionContextAndroid::OnLocationSettingsDialogShown,
244 weak_factory_.GetWeakPtr(), id, requesting_origin, embedding_origin, 262 weak_factory_.GetWeakPtr(), id, requesting_origin, embedding_origin,
245 callback, persist, content_setting)); 263 callback, persist, content_setting));
246 return; 264 return;
247 } 265 }
248 266
249 FinishNotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 267 FinishNotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 // The tab helper can be null in tests. 503 // The tab helper can be null in tests.
486 if (disclosure_helper) 504 if (disclosure_helper)
487 disclosure_helper->MaybeShowDisclosure(requesting_origin); 505 disclosure_helper->MaybeShowDisclosure(requesting_origin);
488 } 506 }
489 } 507 }
490 508
491 void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting( 509 void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting(
492 std::unique_ptr<LocationSettings> settings) { 510 std::unique_ptr<LocationSettings> settings) {
493 location_settings_ = std::move(settings); 511 location_settings_ = std::move(settings);
494 } 512 }
OLDNEW
« 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