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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTabHelper.java

Issue 1416173006: Start using a themed application context for constructing views in Tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: made mTab final Created 5 years, 2 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTabHelper.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTabHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTabHelper.java
index 0947286c7fde754b3bb9217fbaa1d0d7bfa97e29..4081bf20d4aa240a92a12fbb17044e579bbe58ad 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTabHelper.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTabHelper.java
@@ -4,6 +4,8 @@
package org.chromium.chrome.browser.contextualsearch;
+import android.app.Activity;
+
import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChangeReason;
@@ -43,6 +45,8 @@ public class ContextualSearchTabHelper extends EmptyTabObserver {
private long mNativeHelper = 0;
+ private final Tab mTab;
+
/**
* Creates a contextual search tab helper for the given tab.
* @param tab The tab whose contextual search actions will be handled by this helper.
@@ -52,6 +56,7 @@ public class ContextualSearchTabHelper extends EmptyTabObserver {
}
private ContextualSearchTabHelper(Tab tab) {
+ mTab = tab;
tab.addObserver(this);
}
@@ -161,7 +166,7 @@ public class ContextualSearchTabHelper extends EmptyTabObserver {
/**
* @return whether Contextual Search is enabled and active in this tab.
*/
- private static boolean isContextualSearchActive(ContentViewCore cvc) {
+ private boolean isContextualSearchActive(ContentViewCore cvc) {
return !cvc.getWebContents().isIncognito() && getContextualSearchManager(cvc) != null
&& !PrefServiceBridge.getInstance().isContextualSearchDisabled()
&& TemplateUrlService.getInstance().isDefaultSearchEngineGoogle()
@@ -175,10 +180,10 @@ public class ContextualSearchTabHelper extends EmptyTabObserver {
/**
* @return the Contextual Search manager.
*/
- private static ContextualSearchManager getContextualSearchManager(ContentViewCore cvc) {
- // TODO(yfriedman): Decouple this from the activity.
- if (cvc.getContext() instanceof ChromeActivity) {
- return ((ChromeActivity) cvc.getContext()).getContextualSearchManager();
+ private ContextualSearchManager getContextualSearchManager(ContentViewCore cvc) {
+ Activity activity = mTab.getWindowAndroid().getActivity().get();
+ if (activity instanceof ChromeActivity) {
+ return ((ChromeActivity) activity).getContextualSearchManager();
}
return null;
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698