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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkAddActivity.java

Issue 1688033002: Rename EnhancedBookmarks to Bookmarks, part 1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments from #2 Created 4 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.enhancedbookmarks;
6
7 import org.chromium.base.metrics.RecordUserAction;
8 import org.chromium.chrome.browser.init.AsyncInitializationActivity;
9 import org.chromium.chrome.browser.partnerbookmarks.PartnerBookmarksShim;
10 import org.chromium.components.bookmarks.BookmarkId;
11
12 /**
13 * This invisible activity adds a bookmark with the supplied title and url, then launches an
14 * activity to show the new bookmark.
15 *
16 * This activity is used only on pre-M devices with Chrome pre-installed. When a third-party app
17 * calls the now-obsolete method Browser.saveBookmark(), the call is forwarded t hrough
18 * AddBookmarkProxyActivity and launches this activity. See http://crbug.com/581 961 for details.
19 *
20 * TODO(newt): remove this once Android L is no longer supported.
21 */
22 public class EnhancedBookmarkAddActivity extends AsyncInitializationActivity {
23
24 private static final String EXTRA_TITLE = "title";
25 private static final String EXTRA_URL = "url";
26
27 private EnhancedBookmarksModel mModel;
28
29 @Override
30 protected void setContentView() {}
31
32 @Override
33 public void finishNativeInitialization() {
34 RecordUserAction.record("MobileAddBookmarkViaIntent");
35
36 final String title = getIntent().getStringExtra(EXTRA_TITLE);
37 final String url = getIntent().getStringExtra(EXTRA_URL);
38
39 // Partner bookmarks need to be loaded explicitly.
40 PartnerBookmarksShim.kickOffReading(this);
41
42 // Store mModel as a member variable so it can't be garbage collected. O therwise the
43 // Runnable might never be run.
44 mModel = new EnhancedBookmarksModel();
45 mModel.runAfterBookmarkModelLoaded(new Runnable() {
46 @Override
47 public void run() {
48 BookmarkId bookmarkId = EnhancedBookmarkUtils.addBookmarkSilentl y(
49 EnhancedBookmarkAddActivity.this, mModel, title, url);
50 if (bookmarkId != null) {
51 EnhancedBookmarkUtils.startEditActivity(EnhancedBookmarkAddA ctivity.this,
52 bookmarkId, null);
53 }
54 finish();
55 }
56 });
57 }
58
59 @Override
60 protected void onDestroy() {
61 super.onDestroy();
62 if (mModel != null) {
63 mModel.destroy();
64 mModel = null;
65 }
66 }
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698