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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkPage.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkPage.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkPage.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkPage.java
new file mode 100644
index 0000000000000000000000000000000000000000..1853e55e3dd22c20e9eb8144bc34ab822e976609
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkPage.java
@@ -0,0 +1,94 @@
+// Copyright 2015 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.enhancedbookmarks;
+
+import android.app.Activity;
+import android.content.res.Resources;
+import android.view.View;
+
+import com.google.android.apps.chrome.R;
+
+import org.chromium.chrome.browser.NativePage;
+import org.chromium.chrome.browser.Tab;
+import org.chromium.chrome.browser.UrlConstants;
+import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkDelegate.EnhancedBookmarkStateChangeListener;
+import org.chromium.content_public.browser.LoadUrlParams;
+import org.chromium.ui.base.DeviceFormFactor;
+
+/**
+ * A native page holding a {@link EnhancedBookmarkManager} on _tablet_.
+ */
+public class EnhancedBookmarkPage implements NativePage, EnhancedBookmarkStateChangeListener {
+ private final Activity mActivity;
+ private final Tab mTab;
+ private final String mTitle;
+ private final int mBackgroundColor;
+ private final EnhancedBookmarkManager mManager;
+
+ /**
+ * Create a new instance of an enhanced bookmark page.
+ * @param activity The activity to get context and manage fragments.
+ * @param tab The tab to load urls.
+ * @return Null if this method is called on phone. Otherwise, return a new enhanced bookmark
+ * native page for tablet.
+ */
+ public static EnhancedBookmarkPage buildPage(Activity activity, Tab tab) {
+ if (DeviceFormFactor.isTablet(activity)) return new EnhancedBookmarkPage(activity, tab);
+ else return null;
+ }
+
+ private EnhancedBookmarkPage(Activity activity, Tab tab) {
+ mActivity = activity;
+ mTab = tab;
+ mTitle = activity.getString(R.string.bookmarks);
+ mBackgroundColor = activity.getResources().getColor(R.color.default_primary_color);
+
+ mManager = new EnhancedBookmarkManager(mActivity);
+ Resources res = mActivity.getResources();
+ mManager.getView().setPadding(0, res.getDimensionPixelSize(R.dimen.tab_strip_height)
+ + res.getDimensionPixelSize(R.dimen.toolbar_height_no_shadow), 0, 0);
+ mManager.setUrlChangeListener(this);
+ }
+
+ @Override
+ public View getView() {
+ return mManager.getView();
+ }
+
+ @Override
+ public String getTitle() {
+ return mTitle;
+ }
+
+ @Override
+ public String getUrl() {
+ return mManager.getCurrentUrl();
+ }
+
+ @Override
+ public String getHost() {
+ return UrlConstants.BOOKMARKS_HOST;
+ }
+
+ @Override
+ public int getBackgroundColor() {
+ return mBackgroundColor;
+ }
+
+ @Override
+ public void updateForUrl(String url) {
+ mManager.updateForUrl(url);
+ }
+
+ @Override
+ public void destroy() {
+ mManager.destroy();
+ }
+
+ @Override
+ public void onBookmarkUIStateChange(String url) {
+ mTab.loadUrl(new LoadUrlParams(url));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698