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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/bookmark/ShortcutActivity.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/bookmark/ShortcutActivity.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/bookmark/ShortcutActivity.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/bookmark/ShortcutActivity.java
new file mode 100644
index 0000000000000000000000000000000000000000..939856dc05bb0a94ef0aee23938c54df39a3beb8
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/bookmark/ShortcutActivity.java
@@ -0,0 +1,89 @@
+// 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.bookmark;
+
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.view.ViewGroup;
+
+import com.google.android.apps.chrome.R;
+
+import org.chromium.chrome.browser.BookmarkUtils;
+import org.chromium.chrome.browser.UrlConstants;
+import org.chromium.chrome.browser.favicon.FaviconHelper;
+import org.chromium.chrome.browser.init.AsyncInitializationActivity;
+import org.chromium.chrome.browser.ntp.BookmarksPage;
+import org.chromium.chrome.browser.ntp.BookmarksPage.BookmarkSelectedListener;
+import org.chromium.chrome.browser.partnerbookmarks.PartnerBookmarksShim;
+import org.chromium.chrome.browser.profiles.Profile;
+
+/**
+ * Activity that allows the user to select a bookmark to add to their homescreen as a shortcut.
+ */
+public class ShortcutActivity extends AsyncInitializationActivity implements
+ BookmarkSelectedListener {
+ private BookmarksPage mBookmarksPage;
+
+ @Override
+ protected void setContentView() {
+ // We can't show anything until the native library is loaded.
+ }
+
+ @Override
+ public void postInflationStartup() {
+ setTitle(getResources().getString(R.string.bookmark_shortcut_choose_bookmark));
+ }
+
+ @Override
+ public void initializeState() {
+ super.initializeState();
+
+ // Partner bookmarks need to be loaded explicitly.
+ PartnerBookmarksShim.kickOffReading(this);
+
+ Profile profile = Profile.getLastUsedProfile();
+ mBookmarksPage = BookmarksPage.buildPageInSelectBookmarkMode(this, profile, this);
+ mBookmarksPage.updateForUrl(UrlConstants.BOOKMARKS_URL);
+
+ setContentView(mBookmarksPage.getView(), new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT));
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ if (mBookmarksPage != null) {
+ mBookmarksPage.destroy();
+ mBookmarksPage = null;
+ }
+ }
+
+ // BookmarkSelectedListener implementation
+
+ @Override
+ public void onNewTabOpened() {
+ }
+
+ @Override
+ public void onBookmarkSelected(String url, String title, Bitmap favicon) {
+ int dominantColor = FaviconHelper.getDominantColorForBitmap(favicon);
+ Bitmap launcherIcon = BookmarkUtils.createLauncherIcon(this, favicon, url,
+ Color.red(dominantColor), Color.green(dominantColor), Color.blue(dominantColor));
+ Intent intent = BookmarkUtils.createAddToHomeIntent(url, title, launcherIcon);
+ setResult(RESULT_OK, intent);
+ finish();
+ }
+
+ @Override
+ public void onResumeWithNative() { }
+
+ @Override
+ public void onPauseWithNative() { }
+
+ @Override
+ public void onStopWithNative() { }
+}

Powered by Google App Engine
This is Rietveld 408576698