OLD | NEW |
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/contextualsearch/contextual_search_pa
nel.h" | 5 #include "chrome/browser/android/bottombar/contextualsearch/contextual_search_pa
nel.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" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 web_contents_->SetDelegate(web_contents_delegate_.get()); | 110 web_contents_->SetDelegate(web_contents_delegate_.get()); |
111 } | 111 } |
112 | 112 |
113 void ContextualSearchPanel::DestroyWebContents(JNIEnv* env, jobject jobj) { | 113 void ContextualSearchPanel::DestroyWebContents(JNIEnv* env, jobject jobj) { |
114 DCHECK(web_contents_.get()); | 114 DCHECK(web_contents_.get()); |
115 web_contents_.reset(); | 115 web_contents_.reset(); |
116 // |web_contents_delegate_| may already be NULL at this point. | 116 // |web_contents_delegate_| may already be NULL at this point. |
117 web_contents_delegate_.reset(); | 117 web_contents_delegate_.reset(); |
118 } | 118 } |
119 | 119 |
120 void ContextualSearchPanel::ReleaseWebContents(JNIEnv* env, jobject jboj) { | |
121 DCHECK(web_contents_.get()); | |
122 web_contents_delegate_.reset(); | |
123 ignore_result(web_contents_.release()); | |
124 } | |
125 | |
126 void ContextualSearchPanel::SetInterceptNavigationDelegate( | 120 void ContextualSearchPanel::SetInterceptNavigationDelegate( |
127 JNIEnv* env, | 121 JNIEnv* env, |
128 jobject obj, | 122 jobject obj, |
129 jobject delegate, | 123 jobject delegate, |
130 jobject jweb_contents) { | 124 jobject jweb_contents) { |
131 content::WebContents* web_contents = | 125 content::WebContents* web_contents = |
132 content::WebContents::FromJavaWebContents(jweb_contents); | 126 content::WebContents::FromJavaWebContents(jweb_contents); |
133 DCHECK(web_contents); | 127 DCHECK(web_contents); |
134 navigation_interception::InterceptNavigationDelegate::Associate( | 128 navigation_interception::InterceptNavigationDelegate::Associate( |
135 web_contents, | 129 web_contents, |
136 make_scoped_ptr(new navigation_interception::InterceptNavigationDelegate( | 130 make_scoped_ptr(new navigation_interception::InterceptNavigationDelegate( |
137 env, delegate))); | 131 env, delegate))); |
138 } | 132 } |
139 | 133 |
140 bool RegisterContextualSearchPanel(JNIEnv* env) { | 134 bool RegisterContextualSearchPanel(JNIEnv* env) { |
141 return RegisterNativesImpl(env); | 135 return RegisterNativesImpl(env); |
142 } | 136 } |
143 | 137 |
144 jlong Init(JNIEnv* env, jobject obj) { | 138 jlong Init(JNIEnv* env, jobject obj) { |
145 ContextualSearchPanel* manager = new ContextualSearchPanel(env, obj); | 139 ContextualSearchPanel* manager = new ContextualSearchPanel(env, obj); |
146 return reinterpret_cast<intptr_t>(manager); | 140 return reinterpret_cast<intptr_t>(manager); |
147 } | 141 } |
OLD | NEW |