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

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

Issue 666673009: Removing NavigationClient dependencies from Tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the review comments. Created 6 years, 2 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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; 5 package org.chromium.chrome.browser;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.Context; 8 import android.content.Context;
9 import android.graphics.Bitmap; 9 import android.graphics.Bitmap;
10 import android.graphics.Color; 10 import android.graphics.Color;
(...skipping 13 matching lines...) Expand all
24 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulatorWrapper; 24 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulatorWrapper;
25 import org.chromium.chrome.browser.contextmenu.EmptyChromeContextMenuItemDelegat e; 25 import org.chromium.chrome.browser.contextmenu.EmptyChromeContextMenuItemDelegat e;
26 import org.chromium.chrome.browser.dom_distiller.DomDistillerFeedbackReporter; 26 import org.chromium.chrome.browser.dom_distiller.DomDistillerFeedbackReporter;
27 import org.chromium.chrome.browser.infobar.AutoLoginProcessor; 27 import org.chromium.chrome.browser.infobar.AutoLoginProcessor;
28 import org.chromium.chrome.browser.infobar.InfoBarContainer; 28 import org.chromium.chrome.browser.infobar.InfoBarContainer;
29 import org.chromium.chrome.browser.profiles.Profile; 29 import org.chromium.chrome.browser.profiles.Profile;
30 import org.chromium.chrome.browser.toolbar.ToolbarModel; 30 import org.chromium.chrome.browser.toolbar.ToolbarModel;
31 import org.chromium.content.browser.ContentView; 31 import org.chromium.content.browser.ContentView;
32 import org.chromium.content.browser.ContentViewClient; 32 import org.chromium.content.browser.ContentViewClient;
33 import org.chromium.content.browser.ContentViewCore; 33 import org.chromium.content.browser.ContentViewCore;
34 import org.chromium.content.browser.NavigationClient;
35 import org.chromium.content.browser.WebContentsObserver; 34 import org.chromium.content.browser.WebContentsObserver;
36 import org.chromium.content_public.browser.LoadUrlParams; 35 import org.chromium.content_public.browser.LoadUrlParams;
37 import org.chromium.content_public.browser.NavigationHistory;
38 import org.chromium.content_public.browser.WebContents; 36 import org.chromium.content_public.browser.WebContents;
39 import org.chromium.ui.base.Clipboard; 37 import org.chromium.ui.base.Clipboard;
40 import org.chromium.ui.base.WindowAndroid; 38 import org.chromium.ui.base.WindowAndroid;
41 39
42 import java.util.concurrent.atomic.AtomicInteger; 40 import java.util.concurrent.atomic.AtomicInteger;
43 41
44 /** 42 /**
45 * The basic Java representation of a tab. Contains and manages a {@link Conten tView}. 43 * The basic Java representation of a tab. Contains and manages a {@link Conten tView}.
46 * 44 *
47 * Tab provides common functionality for ChromeShell Tab as well as Chrome on An droid's 45 * Tab provides common functionality for ChromeShell Tab as well as Chrome on An droid's
(...skipping 17 matching lines...) Expand all
65 * to the parameter passed to that method. This should be used when doing thin gs like loading 63 * to the parameter passed to that method. This should be used when doing thin gs like loading
66 * persisted {@link Tab}s from disk on process start to ensure all new {@link T ab}s don't have id 64 * persisted {@link Tab}s from disk on process start to ensure all new {@link T ab}s don't have id
67 * collision. 65 * collision.
68 * Some {@link Activity}s will not call this because they do not persist stat e, which means those 66 * Some {@link Activity}s will not call this because they do not persist stat e, which means those
69 * ids can potentially conflict with the ones restored from persisted state dep ending on which 67 * ids can potentially conflict with the ones restored from persisted state dep ending on which
70 * {@link Activity} runs first on process start. If {@link Tab}s are ever shar ed across 68 * {@link Activity} runs first on process start. If {@link Tab}s are ever shar ed across
71 * {@link Activity}s or mixed with {@link Tab}s from other {@link Activity}s co nflicts can occur 69 * {@link Activity}s or mixed with {@link Tab}s from other {@link Activity}s co nflicts can occur
72 * unless special care is taken to make sure {@link Tab#incrementIdCounterTo(in t)} is called with 70 * unless special care is taken to make sure {@link Tab#incrementIdCounterTo(in t)} is called with
73 * the correct value across all affected {@link Activity}s. 71 * the correct value across all affected {@link Activity}s.
74 */ 72 */
75 public class Tab implements NavigationClient { 73 public class Tab {
76 public static final int INVALID_TAB_ID = -1; 74 public static final int INVALID_TAB_ID = -1;
77 75
78 /** Used for automatically generating tab ids. */ 76 /** Used for automatically generating tab ids. */
79 private static final AtomicInteger sIdCounter = new AtomicInteger(); 77 private static final AtomicInteger sIdCounter = new AtomicInteger();
80 78
81 private long mNativeTabAndroid; 79 private long mNativeTabAndroid;
82 80
83 /** Unique id of this tab (within its container). */ 81 /** Unique id of this tab (within its container). */
84 private final int mId; 82 private final int mId;
85 83
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 if (getWebContents() != null) getWebContents().getNavigationController() .goBack(); 400 if (getWebContents() != null) getWebContents().getNavigationController() .goBack();
403 } 401 }
404 402
405 /** 403 /**
406 * Goes to the navigation entry after the current one. 404 * Goes to the navigation entry after the current one.
407 */ 405 */
408 public void goForward() { 406 public void goForward() {
409 if (getWebContents() != null) getWebContents().getNavigationController() .goForward(); 407 if (getWebContents() != null) getWebContents().getNavigationController() .goForward();
410 } 408 }
411 409
412 @Override
413 public NavigationHistory getDirectedNavigationHistory(boolean isForward, int itemLimit) {
414 if (getWebContents() != null) {
415 return getWebContents().getNavigationController()
416 .getDirectedNavigationHistory(isForward, itemLimit);
417 } else {
418 return new NavigationHistory();
419 }
420 }
421
422 @Override
423 public void goToNavigationIndex(int index) {
424 if (getWebContents() != null) {
425 getWebContents().getNavigationController().goToNavigationIndex(index );
426 }
427 }
428
429 /** 410 /**
430 * Loads the current navigation if there is a pending lazy load (after tab r estore). 411 * Loads the current navigation if there is a pending lazy load (after tab r estore).
431 */ 412 */
432 public void loadIfNecessary() { 413 public void loadIfNecessary() {
433 if (getWebContents() != null) getWebContents().getNavigationController() .loadIfNecessary(); 414 if (getWebContents() != null) getWebContents().getNavigationController() .loadIfNecessary();
434 } 415 }
435 416
436 /** 417 /**
437 * Requests the current navigation to be loaded upon the next call to loadIf Necessary(). 418 * Requests the current navigation to be loaded upon the next call to loadIf Necessary().
438 */ 419 */
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 private native Profile nativeGetProfileAndroid(long nativeTabAndroid); 1208 private native Profile nativeGetProfileAndroid(long nativeTabAndroid);
1228 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e xtraHeaders, 1209 private native int nativeLoadUrl(long nativeTabAndroid, String url, String e xtraHeaders,
1229 byte[] postData, int transition, String referrerUrl, int referrerPol icy, 1210 byte[] postData, int transition, String referrerUrl, int referrerPol icy,
1230 boolean isRendererInitiated); 1211 boolean isRendererInitiated);
1231 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url, 1212 private native void nativeSetActiveNavigationEntryTitleForUrl(long nativeTab Android, String url,
1232 String title); 1213 String title);
1233 private native boolean nativePrint(long nativeTabAndroid); 1214 private native boolean nativePrint(long nativeTabAndroid);
1234 private native Bitmap nativeGetFavicon(long nativeTabAndroid); 1215 private native Bitmap nativeGetFavicon(long nativeTabAndroid);
1235 private native boolean nativeIsFaviconValid(long nativeTabAndroid); 1216 private native boolean nativeIsFaviconValid(long nativeTabAndroid);
1236 } 1217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698