| Index: chrome/android/java/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkAddActivity.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkAddActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkAddActivity.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..22d7f3a2361829a5a6de03904d8b18cefefd8468
|
| --- /dev/null
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkAddActivity.java
|
| @@ -0,0 +1,67 @@
|
| +// 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.enhancedbookmarks;
|
| +
|
| +import org.chromium.base.metrics.RecordUserAction;
|
| +import org.chromium.chrome.browser.init.AsyncInitializationActivity;
|
| +import org.chromium.chrome.browser.partnerbookmarks.PartnerBookmarksShim;
|
| +import org.chromium.components.bookmarks.BookmarkId;
|
| +
|
| +/**
|
| + * This invisible activity adds a bookmark with the supplied title and url, then launches an
|
| + * activity to show the new bookmark.
|
| + *
|
| + * This activity is used only on pre-M devices with Chrome pre-installed. When a third-party app
|
| + * calls the now-obsolete method Browser.saveBookmark(), the call is forwarded through
|
| + * AddBookmarkProxyActivity and launches this activity. See http://crbug.com/581961 for details.
|
| + *
|
| + * TODO(newt): remove this once Android L is no longer supported.
|
| + */
|
| +public class EnhancedBookmarkAddActivity extends AsyncInitializationActivity {
|
| +
|
| + private static final String EXTRA_TITLE = "title";
|
| + private static final String EXTRA_URL = "url";
|
| +
|
| + private EnhancedBookmarksModel mModel;
|
| +
|
| + @Override
|
| + protected void setContentView() {}
|
| +
|
| + @Override
|
| + public void finishNativeInitialization() {
|
| + RecordUserAction.record("MobileAddBookmarkViaIntent");
|
| +
|
| + final String title = getIntent().getStringExtra(EXTRA_TITLE);
|
| + final String url = getIntent().getStringExtra(EXTRA_URL);
|
| +
|
| + // Partner bookmarks need to be loaded explicitly.
|
| + PartnerBookmarksShim.kickOffReading(this);
|
| +
|
| + // Store mModel as a member variable so it can't be garbage collected. Otherwise the
|
| + // Runnable might never be run.
|
| + mModel = new EnhancedBookmarksModel();
|
| + mModel.runAfterBookmarkModelLoaded(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + BookmarkId bookmarkId = EnhancedBookmarkUtils.addBookmarkSilently(
|
| + EnhancedBookmarkAddActivity.this, mModel, title, url);
|
| + if (bookmarkId != null) {
|
| + EnhancedBookmarkUtils.startEditActivity(EnhancedBookmarkAddActivity.this,
|
| + bookmarkId, null);
|
| + }
|
| + finish();
|
| + }
|
| + });
|
| + }
|
| +
|
| + @Override
|
| + protected void onDestroy() {
|
| + super.onDestroy();
|
| + if (mModel != null) {
|
| + mModel.destroy();
|
| + mModel = null;
|
| + }
|
| + }
|
| +}
|
|
|