1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_ANDROID_BOTTOMBAR_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_PANEL_H_
6 #define CHROME_BROWSER_ANDROID_BOTTOMBAR_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_PANEL_H_
8 #include "base/android/jni_android.h"
9 #include "base/task/cancelable_task_tracker.h"
10 #include "chrome/browser/android/contextualsearch/contextual_search_context.h"
14 } // namespace content
16 namespace web_contents_delegate_android
{
17 class WebContentsDelegateAndroid
;
18 } // namespace web_contents_delegate_android
20 // Manages the native extraction and request logic for Contextual Search,
21 // and interacts with the Java ContextualSearchPanel for UX.
22 // Most of the work is done by the associated ContextualSearchDelegate.
23 class ContextualSearchPanel
{
25 // Constructs a native manager associated with the Java manager.
26 ContextualSearchPanel(JNIEnv
* env
, jobject obj
);
27 virtual ~ContextualSearchPanel();
29 // Called by the Java ContextualSearchPanel when it is being destroyed.
30 void Destroy(JNIEnv
* env
, jobject obj
);
32 // Removes a search URL from history. |search_start_time_ms| represents the
33 // time at which |search_url| was committed.
34 void RemoveLastHistoryEntry(JNIEnv
* env
,
37 jlong search_start_time_ms
);
39 // Takes ownership of the WebContents associated with the given
40 // |ContentViewCore| which holds the Contextual Search Results.
41 void SetWebContents(JNIEnv
* env
, jobject obj
, jobject jcontent_view_core
,
42 jobject jweb_contents_delegate
);
44 // Destroys the WebContents.
45 void DestroyWebContents(JNIEnv
* env
, jobject jobj
);
47 // Sets the delegate used to convert navigations to intents.
48 void SetInterceptNavigationDelegate(JNIEnv
* env
,
51 jobject jweb_contents
);
54 // Our global reference to the Java ContextualSearchPanel.
55 base::android::ScopedJavaGlobalRef
<jobject
> java_manager_
;
57 // Used if we need to clear history.
58 base::CancelableTaskTracker history_task_tracker_
;
60 // The WebContents that holds the panel content.
61 scoped_ptr
<content::WebContents
> web_contents_
;
62 scoped_ptr
<web_contents_delegate_android::WebContentsDelegateAndroid
>
63 web_contents_delegate_
;
65 DISALLOW_COPY_AND_ASSIGN(ContextualSearchPanel
);
68 bool RegisterContextualSearchPanel(JNIEnv
* env
);
70 #endif // CHROME_BROWSER_ANDROID_BOTTOMBAR_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_PANEL_H_