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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/bookmark/ManageBookmarkActivity.java

Issue 1452323003: Remove the ability to trigger the edit bookmark dialog via URL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « chrome/android/java/AndroidManifest.xml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.bookmark; 5 package org.chromium.chrome.browser.bookmark;
6 6
7 import android.Manifest; 7 import android.Manifest;
8 import android.app.Fragment; 8 import android.app.Fragment;
9 import android.app.FragmentManager.OnBackStackChangedListener; 9 import android.app.FragmentManager.OnBackStackChangedListener;
10 import android.app.FragmentTransaction; 10 import android.app.FragmentTransaction;
11 import android.content.Intent; 11 import android.content.Intent;
12 import android.content.pm.PackageManager; 12 import android.content.pm.PackageManager;
13 import android.content.res.Configuration; 13 import android.content.res.Configuration;
14 import android.net.Uri;
15 import android.nfc.NfcAdapter; 14 import android.nfc.NfcAdapter;
16 import android.os.Bundle; 15 import android.os.Bundle;
17 import android.os.Process; 16 import android.os.Process;
18 import android.support.v4.app.FragmentActivity; 17 import android.support.v4.app.FragmentActivity;
19 import android.util.Log; 18 import android.util.Log;
20 import android.view.WindowManager; 19 import android.view.WindowManager;
21 20
22 import org.chromium.base.VisibleForTesting; 21 import org.chromium.base.VisibleForTesting;
23 import org.chromium.base.annotations.SuppressFBWarnings; 22 import org.chromium.base.annotations.SuppressFBWarnings;
24 import org.chromium.base.library_loader.ProcessInitException; 23 import org.chromium.base.library_loader.ProcessInitException;
25 import org.chromium.chrome.browser.ChromeApplication; 24 import org.chromium.chrome.browser.ChromeApplication;
25 import org.chromium.chrome.browser.ChromeBrowserProviderClient;
26 import org.chromium.chrome.browser.util.IntentUtils;
26 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; 27 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils;
27 import org.chromium.ui.UiUtils; 28 import org.chromium.ui.UiUtils;
28 import org.chromium.ui.base.DeviceFormFactor; 29 import org.chromium.ui.base.DeviceFormFactor;
29 30
30 /** 31 /**
31 * This class provides the adding bookmark UI. It is also required by 32 * This class provides the adding bookmark UI. It is also required by
32 * android.provider.Browser.saveBookmark 33 * android.provider.Browser.saveBookmark
33 */ 34 */
34 public class ManageBookmarkActivity extends FragmentActivity { 35 public class ManageBookmarkActivity extends FragmentActivity {
35 36
36 private static final String BOOKMARK_ID_URI_PARAM = "id";
37 private static final String BOOKMARK_IS_FOLDER_URI_PARAM = "isfolder";
38
39 private static final String TAG = "ManageBookmarkActivity"; 37 private static final String TAG = "ManageBookmarkActivity";
40 38
41 /* TODO(gb-deprecation): Use android.provider.BrowserContract.Bookmarks.IS_F OLDER */ 39 /* TODO(gb-deprecation): Use android.provider.BrowserContract.Bookmarks.IS_F OLDER */
42 public static final String BOOKMARK_INTENT_IS_FOLDER = "folder"; 40 public static final String BOOKMARK_INTENT_IS_FOLDER = "folder";
43 /* TODO(gb-deprecation): Use android.provider.BrowserContract.Bookmarks.TITL E */ 41 /* TODO(gb-deprecation): Use android.provider.BrowserContract.Bookmarks.TITL E */
44 public static final String BOOKMARK_INTENT_TITLE = "title"; 42 public static final String BOOKMARK_INTENT_TITLE = "title";
45 /* TODO(gb-deprecation): Use android.provider.BrowserContract.Bookmarks.URL */ 43 /* TODO(gb-deprecation): Use android.provider.BrowserContract.Bookmarks.URL */
46 public static final String BOOKMARK_INTENT_URL = "url"; 44 public static final String BOOKMARK_INTENT_URL = "url";
47 /* TODO(gb-deprecation): Use android.provider.BrowserContract.Bookmarks._ID */ 45 /* TODO(gb-deprecation): Use android.provider.BrowserContract.Bookmarks._ID */
48 public static final String BOOKMARK_INTENT_ID = "_id"; 46 public static final String BOOKMARK_INTENT_ID = "_id";
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 * Creates the base add/edit bookmark fragment based on the intent passed to this activity. 188 * Creates the base add/edit bookmark fragment based on the intent passed to this activity.
191 * 189 *
192 * @return The appropriate fragment based on the intent parameters. 190 * @return The appropriate fragment based on the intent parameters.
193 */ 191 */
194 @SuppressFBWarnings("NP_NULL_ON_SOME_PATH") 192 @SuppressFBWarnings("NP_NULL_ON_SOME_PATH")
195 private AddEditBookmarkFragment generateBaseFragment() { 193 private AddEditBookmarkFragment generateBaseFragment() {
196 if (getIntent() == null) { 194 if (getIntent() == null) {
197 throw new IllegalArgumentException("intent can not be null"); 195 throw new IllegalArgumentException("intent can not be null");
198 } 196 }
199 Intent intent = getIntent(); 197 Intent intent = getIntent();
200 Uri intentUri = intent.getData();
201 198
202 Long bookmarkId = null; 199 boolean isFolder = IntentUtils.safeGetBooleanExtra(
203 boolean isFolder = false; 200 intent, BOOKMARK_INTENT_IS_FOLDER, false);
204 AddEditBookmarkFragment addEditFragment; 201 String name = IntentUtils.safeGetStringExtra(intent, BOOKMARK_INTENT_TIT LE);
205 if (intentUri != null && intentUri.getHost().equals("editbookmark")) { 202 String url = IntentUtils.safeGetStringExtra(intent, BOOKMARK_INTENT_URL) ;
206 isFolder = intentUri.getBooleanQueryParameter(BOOKMARK_IS_FOLDER_URI _PARAM, false); 203 if (url != null) url = DomDistillerUrlUtils.getOriginalUrlFromDistillerU rl(url);
207 String bookmarkIdParam = intentUri.getQueryParameter(BOOKMARK_ID_URI _PARAM); 204 long bookmarkId = IntentUtils.safeGetLongExtra(
208 if (bookmarkIdParam != null) bookmarkId = Long.parseLong(bookmarkIdP aram); 205 intent, BOOKMARK_INTENT_ID, ChromeBrowserProviderClient.INVALID_ BOOKMARK_ID);
209 addEditFragment = AddEditBookmarkFragment.newEditInstance(isFolder, bookmarkId);
210 } else {
211 Bundle extras = intent.getExtras();
212 String url = null;
213 String name = null;
214 if (extras != null) {
215 isFolder = extras.getBoolean(BOOKMARK_INTENT_IS_FOLDER, false);
216 206
217 if (extras.containsKey(BOOKMARK_INTENT_TITLE)) { 207 AddEditBookmarkFragment addEditFragment = AddEditBookmarkFragment.newIns tance(
218 name = extras.getString(BOOKMARK_INTENT_TITLE); 208 isFolder, bookmarkId, name, url);
219 } 209
220 if (extras.containsKey(BOOKMARK_INTENT_URL)) {
221 url = extras.getString(BOOKMARK_INTENT_URL);
222 url = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(ur l);
223 }
224 if (extras.containsKey(BOOKMARK_INTENT_ID)) {
225 bookmarkId = extras.getLong(BOOKMARK_INTENT_ID);
226 }
227 }
228 addEditFragment = AddEditBookmarkFragment.newInstance(isFolder, book markId, name, url);
229 }
230 setActionListenerOnAddEdit(addEditFragment); 210 setActionListenerOnAddEdit(addEditFragment);
231 return addEditFragment; 211 return addEditFragment;
232 } 212 }
233 213
234 /** 214 /**
235 * Creates and sets an action listener on the add/edit bookmark fragment. 215 * Creates and sets an action listener on the add/edit bookmark fragment.
236 * @param addEditFragment The fragment that the listener should be attached to. 216 * @param addEditFragment The fragment that the listener should be attached to.
237 */ 217 */
238 private void setActionListenerOnAddEdit(final AddEditBookmarkFragment addEdi tFragment) { 218 private void setActionListenerOnAddEdit(final AddEditBookmarkFragment addEdi tFragment) {
239 addEditFragment.setOnActionListener(new AddEditBookmarkFragment.OnAction Listener() { 219 addEditFragment.setOnActionListener(new AddEditBookmarkFragment.OnAction Listener() {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 AddEditBookmarkFragment.newAddNewFolderInstance(parentFolderId, parentName); 306 AddEditBookmarkFragment.newAddNewFolderInstance(parentFolderId, parentName);
327 newFolderFragment.setTargetFragment(triggeringFragment, 0); 307 newFolderFragment.setTargetFragment(triggeringFragment, 0);
328 setActionListenerOnAddEdit(newFolderFragment); 308 setActionListenerOnAddEdit(newFolderFragment);
329 getFragmentManager().beginTransaction() 309 getFragmentManager().beginTransaction()
330 .hide(triggeringFragment) 310 .hide(triggeringFragment)
331 .add(android.R.id.content, newFolderFragment, ADD_FOLDER_FRAGMEN T_TAG) 311 .add(android.R.id.content, newFolderFragment, ADD_FOLDER_FRAGMEN T_TAG)
332 .addToBackStack(null) 312 .addToBackStack(null)
333 .commit(); 313 .commit();
334 } 314 }
335 } 315 }
OLDNEW
« no previous file with comments | « chrome/android/java/AndroidManifest.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698