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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IncognitoNewTabPageView.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/IncognitoNewTabPageView.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IncognitoNewTabPageView.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IncognitoNewTabPageView.java
new file mode 100644
index 0000000000000000000000000000000000000000..819b18874cef85c55a410bc6bef13fe23a516283
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IncognitoNewTabPageView.java
@@ -0,0 +1,109 @@
+// 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.util.AttributeSet;
+import android.view.View;
+import android.widget.FrameLayout;
+
+import com.google.android.apps.chrome.R;
+
+import org.chromium.chrome.browser.util.ViewUtils;
+
+/**
+ * The New Tab Page for use in the incognito profile.
+ */
+public class IncognitoNewTabPageView extends FrameLayout {
+
+ private IncognitoNewTabPageManager mManager;
+ private boolean mFirstShow = true;
+ private NewTabScrollView mScrollView;
+
+ private int mSnapshotWidth;
+ private int mSnapshotHeight;
+ private int mSnapshotScrollY;
+
+ /**
+ * Manages the view interaction with the rest of the system.
+ */
+ interface IncognitoNewTabPageManager {
+ /** Loads a page explaining details about incognito mode in the current tab. */
+ void loadIncognitoLearnMore();
+
+ /**
+ * Called when the NTP has completely finished loading (all views will be inflated
+ * and any dependent resources will have been loaded).
+ */
+ void onLoadingComplete();
+ }
+
+ /** Default constructor needed to inflate via XML. */
+ public IncognitoNewTabPageView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+
+ mScrollView = (NewTabScrollView) findViewById(R.id.ntp_scrollview);
+
+ // FOCUS_BEFORE_DESCENDANTS is needed to support keyboard shortcuts. Otherwise, pressing
+ // any shortcut causes the UrlBar to be focused. See ViewRootImpl.leaveTouchMode().
+ mScrollView.setDescendantFocusability(FOCUS_BEFORE_DESCENDANTS);
+
+ View learnMore = findViewById(R.id.learn_more);
+ learnMore.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mManager.loadIncognitoLearnMore();
+ }
+ });
+ }
+
+ /**
+ * Initialize the incognito New Tab Page.
+ * @param manager The manager that handles external dependencies of the view.
+ */
+ void initialize(IncognitoNewTabPageManager manager) {
+ mManager = manager;
+ }
+
+ /**
+ * @see org.chromium.chrome.browser.compositor.layouts.content.
+ * InvalidationAwareThumbnailProvider#shouldCaptureThumbnail()
+ */
+ boolean shouldCaptureThumbnail() {
+ if (getWidth() == 0 || getHeight() == 0) return false;
+
+ return getWidth() != mSnapshotWidth
+ || getHeight() != mSnapshotHeight
+ || mScrollView.getScrollY() != mSnapshotScrollY;
+ }
+
+ /**
+ * @see org.chromium.chrome.browser.compositor.layouts.content.
+ * InvalidationAwareThumbnailProvider#captureThumbnail(Canvas)
+ */
+ void captureThumbnail(Canvas canvas) {
+ ViewUtils.captureBitmap(this, canvas);
+ mSnapshotWidth = getWidth();
+ mSnapshotHeight = getHeight();
+ mSnapshotScrollY = mScrollView.getScrollY();
+ }
+
+ // OnAttachStateChangeListener overrides
+
+ @Override
+ public void onAttachedToWindow() {
+ assert mManager != null;
+ if (mFirstShow) {
+ mManager.onLoadingComplete();
+ mFirstShow = false;
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698