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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IncognitoNewTabPage.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IncognitoNewTabPage.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IncognitoNewTabPage.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IncognitoNewTabPage.java
new file mode 100644
index 0000000000000000000000000000000000000000..3f0abcfb61d716554a4e218921ff54290d1b2752
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IncognitoNewTabPage.java
@@ -0,0 +1,123 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.ntp;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import com.google.android.apps.chrome.R;
+
+import org.chromium.base.VisibleForTesting;
+import org.chromium.chrome.browser.NativePage;
+import org.chromium.chrome.browser.Tab;
+import org.chromium.chrome.browser.UrlConstants;
+import org.chromium.chrome.browser.compositor.layouts.content.InvalidationAwareThumbnailProvider;
+import org.chromium.chrome.browser.ntp.IncognitoNewTabPageView.IncognitoNewTabPageManager;
+import org.chromium.content_public.browser.LoadUrlParams;
+
+/**
+ * Provides functionality when the user interacts with the Incognito NTP.
+ */
+public class IncognitoNewTabPage implements NativePage, InvalidationAwareThumbnailProvider {
+
+ private static final String LEARN_MORE_INCOGNITO_LINK =
+ "https://www.google.com/support/chrome/bin/answer.py?answer=95464";
+
+ private final Tab mTab;
+
+ private final String mTitle;
+ private final int mBackgroundColor;
+ private final IncognitoNewTabPageView mIncognitoNewTabPageView;
+
+ private boolean mIsLoaded;
+
+ private final IncognitoNewTabPageManager mIncognitoNewTabPageManager =
+ new IncognitoNewTabPageManager() {
+ @Override
+ public void loadIncognitoLearnMore() {
+ mTab.loadUrl(new LoadUrlParams(LEARN_MORE_INCOGNITO_LINK));
+ }
+
+ @Override
+ public void onLoadingComplete() {
+ mIsLoaded = true;
+ }
+ };
+
+ /**
+ * Constructs an Incognito NewTabPage.
+ * @param context The context used to create the new tab page's View.
+ * @param tab The Tab that is showing this new tab page.
+ */
+ public IncognitoNewTabPage(Context context, Tab tab) {
+ mTab = tab;
+
+ mTitle = context.getResources().getString(R.string.button_new_tab);
+ mBackgroundColor = context.getResources().getColor(R.color.ntp_bg_incognito);
+
+ LayoutInflater inflater = LayoutInflater.from(context);
+ mIncognitoNewTabPageView =
+ (IncognitoNewTabPageView) inflater.inflate(R.layout.new_tab_page_incognito, null);
+ mIncognitoNewTabPageView.initialize(mIncognitoNewTabPageManager);
+ }
+
+ /**
+ * @return Whether the NTP has finished loaded.
+ */
+ @VisibleForTesting
+ public boolean isLoadedForTests() {
+ return mIsLoaded;
+ }
+
+ // NativePage overrides
+
+ @Override
+ public void destroy() {
+ assert getView().getParent() == null : "Destroy called before removed from window";
+ }
+
+ @Override
+ public String getUrl() {
+ return UrlConstants.NTP_URL;
+ }
+
+ @Override
+ public String getTitle() {
+ return mTitle;
+ }
+
+ @Override
+ public int getBackgroundColor() {
+ return mBackgroundColor;
+ }
+
+ @Override
+ public View getView() {
+ return mIncognitoNewTabPageView;
+ }
+
+ @Override
+ public String getHost() {
+ return UrlConstants.NTP_HOST;
+ }
+
+ @Override
+ public void updateForUrl(String url) {
+ }
+
+ // InvalidationAwareThumbnailProvider
+
+ @Override
+ public boolean shouldCaptureThumbnail() {
+ return mIncognitoNewTabPageView.shouldCaptureThumbnail();
+ }
+
+ @Override
+ public void captureThumbnail(Canvas canvas) {
+ mIncognitoNewTabPageView.captureThumbnail(canvas);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698