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

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

Issue 1514833002: [Offline Pages on the NTP] Bypass the network interstitial (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@offline_badge
Patch Set: rebase Created 4 years, 11 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
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/offline_page_bridge.cc » ('j') | 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.ntp; 5 package org.chromium.chrome.browser.ntp;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.app.Activity; 8 import android.app.Activity;
9 import android.app.ActivityManager; 9 import android.app.ActivityManager;
10 import android.app.Dialog; 10 import android.app.Dialog;
(...skipping 28 matching lines...) Expand all
39 import org.chromium.chrome.browser.favicon.FaviconHelper.IconAvailabilityCallbac k; 39 import org.chromium.chrome.browser.favicon.FaviconHelper.IconAvailabilityCallbac k;
40 import org.chromium.chrome.browser.favicon.LargeIconBridge; 40 import org.chromium.chrome.browser.favicon.LargeIconBridge;
41 import org.chromium.chrome.browser.favicon.LargeIconBridge.LargeIconCallback; 41 import org.chromium.chrome.browser.favicon.LargeIconBridge.LargeIconCallback;
42 import org.chromium.chrome.browser.metrics.StartupMetrics; 42 import org.chromium.chrome.browser.metrics.StartupMetrics;
43 import org.chromium.chrome.browser.ntp.LogoBridge.Logo; 43 import org.chromium.chrome.browser.ntp.LogoBridge.Logo;
44 import org.chromium.chrome.browser.ntp.LogoBridge.LogoObserver; 44 import org.chromium.chrome.browser.ntp.LogoBridge.LogoObserver;
45 import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager; 45 import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager;
46 import org.chromium.chrome.browser.ntp.interests.InterestsPage; 46 import org.chromium.chrome.browser.ntp.interests.InterestsPage;
47 import org.chromium.chrome.browser.ntp.interests.InterestsPage.InterestsClickLis tener; 47 import org.chromium.chrome.browser.ntp.interests.InterestsPage.InterestsClickLis tener;
48 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; 48 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge;
49 import org.chromium.chrome.browser.offlinepages.OfflinePageItem;
50 import org.chromium.chrome.browser.offlinepages.OfflinePageUtils;
49 import org.chromium.chrome.browser.preferences.DocumentModeManager; 51 import org.chromium.chrome.browser.preferences.DocumentModeManager;
50 import org.chromium.chrome.browser.preferences.DocumentModePreference; 52 import org.chromium.chrome.browser.preferences.DocumentModePreference;
51 import org.chromium.chrome.browser.preferences.PrefServiceBridge; 53 import org.chromium.chrome.browser.preferences.PrefServiceBridge;
52 import org.chromium.chrome.browser.preferences.PreferencesLauncher; 54 import org.chromium.chrome.browser.preferences.PreferencesLauncher;
53 import org.chromium.chrome.browser.profiles.MostVisitedSites; 55 import org.chromium.chrome.browser.profiles.MostVisitedSites;
54 import org.chromium.chrome.browser.profiles.MostVisitedSites.MostVisitedURLsObse rver; 56 import org.chromium.chrome.browser.profiles.MostVisitedSites.MostVisitedURLsObse rver;
55 import org.chromium.chrome.browser.profiles.MostVisitedSites.ThumbnailCallback; 57 import org.chromium.chrome.browser.profiles.MostVisitedSites.ThumbnailCallback;
56 import org.chromium.chrome.browser.profiles.Profile; 58 import org.chromium.chrome.browser.profiles.Profile;
57 import org.chromium.chrome.browser.search_engines.TemplateUrlService; 59 import org.chromium.chrome.browser.search_engines.TemplateUrlService;
58 import org.chromium.chrome.browser.search_engines.TemplateUrlService.TemplateUrl ServiceObserver; 60 import org.chromium.chrome.browser.search_engines.TemplateUrlService.TemplateUrl ServiceObserver;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 return false; 322 return false;
321 } 323 }
322 324
323 private boolean matchURLs(String url1, String url2, boolean matchByHost) { 325 private boolean matchURLs(String url1, String url2, boolean matchByHost) {
324 if (url1 == null || url2 == null) return false; 326 if (url1 == null || url2 == null) return false;
325 return matchByHost ? UrlUtilities.sameHost(url1, url2) : url1.equals (url2); 327 return matchByHost ? UrlUtilities.sameHost(url1, url2) : url1.equals (url2);
326 } 328 }
327 329
328 @Override 330 @Override
329 public void open(String url) { 331 public void open(String url) {
332 if (!OfflinePageUtils.isConnected(mNewTabPageView.getContext()) && ! mIsDestroyed
newt (away) 2016/01/12 20:58:55 This seems like the wrong layer (too high) to be a
Marc Treib 2016/01/13 09:38:19 I don't think we want to do the automatic indirect
newt (away) 2016/01/13 22:05:12 Ok, I'll buy that distinction between navigation f
Marc Treib 2016/01/14 10:09:17 Done.
333 && OfflinePageBridge.isEnabled()) {
334 if (mOfflinePageBridge == null) {
335 mOfflinePageBridge = new OfflinePageBridge(mProfile);
336 }
337 OfflinePageItem offlineItem = mOfflinePageBridge.getPageByOnline URL(url);
338 if (offlineItem != null) {
339 mOfflinePageBridge.markPageAccessed(offlineItem.getBookmarkI d());
340 url = offlineItem.getOfflineUrl();
341 }
342 }
330 mTab.loadUrl(new LoadUrlParams(url, PageTransition.AUTO_BOOKMARK)); 343 mTab.loadUrl(new LoadUrlParams(url, PageTransition.AUTO_BOOKMARK));
331 } 344 }
332 345
333 @Override 346 @Override
334 public void onCreateContextMenu(ContextMenu menu, OnMenuItemClickListene r listener) { 347 public void onCreateContextMenu(ContextMenu menu, OnMenuItemClickListene r listener) {
335 if (mIsDestroyed) return; 348 if (mIsDestroyed) return;
336 menu.add(Menu.NONE, ID_OPEN_IN_NEW_TAB, Menu.NONE, R.string.contextm enu_open_in_new_tab) 349 menu.add(Menu.NONE, ID_OPEN_IN_NEW_TAB, Menu.NONE, R.string.contextm enu_open_in_new_tab)
337 .setOnMenuItemClickListener(listener); 350 .setOnMenuItemClickListener(listener);
338 if (PrefServiceBridge.getInstance().isIncognitoModeEnabled()) { 351 if (PrefServiceBridge.getInstance().isIncognitoModeEnabled()) {
339 menu.add(Menu.NONE, ID_OPEN_IN_INCOGNITO_TAB, Menu.NONE, 352 menu.add(Menu.NONE, ID_OPEN_IN_INCOGNITO_TAB, Menu.NONE,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 if (mIsDestroyed) return; 452 if (mIsDestroyed) return;
440 if (mFaviconHelper == null) mFaviconHelper = new FaviconHelper(); 453 if (mFaviconHelper == null) mFaviconHelper = new FaviconHelper();
441 mFaviconHelper.ensureIconIsAvailable( 454 mFaviconHelper.ensureIconIsAvailable(
442 mProfile, mTab.getWebContents(), pageUrl, iconUrl, isLargeIc on, callback); 455 mProfile, mTab.getWebContents(), pageUrl, iconUrl, isLargeIc on, callback);
443 } 456 }
444 457
445 @Override 458 @Override
446 public boolean isOfflineAvailable(String pageUrl) { 459 public boolean isOfflineAvailable(String pageUrl) {
447 if (mIsDestroyed || !OfflinePageBridge.isEnabled()) return false; 460 if (mIsDestroyed || !OfflinePageBridge.isEnabled()) return false;
448 if (mOfflinePageBridge == null) mOfflinePageBridge = new OfflinePage Bridge(mProfile); 461 if (mOfflinePageBridge == null) mOfflinePageBridge = new OfflinePage Bridge(mProfile);
449 return mOfflinePageBridge.getPageByOnlineURL(pageUrl) != null; 462 return mOfflinePageBridge.getOfflineUrlForOnlineUrl(pageUrl) != null ;
450 } 463 }
451 464
452 @Override 465 @Override
453 public void onLogoClicked(boolean isAnimatedLogoShowing) { 466 public void onLogoClicked(boolean isAnimatedLogoShowing) {
454 if (mIsDestroyed) return; 467 if (mIsDestroyed) return;
455 468
456 if (!isAnimatedLogoShowing && mAnimatedLogoUrl != null) { 469 if (!isAnimatedLogoShowing && mAnimatedLogoUrl != null) {
457 mNewTabPageView.showLogoLoadingView(); 470 mNewTabPageView.showLogoLoadingView();
458 mLogoBridge.getAnimatedLogo(new LogoBridge.AnimatedLogoCallback( ) { 471 mLogoBridge.getAnimatedLogo(new LogoBridge.AnimatedLogoCallback( ) {
459 @Override 472 @Override
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 @Override 766 @Override
754 public boolean shouldCaptureThumbnail() { 767 public boolean shouldCaptureThumbnail() {
755 return mNewTabPageView.shouldCaptureThumbnail(); 768 return mNewTabPageView.shouldCaptureThumbnail();
756 } 769 }
757 770
758 @Override 771 @Override
759 public void captureThumbnail(Canvas canvas) { 772 public void captureThumbnail(Canvas canvas) {
760 mNewTabPageView.captureThumbnail(canvas); 773 mNewTabPageView.captureThumbnail(canvas);
761 } 774 }
762 } 775 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/offline_pages/offline_page_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698