Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/website/WebsitePermissionsFetcher.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/WebsitePermissionsFetcher.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/WebsitePermissionsFetcher.java |
| index 5fb19fb20e97e8bb4d2edd92bc3e06dcb4d9bb6a..4f4728d8fd2803f86649ba8379edca02096a9fe5 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/WebsitePermissionsFetcher.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/WebsitePermissionsFetcher.java |
| @@ -10,6 +10,7 @@ import java.util.ArrayList; |
| import java.util.HashMap; |
| import java.util.HashSet; |
| import java.util.LinkedList; |
| +import java.util.List; |
| import java.util.Map; |
| import java.util.Set; |
| @@ -23,8 +24,8 @@ public class WebsitePermissionsFetcher { |
| * website permissions have been fetched. |
| */ |
| public interface WebsitePermissionsCallback { |
| - void onWebsitePermissionsAvailable( |
| - Map<String, Set<Website>> sitesByOrigin, Map<String, Set<Website>> sitesByHost); |
| + void onWebsitePermissionsAvailable(Map<String, Set<Website>> sitesByOrigin, |
| + Map<String, Set<Website>> sitesByHost, List<String> importantOrigins); |
| } |
| // This is a 1 <--> 1..N mapping between origin and Website. |
| @@ -32,6 +33,8 @@ public class WebsitePermissionsFetcher { |
| // a HashSet is really confusing to readers of this code. There is no deduplication at all. |
| private final Map<String, Set<Website>> mSitesByOrigin = new HashMap<>(); |
| + private final List<String> mImportantOrigins = new ArrayList<>(); |
|
Finnur
2016/03/03 14:15:44
Nit: Document.
dmurph
2016/04/26 21:43:13
Removed.
|
| + |
| // This is a 1 <--> 1..N mapping between host and Website. |
| // TODO(mvanouwerkerk): The Website class has no equals or hashCode methods so storing them in |
| // a HashSet is really confusing to readers of this code. There is no deduplication at all. |
| @@ -48,6 +51,13 @@ public class WebsitePermissionsFetcher { |
| } |
| /** |
| + * @return the mImportantOrigins |
|
Finnur
2016/03/03 14:15:44
nit: This doesn't really add anything to what you
dmurph
2016/04/26 21:43:13
Removed
|
| + */ |
| + public List<String> getImportantOrigins() { |
| + return mImportantOrigins; |
| + } |
| + |
| + /** |
| * Fetches preferences for all sites that have them. |
| * TODO(mvanouwerkerk): Add an argument |url| to only fetch permissions for |
| * sites from the same origin as that of |url| - https://crbug.com/459222. |
| @@ -69,6 +79,8 @@ public class WebsitePermissionsFetcher { |
| queue.add(new LocalStorageInfoFetcher()); |
| // Website storage is per-host. |
| queue.add(new WebStorageInfoFetcher()); |
| + // Important sites |
| + queue.add(new ImportantOriginInfoFetcher()); |
| // Popup exceptions are host-based patterns (unless we start |
| // synchronizing popup exceptions with desktop Chrome.) |
| queue.add(new PopupExceptionInfoFetcher()); |
| @@ -110,6 +122,8 @@ public class WebsitePermissionsFetcher { |
| queue.add(new LocalStorageInfoFetcher()); |
| // Website storage is per-host. |
| queue.add(new WebStorageInfoFetcher()); |
| + // Important sites |
|
Finnur
2016/03/03 14:15:44
nit: End with period.
dmurph
2016/04/26 21:43:13
Removed.
|
| + queue.add(new ImportantOriginInfoFetcher()); |
| } else if (category.showFullscreenSites()) { |
| // Full screen is per-origin. |
| queue.add(new FullscreenInfoFetcher()); |
| @@ -286,6 +300,22 @@ public class WebsitePermissionsFetcher { |
| } |
| } |
| + private class ImportantOriginInfoFetcher extends Task { |
| + @Override |
| + public void runAsync(final TaskQueue queue) { |
| + WebsitePreferenceBridge.fetchImportantOriginInfo( |
| + new WebsitePreferenceBridge.ImportantOriginsReadyCallback() { |
| + @SuppressWarnings("unchecked") |
| + @Override |
| + public void onImportantOriginsReady(ArrayList sortedOrigins, HashMap map) { |
| + mImportantOrigins.clear(); |
| + mImportantOrigins.addAll((ArrayList<String>) sortedOrigins); |
| + queue.next(); |
| + } |
| + }); |
| + } |
| + } |
| + |
| private class LocalStorageInfoFetcher extends Task { |
| @Override |
| public void runAsync(final TaskQueue queue) { |
| @@ -381,7 +411,8 @@ public class WebsitePermissionsFetcher { |
| private class PermissionsAvailableCallbackRunner extends Task { |
| @Override |
| public void run() { |
| - mCallback.onWebsitePermissionsAvailable(mSitesByOrigin, mSitesByHost); |
| + mCallback.onWebsitePermissionsAvailable( |
| + mSitesByOrigin, mSitesByHost, mImportantOrigins); |
| } |
| } |
| } |