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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/website/WebsitePermissionsFetcher.java

Issue 2953853002: [Android Site Settings] Disable fetching important sites when not needed (Closed)
Patch Set: Created 3 years, 6 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 package org.chromium.chrome.browser.preferences.website; 5 package org.chromium.chrome.browser.preferences.website;
6 6
7 import android.util.Pair; 7 import android.util.Pair;
8 8
9 import org.chromium.base.Callback; 9 import org.chromium.base.Callback;
10 import org.chromium.chrome.browser.ContentSettingsType; 10 import org.chromium.chrome.browser.ContentSettingsType;
(...skipping 16 matching lines...) Expand all
27 public interface WebsitePermissionsCallback { 27 public interface WebsitePermissionsCallback {
28 void onWebsitePermissionsAvailable(Collection<Website> sites); 28 void onWebsitePermissionsAvailable(Collection<Website> sites);
29 } 29 }
30 30
31 // This map looks up Websites by their origin and embedder. 31 // This map looks up Websites by their origin and embedder.
32 private final Map<Pair<WebsiteAddress, WebsiteAddress>, Website> mSites = ne w HashMap<>(); 32 private final Map<Pair<WebsiteAddress, WebsiteAddress>, Website> mSites = ne w HashMap<>();
33 33
34 // The callback to run when the permissions have been fetched. 34 // The callback to run when the permissions have been fetched.
35 private final WebsitePermissionsCallback mCallback; 35 private final WebsitePermissionsCallback mCallback;
36 36
37 private final boolean mFetchSiteImportantInfo;
38
37 /** 39 /**
38 * @param callback The callback to run when the fetch is complete. 40 * @param callback The callback to run when the fetch is complete.
39 */ 41 */
40 public WebsitePermissionsFetcher(WebsitePermissionsCallback callback) { 42 public WebsitePermissionsFetcher(WebsitePermissionsCallback callback) {
Ted C 2017/06/22 20:06:49 replace the two lines with: this(callback, false)
dmurph 2017/06/23 00:22:48 Done.
41 mCallback = callback; 43 mCallback = callback;
44 mFetchSiteImportantInfo = false;
42 } 45 }
43 46
44 /** 47 /**
48 * @param callback The callback to run when the fetch is complete.
Ted C 2017/06/22 20:06:49 add a @param for fetchSiteImportantInfo
dmurph 2017/06/23 00:22:48 Done.
49 */
50 public WebsitePermissionsFetcher(
51 WebsitePermissionsCallback callback, boolean fetchSiteImportantInfo) {
52 mCallback = callback;
53 mFetchSiteImportantInfo = fetchSiteImportantInfo;
54 }
55
56 /**
45 * Fetches preferences for all sites that have them. 57 * Fetches preferences for all sites that have them.
46 * TODO(mvanouwerkerk): Add an argument |url| to only fetch permissions for 58 * TODO(mvanouwerkerk): Add an argument |url| to only fetch permissions for
47 * sites from the same origin as that of |url| - https://crbug.com/459222. 59 * sites from the same origin as that of |url| - https://crbug.com/459222.
48 */ 60 */
49 public void fetchAllPreferences() { 61 public void fetchAllPreferences() {
50 TaskQueue queue = new TaskQueue(); 62 TaskQueue queue = new TaskQueue();
51 // Populate features from more specific to less specific. 63 // Populate features from more specific to less specific.
52 // Geolocation lookup permission is per-origin and per-embedder. 64 // Geolocation lookup permission is per-origin and per-embedder.
53 queue.add(new GeolocationInfoFetcher()); 65 queue.add(new GeolocationInfoFetcher());
54 // Midi sysex access permission is per-origin and per-embedder. 66 // Midi sysex access permission is per-origin and per-embedder.
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 for (Object o : result.entrySet()) { 303 for (Object o : result.entrySet()) {
292 @SuppressWarnings("unchecked") 304 @SuppressWarnings("unchecked")
293 Map.Entry<String, LocalStorageInfo> entry = 305 Map.Entry<String, LocalStorageInfo> entry =
294 (Map.Entry<String, LocalStorageInfo>) o; 306 (Map.Entry<String, LocalStorageInfo>) o;
295 WebsiteAddress address = WebsiteAddress.create(entry.get Key()); 307 WebsiteAddress address = WebsiteAddress.create(entry.get Key());
296 if (address == null) continue; 308 if (address == null) continue;
297 findOrCreateSite(address, null).setLocalStorageInfo(entr y.getValue()); 309 findOrCreateSite(address, null).setLocalStorageInfo(entr y.getValue());
298 } 310 }
299 queue.next(); 311 queue.next();
300 } 312 }
301 }); 313 }, mFetchSiteImportantInfo);
302 } 314 }
303 } 315 }
304 316
305 private class WebStorageInfoFetcher extends Task { 317 private class WebStorageInfoFetcher extends Task {
306 @Override 318 @Override
307 public void runAsync(final TaskQueue queue) { 319 public void runAsync(final TaskQueue queue) {
308 WebsitePreferenceBridge.fetchStorageInfo(new Callback<ArrayList>() { 320 WebsitePreferenceBridge.fetchStorageInfo(new Callback<ArrayList>() {
309 @Override 321 @Override
310 public void onResult(ArrayList result) { 322 public void onResult(ArrayList result) {
311 @SuppressWarnings("unchecked") 323 @SuppressWarnings("unchecked")
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 402 }
391 } 403 }
392 404
393 private class PermissionsAvailableCallbackRunner extends Task { 405 private class PermissionsAvailableCallbackRunner extends Task {
394 @Override 406 @Override
395 public void run() { 407 public void run() {
396 mCallback.onWebsitePermissionsAvailable(mSites.values()); 408 mCallback.onWebsitePermissionsAvailable(mSites.values());
397 } 409 }
398 } 410 }
399 } 411 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698