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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java

Issue 1283223004: Contextual Search Panel should own ContentViewCore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Override wrappers instead of native Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java
index b5d17b51641b132e647e2283c383bd2c0c778b3f..b13f30c6dcd1d7dac97ef5d0b7b303df58d4a7aa 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java
@@ -7,7 +7,12 @@ package org.chromium.chrome.browser.compositor.bottombar.contextualsearch;
import android.content.Context;
import android.os.Handler;
+import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.compositor.layouts.LayoutUpdateHost;
+import org.chromium.components.navigation_interception.InterceptNavigationDelegate;
+import org.chromium.components.web_contents_delegate_android.WebContentsDelegateAndroid;
+import org.chromium.content.browser.ContentViewCore;
+import org.chromium.content_public.browser.WebContents;
/**
* Controls the Contextual Search Panel.
@@ -51,6 +56,16 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation
}
/**
+ * The ContentViewCore that this panel will display.
+ */
+ private ContentViewCore mContentViewCore;
+
+ /**
+ * The pointer to the native version of this class.
+ */
+ private long mNativeContextualSearchPanelPtr;
+
+ /**
* The delay after which the hide progress will be hidden.
*/
private static final long HIDE_PROGRESS_BAR_DELAY = 1000 / 60 * 4;
@@ -90,6 +105,7 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation
*/
public ContextualSearchPanel(Context context, LayoutUpdateHost updateHost) {
super(context, updateHost);
+ nativeInit();
}
// ============================================================================================
@@ -508,4 +524,75 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation
public boolean shouldAnimatePanelCloseOnPromoteToTab() {
return mSearchPanelFeatures.shouldAnimatePanelCloseOnPromoteToTab();
}
+
+ // ============================================================================================
+ // Methods for managing this panel's ContentViewCore.
+ // ============================================================================================
+
+ @CalledByNative
+ public void clearNativePanelContentPtr() {
+ assert mNativeContextualSearchPanelPtr != 0;
+ mNativeContextualSearchPanelPtr = 0;
+ }
+
+ @CalledByNative
+ public void setNativePanelContentPtr(long nativePtr) {
+ assert mNativeContextualSearchPanelPtr == 0;
+ mNativeContextualSearchPanelPtr = nativePtr;
+ }
+
+ @Override
+ public ContentViewCore getContentViewCore() {
+ return mContentViewCore;
+ }
+
+ public void resetContentViewCore() {
+ // TODO(mdjones): Merge all code related to deleting/resetting the ContentViewCore.
+ mContentViewCore = null;
+ }
+
+ @Override
+ public void destroy() {
+ nativeDestroy(mNativeContextualSearchPanelPtr);
+ }
+
+ @Override
+ public void removeLastHistoryEntry(String historyUrl, long urlTimeMs) {
+ nativeRemoveLastHistoryEntry(mNativeContextualSearchPanelPtr, historyUrl, urlTimeMs);
+ }
+
+ @Override
+ public void setWebContents(ContentViewCore contentView, WebContentsDelegateAndroid delegate) {
+ mContentViewCore = contentView;
+ nativeSetWebContents(mNativeContextualSearchPanelPtr, contentView, delegate);
+ }
+
+ @Override
+ public void destroyWebContents() {
+ nativeDestroyWebContents(mNativeContextualSearchPanelPtr);
+ }
+
+ @Override
+ public void releaseWebContents() {
+ nativeReleaseWebContents(mNativeContextualSearchPanelPtr);
+ }
+
+ @Override
+ public void setInterceptNavigationDelegate(
+ InterceptNavigationDelegate delegate, WebContents webContents) {
+ nativeSetInterceptNavigationDelegate(mNativeContextualSearchPanelPtr,
+ delegate, webContents);
+ }
+
+ // Native calls.
+ protected native long nativeInit();
+ private native void nativeDestroy(long nativeContextualSearchPanel);
+ private native void nativeRemoveLastHistoryEntry(
+ long nativeContextualSearchPanel, String historyUrl, long urlTimeMs);
+ private native void nativeSetWebContents(long nativeContextualSearchPanel,
+ ContentViewCore contentViewCore, WebContentsDelegateAndroid delegate);
+ private native void nativeDestroyWebContents(long nativeContextualSearchPanel);
+ private native void nativeReleaseWebContents(long nativeContextualSearchPanel);
+ private native void nativeSetInterceptNavigationDelegate(long nativeContextualSearchPanel,
+ InterceptNavigationDelegate delegate, WebContents webContents);
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelAnimation.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698