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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/history/HistoryItem.java

Issue 2542203002: [Android History] Add Android history manager UI and bridge (Closed)
Patch Set: Rebase, drop changes to time.* Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/history/HistoryItem.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryItem.java b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryItem.java
new file mode 100644
index 0000000000000000000000000000000000000000..a68f650f3dc8d6e7c53d60bd92cd63dc745eeaf2
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryItem.java
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.history;
+
+import android.text.TextUtils;
+
+import org.chromium.chrome.browser.widget.DateDividedAdapter.TimedItem;
+
+/** Contains information about a single browsing history item. */
+public class HistoryItem extends TimedItem {
+ private final String mUrl;
+ private final String mDomain;
+ private final String mTitle;
+ private final long mTimestamp;
+ private Long mStableId;
+
+ /**
+ * @param url The url for this item.
+ * @param domain The string to display for the item's domain.
+ * @param title The string to display for the item's title.
+ * @param timestamp The timestamp for this item.
+ */
+ public HistoryItem(String url, String domain, String title, long timestamp) {
+ mUrl = url;
+ mDomain = domain;
+ mTitle = TextUtils.isEmpty(title) ? url : title;
+ mTimestamp = timestamp;
+ }
+
+ /** @return The string to display for the item's domain. */
+ public String getDomain() {
+ return mDomain;
+ }
+
+ /** @return The string to display for the item's title. */
+ public String getTitle() {
+ return mTitle;
+ }
+
+ @Override
+ public long getTimestamp() {
+ return mTimestamp;
+ }
+
+ @Override
+ public long getStableId() {
+ if (mStableId == null) {
+ // Generate a stable ID that combines the timestamp and the URL.
+ mStableId = (long) mUrl.hashCode();
+ mStableId = (mStableId << 32) + (getTimestamp() & 0x0FFFFFFFF);
+ }
+ return mStableId;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698