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

Side by Side Diff: chrome/browser/android/preferences/website_preference_bridge.cc

Issue 2612993002: Make geolocation API and X-Geo header access consistent (Closed)
Patch Set: Fix some things; rebase Created 3 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/android/preferences/website_preference_bridge.h" 5 #include "chrome/browser/android/preferences/website_preference_bridge.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/android/callback_android.h" 11 #include "base/android/callback_android.h"
12 #include "base/android/jni_android.h" 12 #include "base/android/jni_android.h"
13 #include "base/android/jni_string.h" 13 #include "base/android/jni_string.h"
14 #include "base/android/scoped_java_ref.h" 14 #include "base/android/scoped_java_ref.h"
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/bind_helpers.h" 16 #include "base/bind_helpers.h"
17 #include "base/json/json_reader.h" 17 #include "base/json/json_reader.h"
18 #include "base/json/json_writer.h" 18 #include "base/json/json_writer.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h "
21 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" 22 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h"
22 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" 23 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
23 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h" 24 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h"
24 #include "chrome/browser/browsing_data/cookies_tree_model.h" 25 #include "chrome/browser/browsing_data/cookies_tree_model.h"
25 #include "chrome/browser/browsing_data/local_data_container.h" 26 #include "chrome/browser/browsing_data/local_data_container.h"
26 #include "chrome/browser/browsing_data/origin_filter_builder.h" 27 #include "chrome/browser/browsing_data/origin_filter_builder.h"
27 #include "chrome/browser/content_settings/cookie_settings_factory.h" 28 #include "chrome/browser/content_settings/cookie_settings_factory.h"
28 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 29 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
29 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 30 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
30 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" 31 #include "chrome/browser/content_settings/web_site_settings_uma_util.h"
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 const JavaParamRef<jstring>& jorigin) { 747 const JavaParamRef<jstring>& jorigin) {
747 OriginFilterBuilder builder(OriginFilterBuilder::WHITELIST); 748 OriginFilterBuilder builder(OriginFilterBuilder::WHITELIST);
748 builder.AddOrigin(url::Origin(GURL(ConvertJavaStringToUTF8(env, jorigin)))); 749 builder.AddOrigin(url::Origin(GURL(ConvertJavaStringToUTF8(env, jorigin))));
749 GetHostContentSettingsMap(false) 750 GetHostContentSettingsMap(false)
750 ->ClearSettingsForOneTypeWithPredicate( 751 ->ClearSettingsForOneTypeWithPredicate(
751 CONTENT_SETTINGS_TYPE_APP_BANNER, 752 CONTENT_SETTINGS_TYPE_APP_BANNER,
752 base::Bind(&ForwardPrimaryPatternCallback, 753 base::Bind(&ForwardPrimaryPatternCallback,
753 builder.BuildWebsiteSettingsPatternMatchesFilter())); 754 builder.BuildWebsiteSettingsPatternMatchesFilter()));
754 } 755 }
755 756
757 static jboolean ShouldUseDSEGeolocationSetting(
758 JNIEnv* env,
759 const JavaParamRef<jclass>& clazz,
760 const JavaParamRef<jstring>& jorigin,
761 jboolean is_incognito) {
762 SearchGeolocationService* search_helper =
763 SearchGeolocationService::Factory::GetForBrowserContext(
764 GetActiveUserProfile(is_incognito));
765 return search_helper &&
766 search_helper->UseDSEGeolocationSetting(
767 url::Origin(GURL(ConvertJavaStringToUTF8(env, jorigin))));
768 }
769
770 static jboolean GetDSEGeolocationSetting(JNIEnv* env,
771 const JavaParamRef<jclass>& clazz) {
772 SearchGeolocationService* search_helper =
773 SearchGeolocationService::Factory::GetForBrowserContext(
774 GetActiveUserProfile(false));
raymes 2017/01/09 05:47:26 nit: document the boolean /* is_incognito */
benwells 2017/01/09 21:02:22 Done.
775 return search_helper->GetDSEGeolocationSetting();
776 }
777
778 static void SetDSEGeolocationSetting(JNIEnv* env,
779 const JavaParamRef<jclass>& clazz,
780 jboolean setting) {
781 SearchGeolocationService* search_helper =
782 SearchGeolocationService::Factory::GetForBrowserContext(
783 GetActiveUserProfile(false));
raymes 2017/01/09 05:47:26 nit: same here.
benwells 2017/01/09 21:02:22 Done.
784 return search_helper->SetDSEGeolocationSetting(setting);
785 }
786
756 // Register native methods 787 // Register native methods
757 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { 788 bool RegisterWebsitePreferenceBridge(JNIEnv* env) {
758 return RegisterNativesImpl(env); 789 return RegisterNativesImpl(env);
759 } 790 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698