Bug 1293790 - Pre: implement AS topsites access draft
authorAndrzej Hunt <ahunt@mozilla.com>
Tue, 09 Aug 2016 14:19:10 -0700
changeset 398841 1ef143809931994070b1e52453422f7931aa7435
parent 398840 0aeb441955b87895f77f6ac0a08a73cd42188999
child 398842 d16a05e0982dfa67020602ef733853c36b1e8cc5
push id25653
push userahunt@mozilla.com
push dateTue, 09 Aug 2016 21:33:27 +0000
bugs1293790
milestone51.0a1
Bug 1293790 - Pre: implement AS topsites access MozReview-Commit-ID: 1z30naErciE
mobile/android/base/java/org/mozilla/gecko/db/BrowserDB.java
mobile/android/base/java/org/mozilla/gecko/db/LocalBrowserDB.java
mobile/android/base/java/org/mozilla/gecko/db/StubBrowserDB.java
--- a/mobile/android/base/java/org/mozilla/gecko/db/BrowserDB.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/BrowserDB.java
@@ -76,16 +76,18 @@ public interface BrowserDB {
     /**
      * @return a cursor over top sites (high-ranking bookmarks and history).
      * Can return <code>null</code>.
      * Returns no more than <code>limit</code> results.
      * Suggested sites will be limited to being within the first <code>suggestedRangeLimit</code> results.
      */
     public abstract Cursor getTopSites(ContentResolver cr, int suggestedRangeLimit, int limit);
 
+    public abstract Cursor getASTopSites(ContentResolver cr, int limit);
+
     public abstract void updateVisitedHistory(ContentResolver cr, String uri);
 
     public abstract void updateHistoryTitle(ContentResolver cr, String uri, String title);
 
     /**
      * Can return <code>null</code>.
      */
     public abstract Cursor getAllVisitedHistory(ContentResolver cr);
--- a/mobile/android/base/java/org/mozilla/gecko/db/LocalBrowserDB.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/LocalBrowserDB.java
@@ -1840,16 +1840,38 @@ public class LocalBrowserDB implements B
             if (StringUtils.isUserEnteredUrl(url)) {
                 url = StringUtils.decodeUserEnteredUrl(url);
             }
 
             urls.add(url);
         } while (c.moveToNext());
     }
 
+    public Cursor getASTopSites(ContentResolver cr, int limit) {
+        final Uri uri = mTopSitesUriWithProfile.buildUpon()
+                .appendQueryParameter(BrowserContract.PARAM_LIMIT,
+                        String.valueOf(limit))
+                .appendQueryParameter(BrowserContract.PARAM_SUGGESTEDSITES_LIMIT,
+                        String.valueOf(limit))
+                .appendQueryParameter(BrowserContract.PARAM_TOPSITES_DISABLE_PINNED, Boolean.TRUE.toString())
+                .build();
+
+        Cursor topSitesCursor = cr.query(uri,
+                new String[]{Combined._ID,
+                        Combined.URL,
+                        Combined.TITLE,
+                        Combined.BOOKMARK_ID,
+                        Combined.HISTORY_ID},
+                null,
+                null,
+                null);
+
+        return topSitesCursor;
+    }
+
     @Override
     public Cursor getTopSites(ContentResolver cr, int suggestedRangeLimit, int limit) {
         final Uri uri = mTopSitesUriWithProfile.buildUpon()
                 .appendQueryParameter(BrowserContract.PARAM_LIMIT,
                         String.valueOf(limit))
                 .appendQueryParameter(BrowserContract.PARAM_SUGGESTEDSITES_LIMIT,
                         String.valueOf(suggestedRangeLimit))
                 .build();
--- a/mobile/android/base/java/org/mozilla/gecko/db/StubBrowserDB.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/StubBrowserDB.java
@@ -374,16 +374,20 @@ public class StubBrowserDB implements Br
     public int getSuggestedBackgroundColorForUrl(String url) {
         return 0;
     }
 
     public Cursor getTopSites(ContentResolver cr, int suggestedRangeLimit, int limit) {
         return null;
     }
 
+    public Cursor getASTopSites(ContentResolver cr, int limit) {
+        return null;
+    }
+
     public static Factory getFactory() {
         return new Factory() {
             @Override
             public BrowserDB get(String profileName, File profileDir) {
                 return new StubBrowserDB(profileName);
             }
         };
     }