Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchBarControl.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchBarControl.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchBarControl.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9fec723e91f8c2cb5ca8849eac82101bea3ba0c1 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchBarControl.java |
@@ -0,0 +1,79 @@ |
+// 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.compositor.bottombar.contextualsearch; |
+ |
+import android.content.Context; |
+import android.view.ViewGroup; |
+ |
+import org.chromium.ui.resources.dynamics.DynamicResourceLoader; |
+ |
+/** |
+ * Controls the Search Bar in the Contextual Search Panel. |
+ */ |
+public class ContextualSearchBarControl { |
+ /** |
+ * The {@link ContextualSearchContextControl} used to control the Search Context View. |
+ */ |
+ private final ContextualSearchContextControl mContextControl; |
+ |
+ /** |
+ * The {@link ContextualSearchTermControl} used to control the Search Term View. |
+ */ |
+ private final ContextualSearchTermControl mSearchTermControl; |
+ |
+ /** |
+ * Constructs a new bottom bar control container by inflating views from XML. |
+ * |
+ * @param panel The panel delegate. |
+ * @param context The context used to build this view. |
+ * @param container The parent view for the bottom bar views. |
+ * @param loader The resource loader that will handle the snapshot capturing. |
+ */ |
+ public ContextualSearchBarControl(ContextualSearchPanelDelegate panel, Context context, |
+ ViewGroup container, DynamicResourceLoader loader) { |
+ mContextControl = new ContextualSearchContextControl(panel, context, container, loader); |
+ mSearchTermControl = new ContextualSearchTermControl(panel, context, container, loader); |
+ } |
+ |
+ /** |
+ * Removes the bottom bar views from the parent container. |
+ */ |
+ public void destroy() { |
+ mContextControl.destroy(); |
+ mSearchTermControl.destroy(); |
+ } |
+ |
+ /** |
+ * Sets the search context to display in the control. |
+ * @param selection The portion of the context that represents the user's selection. |
+ * @param start The portion of the context before the selection. |
+ * @param end The portion of the context after the selection. |
+ */ |
+ public void setSearchContext(String selection, String start, String end) { |
+ mContextControl.setSearchContext(selection, start, end); |
+ } |
+ |
+ /** |
+ * Sets the search term to display in the control. |
+ * @param searchTerm The string that represents the search term. |
+ */ |
+ public void setSearchTerm(String searchTerm) { |
+ mSearchTermControl.setSearchTerm(searchTerm); |
+ } |
+ |
+ /** |
+ * @return The Id of the Search Context View. |
+ */ |
+ public int getSearchContextViewId() { |
+ return mContextControl.getViewId(); |
+ } |
+ |
+ /** |
+ * @return The Id of the Search Term View. |
+ */ |
+ public int getSearchTermViewId() { |
+ return mSearchTermControl.getViewId(); |
+ } |
+} |