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

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

Issue 2235533002: Revert "Changed NavigationController access to through tab in Java code" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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.tab; 5 package org.chromium.chrome.browser.tab;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.app.Application; 8 import android.app.Application;
9 import android.content.Context; 9 import android.content.Context;
10 import android.content.Intent; 10 import android.content.Intent;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; 59 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator;
60 import org.chromium.chrome.browser.contextualsearch.ContextualSearchTabHelper; 60 import org.chromium.chrome.browser.contextualsearch.ContextualSearchTabHelper;
61 import org.chromium.chrome.browser.crash.MinidumpDirectoryObserver; 61 import org.chromium.chrome.browser.crash.MinidumpDirectoryObserver;
62 import org.chromium.chrome.browser.crash.MinidumpUploadService; 62 import org.chromium.chrome.browser.crash.MinidumpUploadService;
63 import org.chromium.chrome.browser.customtabs.CustomTabActivity; 63 import org.chromium.chrome.browser.customtabs.CustomTabActivity;
64 import org.chromium.chrome.browser.download.ChromeDownloadDelegate; 64 import org.chromium.chrome.browser.download.ChromeDownloadDelegate;
65 import org.chromium.chrome.browser.fullscreen.FullscreenManager; 65 import org.chromium.chrome.browser.fullscreen.FullscreenManager;
66 import org.chromium.chrome.browser.help.HelpAndFeedback; 66 import org.chromium.chrome.browser.help.HelpAndFeedback;
67 import org.chromium.chrome.browser.infobar.InfoBarContainer; 67 import org.chromium.chrome.browser.infobar.InfoBarContainer;
68 import org.chromium.chrome.browser.media.ui.MediaSessionTabHelper; 68 import org.chromium.chrome.browser.media.ui.MediaSessionTabHelper;
69 import org.chromium.chrome.browser.navigation.NavigationHandler;
70 import org.chromium.chrome.browser.navigation.TabWebContentsNavigationHandler;
71 import org.chromium.chrome.browser.ntp.NativePageAssassin; 69 import org.chromium.chrome.browser.ntp.NativePageAssassin;
72 import org.chromium.chrome.browser.ntp.NativePageFactory; 70 import org.chromium.chrome.browser.ntp.NativePageFactory;
73 import org.chromium.chrome.browser.omnibox.geo.GeolocationHeader; 71 import org.chromium.chrome.browser.omnibox.geo.GeolocationHeader;
74 import org.chromium.chrome.browser.policy.PolicyAuditor; 72 import org.chromium.chrome.browser.policy.PolicyAuditor;
75 import org.chromium.chrome.browser.prerender.ExternalPrerenderHandler; 73 import org.chromium.chrome.browser.prerender.ExternalPrerenderHandler;
76 import org.chromium.chrome.browser.printing.TabPrinter; 74 import org.chromium.chrome.browser.printing.TabPrinter;
77 import org.chromium.chrome.browser.profiles.Profile; 75 import org.chromium.chrome.browser.profiles.Profile;
78 import org.chromium.chrome.browser.rlz.RevenueStats; 76 import org.chromium.chrome.browser.rlz.RevenueStats;
79 import org.chromium.chrome.browser.search_engines.TemplateUrlService; 77 import org.chromium.chrome.browser.search_engines.TemplateUrlService;
80 import org.chromium.chrome.browser.snackbar.LofiBarController; 78 import org.chromium.chrome.browser.snackbar.LofiBarController;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 379
382 private ChromeDownloadDelegate mDownloadDelegate; 380 private ChromeDownloadDelegate mDownloadDelegate;
383 381
384 protected Handler mHandler; 382 protected Handler mHandler;
385 383
386 private LofiBarController mLoFiBarController; 384 private LofiBarController mLoFiBarController;
387 385
388 /** Whether or not the tab closing the tab can send the user back to the app that opened it. */ 386 /** Whether or not the tab closing the tab can send the user back to the app that opened it. */
389 private boolean mIsAllowedToReturnToExternalApp; 387 private boolean mIsAllowedToReturnToExternalApp;
390 388
391 private NavigationHandler mNavigationHandler;
392
393 /**
394 * Method to access navigation handler for a tab.
395 * @return navigation handler.
396 */
397 public NavigationHandler getNavigationHandler() {
398 return mNavigationHandler;
399 }
400
401 private class TabContentViewClient extends ContentViewClient { 389 private class TabContentViewClient extends ContentViewClient {
402 @Override 390 @Override
403 public void onBackgroundColorChanged(int color) { 391 public void onBackgroundColorChanged(int color) {
404 Tab.this.onBackgroundColorChanged(color); 392 Tab.this.onBackgroundColorChanged(color);
405 } 393 }
406 394
407 @Override 395 @Override
408 public void onOffsetsForFullscreenChanged( 396 public void onOffsetsForFullscreenChanged(
409 float topControlsOffsetY, float contentOffsetY) { 397 float topControlsOffsetY, float contentOffsetY) {
410 onOffsetsChanged(topControlsOffsetY, contentOffsetY, isShowingSadTab ()); 398 onOffsetsChanged(topControlsOffsetY, contentOffsetY, isShowingSadTab ());
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 * @param observer The {@link TabObserver} to remove. 727 * @param observer The {@link TabObserver} to remove.
740 */ 728 */
741 public void removeObserver(TabObserver observer) { 729 public void removeObserver(TabObserver observer) {
742 mObservers.removeObserver(observer); 730 mObservers.removeObserver(observer);
743 } 731 }
744 732
745 /** 733 /**
746 * @return Whether or not this tab has a previous navigation entry. 734 * @return Whether or not this tab has a previous navigation entry.
747 */ 735 */
748 public boolean canGoBack() { 736 public boolean canGoBack() {
749 return getNavigationHandler() != null && getNavigationHandler().canGoBac k(); 737 return getWebContents() != null && getWebContents().getNavigationControl ler().canGoBack();
750 } 738 }
751 739
752 /** 740 /**
753 * @return Whether or not this tab has a navigation entry after the current one. 741 * @return Whether or not this tab has a navigation entry after the current one.
754 */ 742 */
755 public boolean canGoForward() { 743 public boolean canGoForward() {
756 return getNavigationHandler() != null && getNavigationHandler().canGoFor ward(); 744 return getWebContents() != null && getWebContents().getNavigationControl ler()
745 .canGoForward();
757 } 746 }
758 747
759 /** 748 /**
760 * Goes to the navigation entry before the current one. 749 * Goes to the navigation entry before the current one.
761 */ 750 */
762 public void goBack() { 751 public void goBack() {
763 if (getNavigationHandler() != null) getNavigationHandler().goBack(); 752 if (getWebContents() != null) getWebContents().getNavigationController() .goBack();
764 } 753 }
765 754
766 /** 755 /**
767 * Goes to the navigation entry after the current one. 756 * Goes to the navigation entry after the current one.
768 */ 757 */
769 public void goForward() { 758 public void goForward() {
770 if (getNavigationHandler() != null) getNavigationHandler().goForward(); 759 if (getWebContents() != null) getWebContents().getNavigationController() .goForward();
771 } 760 }
772 761
773 /** 762 /**
774 * Loads the current navigation if there is a pending lazy load (after tab r estore). 763 * Loads the current navigation if there is a pending lazy load (after tab r estore).
775 */ 764 */
776 public void loadIfNecessary() { 765 public void loadIfNecessary() {
777 if (getNavigationHandler() != null) getNavigationHandler().loadIfNecessa ry(); 766 if (getWebContents() != null) getWebContents().getNavigationController() .loadIfNecessary();
778 } 767 }
779 768
780 /** 769 /**
781 * Requests the current navigation to be loaded upon the next call to loadIf Necessary(). 770 * Requests the current navigation to be loaded upon the next call to loadIf Necessary().
782 */ 771 */
783 protected void requestRestoreLoad() { 772 protected void requestRestoreLoad() {
784 if (getNavigationHandler() != null) { 773 if (getWebContents() != null) {
785 getNavigationHandler().requestRestoreLoad(); 774 getWebContents().getNavigationController().requestRestoreLoad();
786 } 775 }
787 } 776 }
788 777
789 /** 778 /**
790 * Causes this tab to navigate to the specified URL. 779 * Causes this tab to navigate to the specified URL.
791 * @param params parameters describing the url load. Note that it is importa nt to set correct 780 * @param params parameters describing the url load. Note that it is importa nt to set correct
792 * page transition as it is used for ranking URLs in the histo ry so the omnibox 781 * page transition as it is used for ranking URLs in the histo ry so the omnibox
793 * can report suggestions correctly. 782 * can report suggestions correctly.
794 * @return FULL_PRERENDERED_PAGE_LOAD or PARTIAL_PRERENDERED_PAGE_LOAD if th e page has been 783 * @return FULL_PRERENDERED_PAGE_LOAD or PARTIAL_PRERENDERED_PAGE_LOAD if th e page has been
795 * prerendered. DEFAULT_PAGE_LOAD if it had not. 784 * prerendered. DEFAULT_PAGE_LOAD if it had not.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 984
996 printingController.setPendingPrint(new TabPrinter(this), 985 printingController.setPendingPrint(new TabPrinter(this),
997 new PrintManagerDelegateImpl(getActivity())); 986 new PrintManagerDelegateImpl(getActivity()));
998 } 987 }
999 988
1000 /** 989 /**
1001 * Reloads the current page content. 990 * Reloads the current page content.
1002 */ 991 */
1003 public void reload() { 992 public void reload() {
1004 // TODO(dtrainor): Should we try to rebuild the ContentView if it's froz en? 993 // TODO(dtrainor): Should we try to rebuild the ContentView if it's froz en?
1005 if (getNavigationHandler() != null) getNavigationHandler().reload(true); 994 if (getWebContents() != null) getWebContents().getNavigationController() .reload(true);
1006 } 995 }
1007 996
1008 /** 997 /**
1009 * Reloads the current page content. 998 * Reloads the current page content.
1010 * This version ignores the cache and reloads from the network. 999 * This version ignores the cache and reloads from the network.
1011 */ 1000 */
1012 public void reloadIgnoringCache() { 1001 public void reloadIgnoringCache() {
1013 if (getNavigationHandler() != null) { 1002 if (getWebContents() != null) {
1014 getNavigationHandler().reloadBypassingCache(true); 1003 getWebContents().getNavigationController().reloadBypassingCache(true );
1015 } 1004 }
1016 } 1005 }
1017 1006
1018 /** 1007 /**
1019 * Reloads the current page content with Lo-Fi off. 1008 * Reloads the current page content with Lo-Fi off.
1020 * This version ignores the cache and reloads from the network. 1009 * This version ignores the cache and reloads from the network.
1021 */ 1010 */
1022 public void reloadDisableLoFi() { 1011 public void reloadDisableLoFi() {
1023 if (getNavigationHandler() != null) { 1012 if (getWebContents() != null) {
1024 getNavigationHandler().reloadDisableLoFi(true); 1013 getWebContents().getNavigationController().reloadDisableLoFi(true);
1025 } 1014 }
1026 } 1015 }
1027 1016
1028 /** 1017 /**
1029 * Reloads all the Lo-Fi images in this Tab's WebContents. 1018 * Reloads all the Lo-Fi images in this Tab's WebContents.
1030 * This version ignores the cache and reloads from the network. 1019 * This version ignores the cache and reloads from the network.
1031 */ 1020 */
1032 public void reloadLoFiImages() { 1021 public void reloadLoFiImages() {
1033 if (getWebContents() != null) { 1022 if (getWebContents() != null) {
1034 getWebContents().reloadLoFiImages(); 1023 getWebContents().reloadLoFiImages();
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 return mNativePage != null; 1180 return mNativePage != null;
1192 } 1181 }
1193 1182
1194 /** 1183 /**
1195 * Set whether or not the {@link ContentViewCore} should be using a desktop user agent for the 1184 * Set whether or not the {@link ContentViewCore} should be using a desktop user agent for the
1196 * currently loaded page. 1185 * currently loaded page.
1197 * @param useDesktop If {@code true}, use a desktop user agent. Otherwi se use a mobile one. 1186 * @param useDesktop If {@code true}, use a desktop user agent. Otherwi se use a mobile one.
1198 * @param reloadOnChange Reload the page if the user agent has changed. 1187 * @param reloadOnChange Reload the page if the user agent has changed.
1199 */ 1188 */
1200 public void setUseDesktopUserAgent(boolean useDesktop, boolean reloadOnChang e) { 1189 public void setUseDesktopUserAgent(boolean useDesktop, boolean reloadOnChang e) {
1201 if (getNavigationHandler() != null) { 1190 if (getWebContents() != null) {
1202 getNavigationHandler().setUseDesktopUserAgent(useDesktop, reloadOnCh ange); 1191 getWebContents().getNavigationController()
1192 .setUseDesktopUserAgent(useDesktop, reloadOnChange);
1203 } 1193 }
1204 } 1194 }
1205 1195
1206 /** 1196 /**
1207 * @return Whether or not the {@link ContentViewCore} is using a desktop use r agent. 1197 * @return Whether or not the {@link ContentViewCore} is using a desktop use r agent.
1208 */ 1198 */
1209 public boolean getUseDesktopUserAgent() { 1199 public boolean getUseDesktopUserAgent() {
1210 return getNavigationHandler() != null 1200 return getWebContents() != null && getWebContents().getNavigationControl ler()
1211 && getNavigationHandler().getUseDesktopUserAgent(); 1201 .getUseDesktopUserAgent();
1212 } 1202 }
1213 1203
1214 /** 1204 /**
1215 * @return The current {@link ConnectionSecurityLevel} for the tab. 1205 * @return The current {@link ConnectionSecurityLevel} for the tab.
1216 */ 1206 */
1217 // TODO(tedchoc): Remove this and transition all clients to use ToolbarModel directly. 1207 // TODO(tedchoc): Remove this and transition all clients to use ToolbarModel directly.
1218 public int getSecurityLevel() { 1208 public int getSecurityLevel() {
1219 return SecurityStateModel.getSecurityLevelForWebContents(getWebContents( )); 1209 return SecurityStateModel.getSecurityLevelForWebContents(getWebContents( ));
1220 } 1210 }
1221 1211
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 } 1845 }
1856 1846
1857 mDownloadDelegate = new ChromeDownloadDelegate(mThemedApplicationCon text, this); 1847 mDownloadDelegate = new ChromeDownloadDelegate(mThemedApplicationCon text, this);
1858 1848
1859 assert mNativeTabAndroid != 0; 1849 assert mNativeTabAndroid != 0;
1860 nativeInitWebContents(mNativeTabAndroid, mIncognito, mContentViewCor e.getWebContents(), 1850 nativeInitWebContents(mNativeTabAndroid, mIncognito, mContentViewCor e.getWebContents(),
1861 mWebContentsDelegate, 1851 mWebContentsDelegate,
1862 new TabContextMenuPopulator( 1852 new TabContextMenuPopulator(
1863 mDelegateFactory.createContextMenuPopulator(this), t his)); 1853 mDelegateFactory.createContextMenuPopulator(this), t his));
1864 1854
1865 // TODO(shaktisahu): Add logic for blimp version of navigation handl er.
1866 mNavigationHandler = new TabWebContentsNavigationHandler(getWebConte nts());
1867
1868 // In the case where restoring a Tab or showing a prerendered one we already have a 1855 // In the case where restoring a Tab or showing a prerendered one we already have a
1869 // valid infobar container, no need to recreate one. 1856 // valid infobar container, no need to recreate one.
1870 if (mInfoBarContainer == null) { 1857 if (mInfoBarContainer == null) {
1871 // The InfoBarContainer needs to be created after the ContentVie w has been natively 1858 // The InfoBarContainer needs to be created after the ContentVie w has been natively
1872 // initialized. 1859 // initialized.
1873 mInfoBarContainer = new InfoBarContainer( 1860 mInfoBarContainer = new InfoBarContainer(
1874 mThemedApplicationContext, getId(), mContentViewParent, this); 1861 mThemedApplicationContext, getId(), mContentViewParent, this);
1875 } else { 1862 } else {
1876 mInfoBarContainer.onParentViewChanged(getId(), mContentViewParen t); 1863 mInfoBarContainer.onParentViewChanged(getId(), mContentViewParen t);
1877 } 1864 }
1878 mInfoBarContainer.setContentViewCore(mContentViewCore); 1865 mInfoBarContainer.setContentViewCore(mContentViewCore);
1879 1866
1880 mSwipeRefreshHandler = new SwipeRefreshHandler(mThemedApplicationCon text); 1867 mSwipeRefreshHandler = new SwipeRefreshHandler(mThemedApplicationCon text);
1881 mSwipeRefreshHandler.setContentViewCore(mContentViewCore, getNavigat ionHandler()); 1868 mSwipeRefreshHandler.setContentViewCore(mContentViewCore);
1882 1869
1883 updateThemeColorIfNeeded(false); 1870 updateThemeColorIfNeeded(false);
1884 notifyContentChanged(); 1871 notifyContentChanged();
1885 1872
1886 // For browser tabs, we want to set accessibility focus to the page 1873 // For browser tabs, we want to set accessibility focus to the page
1887 // when it loads. This is not the default behavior for embedded 1874 // when it loads. This is not the default behavior for embedded
1888 // web views. 1875 // web views.
1889 mContentViewCore.setShouldSetAccessibilityFocusOnPageLoad(true); 1876 mContentViewCore.setShouldSetAccessibilityFocusOnPageLoad(true);
1890 1877
1891 setInterceptNavigationDelegate(mDelegateFactory.createInterceptNavig ationDelegate( 1878 setInterceptNavigationDelegate(mDelegateFactory.createInterceptNavig ationDelegate(
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 mContentViewCore.getContainerView().setOnSystemUiVisibilityChangeListene r(null); 2359 mContentViewCore.getContainerView().setOnSystemUiVisibilityChangeListene r(null);
2373 if (mGestureStateListener != null) { 2360 if (mGestureStateListener != null) {
2374 mContentViewCore.removeGestureStateListener(mGestureStateListener); 2361 mContentViewCore.removeGestureStateListener(mGestureStateListener);
2375 } 2362 }
2376 2363
2377 if (mInfoBarContainer != null && mInfoBarContainer.getParent() != null) { 2364 if (mInfoBarContainer != null && mInfoBarContainer.getParent() != null) {
2378 mInfoBarContainer.removeFromParentView(); 2365 mInfoBarContainer.removeFromParentView();
2379 mInfoBarContainer.setContentViewCore(null); 2366 mInfoBarContainer.setContentViewCore(null);
2380 } 2367 }
2381 if (mSwipeRefreshHandler != null) { 2368 if (mSwipeRefreshHandler != null) {
2382 mSwipeRefreshHandler.setContentViewCore(null, null); 2369 mSwipeRefreshHandler.setContentViewCore(null);
2383 mSwipeRefreshHandler = null; 2370 mSwipeRefreshHandler = null;
2384 } 2371 }
2385
2386 mNavigationHandler = null;
2387
2388 mContentViewParent = null; 2372 mContentViewParent = null;
2389 mContentViewCore.destroy(); 2373 mContentViewCore.destroy();
2390 mContentViewCore = null; 2374 mContentViewCore = null;
2391 2375
2392 mWebContentsDelegate = null; 2376 mWebContentsDelegate = null;
2393 2377
2394 if (mWebContentsObserver != null) { 2378 if (mWebContentsObserver != null) {
2395 mWebContentsObserver.destroy(); 2379 mWebContentsObserver.destroy();
2396 mWebContentsObserver = null; 2380 mWebContentsObserver = null;
2397 } 2381 }
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
3290 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, 3274 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id,
3291 InterceptNavigationDelegate delegate); 3275 InterceptNavigationDelegate delegate);
3292 private native void nativeAttachToTabContentManager(long nativeTabAndroid, 3276 private native void nativeAttachToTabContentManager(long nativeTabAndroid,
3293 TabContentManager tabContentManager); 3277 TabContentManager tabContentManager);
3294 private native void nativeAttachOverlayWebContents( 3278 private native void nativeAttachOverlayWebContents(
3295 long nativeTabAndroid, WebContents webContents, boolean visible); 3279 long nativeTabAndroid, WebContents webContents, boolean visible);
3296 private native void nativeDetachOverlayWebContents( 3280 private native void nativeDetachOverlayWebContents(
3297 long nativeTabAndroid, WebContents webContents); 3281 long nativeTabAndroid, WebContents webContents);
3298 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); 3282 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url);
3299 } 3283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698