Chromium Code Reviews| Index: chrome/browser/android/preferences/website_preference_bridge.cc |
| diff --git a/chrome/browser/android/preferences/website_preference_bridge.cc b/chrome/browser/android/preferences/website_preference_bridge.cc |
| index 31e94cf5ec3a2d0b7ad6b0383a6b825ce7ab5cd7..23ac44ea98a0b9bd5cefad47711145f03ac72744 100644 |
| --- a/chrome/browser/android/preferences/website_preference_bridge.cc |
| +++ b/chrome/browser/android/preferences/website_preference_bridge.cc |
| @@ -4,6 +4,10 @@ |
| #include "chrome/browser/android/preferences/website_preference_bridge.h" |
| +#include <algorithm> |
| +#include <string> |
| +#include <vector> |
| + |
| #include "base/android/jni_android.h" |
| #include "base/android/jni_string.h" |
| #include "base/android/scoped_java_ref.h" |
| @@ -11,6 +15,7 @@ |
| #include "base/bind_helpers.h" |
| #include "base/logging.h" |
| #include "base/macros.h" |
| +#include "chrome/browser/android/preferences/important_sites_util.h" |
| #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| #include "chrome/browser/browsing_data/browsing_data_quota_helper.h" |
| #include "chrome/browser/browsing_data/cookies_tree_model.h" |
| @@ -29,6 +34,7 @@ |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/storage_partition.h" |
| #include "jni/WebsitePreferenceBridge_jni.h" |
| +#include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| #include "storage/browser/quota/quota_manager.h" |
| #include "storage/common/quota/quota_status_code.h" |
| #include "url/url_constants.h" |
| @@ -41,6 +47,7 @@ using base::android::ScopedJavaLocalRef; |
| using content::BrowserThread; |
| namespace { |
| +const int kMaxImportantSites = 10; |
|
Theresa
2016/04/27 21:11:00
Why is this different from the value in pref_servi
dmurph
2016/04/29 23:53:49
I chatted with Dru (the PM on this) and we decided
|
| Profile* GetActiveUserProfile(bool is_incognito) { |
| Profile* profile = ProfileManager::GetActiveUserProfile(); |
| @@ -643,25 +650,39 @@ class LocalStorageInfoReadyCallback { |
| } |
| void OnLocalStorageModelInfoLoaded( |
| + Profile* profile, |
| const std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>& |
| local_storage_info) { |
| ScopedJavaLocalRef<jobject> map = |
| Java_WebsitePreferenceBridge_createLocalStorageInfoMap(env_); |
| + std::vector<std::string> important_domains = |
| + ImportantSitesUtil::GetImportantRegisterableDomains(profile, |
| + kMaxImportantSites); |
| + |
| std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::const_iterator |
| i; |
| for (i = local_storage_info.begin(); i != local_storage_info.end(); ++i) { |
| ScopedJavaLocalRef<jstring> full_origin = |
| ConvertUTF8ToJavaString(env_, i->origin_url.spec()); |
| + std::string origin_str = i->origin_url.GetOrigin().spec(); |
| + bool important = false; |
| + std::string registerable_domain = |
| + net::registry_controlled_domains::GetDomainAndRegistry( |
| + i->origin_url, |
| + net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| + if (std::find(important_domains.begin(), important_domains.end(), |
|
Theresa
2016/04/27 21:11:00
Does 'important' info need to be added to each web
dmurph
2016/04/29 23:53:49
We don't fetch it for every website (we just use t
Theresa
2016/05/03 00:04:27
sg.
|
| + registerable_domain) == important_domains.end()) { |
| + important = true; |
| + } |
| // Remove the trailing backslash so the origin is matched correctly in |
| // SingleWebsitePreferences.mergePermissionInfoForTopLevelOrigin. |
| - std::string origin_str = i->origin_url.GetOrigin().spec(); |
| DCHECK(origin_str[origin_str.size() - 1] == '/'); |
| origin_str = origin_str.substr(0, origin_str.size() - 1); |
| ScopedJavaLocalRef<jstring> origin = |
| ConvertUTF8ToJavaString(env_, origin_str); |
| Java_WebsitePreferenceBridge_insertLocalStorageInfoIntoMap( |
| - env_, map.obj(), origin.obj(), full_origin.obj(), i->size); |
| + env_, map.obj(), origin.obj(), full_origin.obj(), i->size, important); |
| } |
| Java_LocalStorageInfoReadyCallback_onLocalStorageInfoReady( |
| @@ -697,7 +718,7 @@ static void FetchLocalStorageInfo(JNIEnv* env, |
| new LocalStorageInfoReadyCallback(java_callback); |
| local_storage_helper->StartFetching( |
| base::Bind(&LocalStorageInfoReadyCallback::OnLocalStorageModelInfoLoaded, |
| - base::Unretained(local_storage_callback))); |
| + base::Unretained(local_storage_callback), profile)); |
| } |
| static void FetchStorageInfo(JNIEnv* env, |