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

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

Issue 927763003: Move website settings fetching from WebsitePreferences to new WebsitePermissionFetcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert changes to WebsiteSettingsPopup. Created 5 years, 10 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 "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/android/scoped_java_ref.h" 9 #include "base/android/scoped_java_ref.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/strings/string_util.h"
13 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" 15 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
15 #include "chrome/browser/browsing_data/cookies_tree_model.h" 16 #include "chrome/browser/browsing_data/cookies_tree_model.h"
16 #include "chrome/browser/browsing_data/local_data_container.h" 17 #include "chrome/browser/browsing_data/local_data_container.h"
17 #include "chrome/browser/content_settings/cookie_settings.h" 18 #include "chrome/browser/content_settings/cookie_settings.h"
18 #include "chrome/browser/notifications/desktop_notification_profile_util.h" 19 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
21 #include "components/content_settings/core/browser/host_content_settings_map.h" 22 #include "components/content_settings/core/browser/host_content_settings_map.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/storage_partition.h" 24 #include "content/public/browser/storage_partition.h"
24 #include "jni/WebsitePreferenceBridge_jni.h" 25 #include "jni/WebsitePreferenceBridge_jni.h"
25 #include "storage/browser/quota/quota_client.h" 26 #include "storage/browser/quota/quota_client.h"
26 #include "storage/browser/quota/quota_manager.h" 27 #include "storage/browser/quota/quota_manager.h"
28 #include "url/url_constants.h"
27 29
28 using base::android::ConvertJavaStringToUTF8; 30 using base::android::ConvertJavaStringToUTF8;
29 using base::android::ConvertUTF8ToJavaString; 31 using base::android::ConvertUTF8ToJavaString;
30 using base::android::JavaRef; 32 using base::android::JavaRef;
31 using base::android::ScopedJavaGlobalRef; 33 using base::android::ScopedJavaGlobalRef;
32 using base::android::ScopedJavaLocalRef; 34 using base::android::ScopedJavaLocalRef;
33 using content::BrowserThread; 35 using content::BrowserThread;
34 36
35 static HostContentSettingsMap* GetHostContentSettingsMap() { 37 static HostContentSettingsMap* GetHostContentSettingsMap() {
36 Profile* profile = ProfileManager::GetActiveUserProfile(); 38 Profile* profile = ProfileManager::GetActiveUserProfile();
(...skipping 14 matching lines...) Expand all
51 for (const auto& settings_it : all_settings) { 53 for (const auto& settings_it : all_settings) {
52 if (settings_it.setting == default_content_setting) 54 if (settings_it.setting == default_content_setting)
53 continue; 55 continue;
54 if (managedOnly && 56 if (managedOnly &&
55 HostContentSettingsMap::GetProviderTypeFromSource(settings_it.source) != 57 HostContentSettingsMap::GetProviderTypeFromSource(settings_it.source) !=
56 HostContentSettingsMap::ProviderType::POLICY_PROVIDER) { 58 HostContentSettingsMap::ProviderType::POLICY_PROVIDER) {
57 continue; 59 continue;
58 } 60 }
59 const std::string origin = settings_it.primary_pattern.ToString(); 61 const std::string origin = settings_it.primary_pattern.ToString();
60 const std::string embedder = settings_it.secondary_pattern.ToString(); 62 const std::string embedder = settings_it.secondary_pattern.ToString();
61 ScopedJavaLocalRef<jstring> jorigin = ConvertUTF8ToJavaString(env, origin); 63
64 // The string |jorigin| is used to group permissions together in the Site
Miguel Garcia 2015/02/18 21:40:46 Do you really need to do this here? Can't you pass
Michael van Ouwerkerk 2015/02/19 17:19:35 I think this can stay for the moment, but I'm happ
65 // Settings list. In order to group sites with the same origin, remove any
66 // standard port from the end of the URL if it's present (i.e. remove :443
67 // for HTTPS sites and :80 for HTTP sites).
68 // TODO(sashab,lgarron): Find out which settings are being saved with the
69 // port and omit it if it's the standard port.
70 // TODO(sashab): Remove all this logic and take two passes through
71 // HostContentSettingsMap: once to get all the 'interesting' hosts, and once
72 // (on SingleWebsitePreferences) to find permission patterns which match
73 // each of these hosts.
74 const char* kHttpPortSuffix = ":80";
75 const char* kHttpsPortSuffix = ":443";
76 ScopedJavaLocalRef<jstring> jorigin;
77 if (StartsWithASCII(origin, url::kHttpsScheme, false) &&
78 EndsWith(origin, kHttpsPortSuffix, false)) {
79 jorigin = ConvertUTF8ToJavaString(
80 env, origin.substr(0, origin.size() - strlen(kHttpsPortSuffix)));
81 } else if (StartsWithASCII(origin, url::kHttpScheme, false) &&
82 EndsWith(origin, kHttpPortSuffix, false)) {
83 jorigin = ConvertUTF8ToJavaString(
84 env, origin.substr(0, origin.size() - strlen(kHttpPortSuffix)));
85 } else {
86 jorigin = ConvertUTF8ToJavaString(env, origin);
87 }
88
62 ScopedJavaLocalRef<jstring> jembedder; 89 ScopedJavaLocalRef<jstring> jembedder;
63 if (embedder != origin) 90 if (embedder != origin)
64 jembedder = ConvertUTF8ToJavaString(env, embedder); 91 jembedder = ConvertUTF8ToJavaString(env, embedder);
65 switch (content_type) { 92 switch (content_type) {
66 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: 93 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
67 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: 94 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
68 Java_WebsitePreferenceBridge_insertVoiceAndVideoCaptureInfoIntoList( 95 Java_WebsitePreferenceBridge_insertVoiceAndVideoCaptureInfoIntoList(
69 env, list, jorigin.obj(), jembedder.obj()); 96 env, list, jorigin.obj(), jembedder.obj());
70 break; 97 break;
71 case CONTENT_SETTINGS_TYPE_GEOLOCATION: 98 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 GURL url(ConvertJavaStringToUTF8(env, jorigin)); 646 GURL url(ConvertJavaStringToUTF8(env, jorigin));
620 scoped_refptr<SiteDataDeleteHelper> site_data_deleter( 647 scoped_refptr<SiteDataDeleteHelper> site_data_deleter(
621 new SiteDataDeleteHelper(profile, url)); 648 new SiteDataDeleteHelper(profile, url));
622 site_data_deleter->Run(); 649 site_data_deleter->Run();
623 } 650 }
624 651
625 // Register native methods 652 // Register native methods
626 bool RegisterWebsitePreferenceBridge(JNIEnv* env) { 653 bool RegisterWebsitePreferenceBridge(JNIEnv* env) {
627 return RegisterNativesImpl(env); 654 return RegisterNativesImpl(env);
628 } 655 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698