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

Side by Side Diff: chrome/browser/android/bottombar/overlay_panel_content.cc

Issue 1385663002: [Contextual Search] Add Mojo-enabled API component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed the CS API controller to not be a notification observer. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/bottombar/overlay_panel_content.h" 5 #include "chrome/browser/android/bottombar/overlay_panel_content.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "chrome/browser/android/tab_android.h" 13 #include "chrome/browser/android/tab_android.h"
14 #include "chrome/browser/history/history_service_factory.h" 14 #include "chrome/browser/history/history_service_factory.h"
15 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/search_engines/template_url_service_factory.h" 16 #include "chrome/browser/search_engines/template_url_service_factory.h"
17 #include "chrome/browser/ui/android/window_android_helper.h" 17 #include "chrome/browser/ui/android/window_android_helper.h"
18 #include "components/history/core/browser/history_service.h" 18 #include "components/history/core/browser/history_service.h"
19 #include "components/navigation_interception/intercept_navigation_delegate.h" 19 #include "components/navigation_interception/intercept_navigation_delegate.h"
20 #include "components/variations/variations_associated_data.h" 20 #include "components/variations/variations_associated_data.h"
21 #include "components/web_contents_delegate_android/web_contents_delegate_android .h" 21 #include "components/web_contents_delegate_android/web_contents_delegate_android .h"
22 #include "content/public/browser/android/content_view_core.h" 22 #include "content/public/browser/android/content_view_core.h"
23 #include "content/public/browser/render_process_host.h"
23 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
24 #include "jni/OverlayPanelContent_jni.h" 25 #include "jni/OverlayPanelContent_jni.h"
25 #include "net/url_request/url_fetcher_impl.h" 26 #include "net/url_request/url_fetcher_impl.h"
26 27
27 using content::ContentViewCore; 28 using content::ContentViewCore;
28 29
29 namespace { 30 namespace {
30 31
31 const int kHistoryDeletionWindowSeconds = 2; 32 const int kHistoryDeletionWindowSeconds = 2;
32 33
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // to a real tab. 101 // to a real tab.
101 TabAndroid::AttachTabHelpers(web_contents_.get()); 102 TabAndroid::AttachTabHelpers(web_contents_.get());
102 WindowAndroidHelper::FromWebContents(web_contents_.get()) 103 WindowAndroidHelper::FromWebContents(web_contents_.get())
103 ->SetWindowAndroid(content_view_core->GetWindowAndroid()); 104 ->SetWindowAndroid(content_view_core->GetWindowAndroid());
104 web_contents_delegate_.reset( 105 web_contents_delegate_.reset(
105 new web_contents_delegate_android::WebContentsDelegateAndroid( 106 new web_contents_delegate_android::WebContentsDelegateAndroid(
106 env, jweb_contents_delegate)); 107 env, jweb_contents_delegate));
107 web_contents_->SetDelegate(web_contents_delegate_.get()); 108 web_contents_->SetDelegate(web_contents_delegate_.get());
108 } 109 }
109 110
110 void OverlayPanelContent::DestroyWebContents(JNIEnv* env, jobject jobj) { 111 int OverlayPanelContent::DestroyWebContents(JNIEnv* env, jobject jobj) {
111 DCHECK(web_contents_.get()); 112 DCHECK(web_contents_.get());
113 int host_id = web_contents_->GetRenderProcessHost()->GetID();
112 web_contents_.reset(); 114 web_contents_.reset();
113 // |web_contents_delegate_| may already be NULL at this point. 115 // |web_contents_delegate_| may already be NULL at this point.
114 web_contents_delegate_.reset(); 116 web_contents_delegate_.reset();
117 return host_id;
115 } 118 }
116 119
117 void OverlayPanelContent::SetInterceptNavigationDelegate( 120 void OverlayPanelContent::SetInterceptNavigationDelegate(
118 JNIEnv* env, 121 JNIEnv* env,
119 jobject obj, 122 jobject obj,
120 jobject delegate, 123 jobject delegate,
121 jobject jweb_contents) { 124 jobject jweb_contents) {
122 content::WebContents* web_contents = 125 content::WebContents* web_contents =
123 content::WebContents::FromJavaWebContents(jweb_contents); 126 content::WebContents::FromJavaWebContents(jweb_contents);
124 DCHECK(web_contents); 127 DCHECK(web_contents);
125 navigation_interception::InterceptNavigationDelegate::Associate( 128 navigation_interception::InterceptNavigationDelegate::Associate(
126 web_contents, 129 web_contents,
127 make_scoped_ptr(new navigation_interception::InterceptNavigationDelegate( 130 make_scoped_ptr(new navigation_interception::InterceptNavigationDelegate(
128 env, delegate))); 131 env, delegate)));
129 } 132 }
130 133
131 bool RegisterOverlayPanelContent(JNIEnv* env) { 134 bool RegisterOverlayPanelContent(JNIEnv* env) {
132 return RegisterNativesImpl(env); 135 return RegisterNativesImpl(env);
133 } 136 }
134 137
135 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 138 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
136 OverlayPanelContent* content = new OverlayPanelContent(env, obj); 139 OverlayPanelContent* content = new OverlayPanelContent(env, obj);
137 return reinterpret_cast<intptr_t>(content); 140 return reinterpret_cast<intptr_t>(content);
138 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698