| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_ANDROID_SEARCH_GEOLOCATION_DISCLOSURE_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_SEARCH_GEOLOCATION_DISCLOSURE_TAB_HELPER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_SEARCH_GEOLOCATION_DISCLOSURE_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_ANDROID_SEARCH_GEOLOCATION_DISCLOSURE_TAB_HELPER_H_ |
| 7 | 7 |
| 8 #include <jni.h> | |
| 9 | |
| 10 #include "base/macros.h" | 8 #include "base/macros.h" |
| 11 #include "content/public/browser/web_contents_observer.h" | 9 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "content/public/browser/web_contents_user_data.h" | 10 #include "content/public/browser/web_contents_user_data.h" |
| 13 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 14 | 12 |
| 15 class Profile; | 13 class Profile; |
| 16 | 14 |
| 17 namespace user_prefs { | 15 namespace user_prefs { |
| 18 class PrefRegistrySyncable; | 16 class PrefRegistrySyncable; |
| 19 } | 17 } |
| 20 | 18 |
| 21 // Tab helper to show the search geolocation disclosure. | 19 // Tab helper to show the search geolocation disclosure. |
| 22 class SearchGeolocationDisclosureTabHelper | 20 class SearchGeolocationDisclosureTabHelper |
| 23 : public content::WebContentsObserver, | 21 : public content::WebContentsObserver, |
| 24 public content::WebContentsUserData< | 22 public content::WebContentsUserData< |
| 25 SearchGeolocationDisclosureTabHelper> { | 23 SearchGeolocationDisclosureTabHelper> { |
| 26 public: | 24 public: |
| 27 ~SearchGeolocationDisclosureTabHelper() override; | 25 ~SearchGeolocationDisclosureTabHelper() override; |
| 28 | 26 |
| 29 // content::WebContentsObserver overrides. | 27 // content::WebContentsObserver overrides. |
| 30 void NavigationEntryCommitted( | 28 void NavigationEntryCommitted( |
| 31 const content::LoadCommittedDetails& load_details) override; | 29 const content::LoadCommittedDetails& load_details) override; |
| 32 | 30 |
| 33 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 31 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 34 | 32 |
| 35 // Registers native methods. | |
| 36 static bool Register(JNIEnv* env); | |
| 37 | |
| 38 private: | 33 private: |
| 39 explicit SearchGeolocationDisclosureTabHelper(content::WebContents* contents); | 34 explicit SearchGeolocationDisclosureTabHelper(content::WebContents* contents); |
| 40 friend class content::WebContentsUserData< | 35 friend class content::WebContentsUserData< |
| 41 SearchGeolocationDisclosureTabHelper>; | 36 SearchGeolocationDisclosureTabHelper>; |
| 42 | 37 |
| 43 void MaybeShowDefaultSearchGeolocationDisclosure(const GURL& gurl); | 38 void MaybeShowDefaultSearchGeolocationDisclosure(const GURL& gurl); |
| 44 | 39 |
| 45 bool ShouldShowDisclosureForUrl(const GURL& gurl); | |
| 46 | |
| 47 // Record metrics, once per client, of the permission state before and after | 40 // Record metrics, once per client, of the permission state before and after |
| 48 // the disclosure has been shown. | 41 // the disclosure has been shown. |
| 49 void RecordPreDisclosureMetrics(const GURL& gurl); | 42 void RecordPreDisclosureMetrics(const GURL& gurl); |
| 50 void RecordPostDisclosureMetrics(const GURL& gurl); | 43 void RecordPostDisclosureMetrics(const GURL& gurl); |
| 51 Profile* GetProfile(); | 44 Profile* GetProfile(); |
| 52 | 45 |
| 53 bool consistent_geolocation_enabled_; | 46 bool consistent_geolocation_enabled_; |
| 54 | 47 |
| 55 DISALLOW_COPY_AND_ASSIGN(SearchGeolocationDisclosureTabHelper); | 48 DISALLOW_COPY_AND_ASSIGN(SearchGeolocationDisclosureTabHelper); |
| 56 }; | 49 }; |
| 57 | 50 |
| 58 #endif // CHROME_BROWSER_ANDROID_SEARCH_GEOLOCATION_DISCLOSURE_TAB_HELPER_H_ | 51 #endif // CHROME_BROWSER_ANDROID_SEARCH_GEOLOCATION_DISCLOSURE_TAB_HELPER_H_ |
| OLD | NEW |