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

Side by Side Diff: chrome/browser/android/omnibox/autocomplete_controller_android.cc

Issue 1391893003: NOT FOR REVIEW: Aura on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/omnibox/autocomplete_controller_android.h" 5 #include "chrome/browser/android/omnibox/autocomplete_controller_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 void AutocompleteControllerAndroid::OnSuggestionSelected( 209 void AutocompleteControllerAndroid::OnSuggestionSelected(
210 JNIEnv* env, 210 JNIEnv* env,
211 jobject obj, 211 jobject obj,
212 jint selected_index, 212 jint selected_index,
213 jstring j_current_url, 213 jstring j_current_url,
214 jboolean is_query_in_omnibox, 214 jboolean is_query_in_omnibox,
215 jboolean focused_from_fakebox, 215 jboolean focused_from_fakebox,
216 jlong elapsed_time_since_first_modified, 216 jlong elapsed_time_since_first_modified,
217 jobject j_web_contents) { 217 jobject j_web_contents) {
218 #if !defined(USE_AURA)
218 base::string16 url = ConvertJavaStringToUTF16(env, j_current_url); 219 base::string16 url = ConvertJavaStringToUTF16(env, j_current_url);
219 const GURL current_url = GURL(url); 220 const GURL current_url = GURL(url);
220 OmniboxEventProto::PageClassification current_page_classification = 221 OmniboxEventProto::PageClassification current_page_classification =
221 ClassifyPage(current_url, is_query_in_omnibox, focused_from_fakebox); 222 ClassifyPage(current_url, is_query_in_omnibox, focused_from_fakebox);
222 const base::TimeTicks& now(base::TimeTicks::Now()); 223 const base::TimeTicks& now(base::TimeTicks::Now());
223 content::WebContents* web_contents = 224 content::WebContents* web_contents =
224 content::WebContents::FromJavaWebContents(j_web_contents); 225 content::WebContents::FromJavaWebContents(j_web_contents);
225 226
226 OmniboxLog log( 227 OmniboxLog log(
227 input_.text(), 228 input_.text(),
228 false, /* don't know */ 229 false, /* don't know */
229 input_.type(), 230 input_.type(),
230 true, 231 true,
231 selected_index, 232 selected_index,
232 false, 233 false,
233 SessionTabHelper::IdForTab(web_contents), 234 SessionTabHelper::IdForTab(web_contents),
234 current_page_classification, 235 current_page_classification,
235 base::TimeDelta::FromMilliseconds(elapsed_time_since_first_modified), 236 base::TimeDelta::FromMilliseconds(elapsed_time_since_first_modified),
236 base::string16::npos, 237 base::string16::npos,
237 now - autocomplete_controller_->last_time_default_match_changed(), 238 now - autocomplete_controller_->last_time_default_match_changed(),
238 autocomplete_controller_->result()); 239 autocomplete_controller_->result());
239 autocomplete_controller_->AddProvidersInfo(&log.providers_info); 240 autocomplete_controller_->AddProvidersInfo(&log.providers_info);
240 241
241 OmniboxEventGlobalTracker::GetInstance()->OnURLOpened(&log); 242 OmniboxEventGlobalTracker::GetInstance()->OnURLOpened(&log);
242 content::NotificationService::current()->Notify( 243 content::NotificationService::current()->Notify(
243 chrome::NOTIFICATION_OMNIBOX_OPENED_URL, 244 chrome::NOTIFICATION_OMNIBOX_OPENED_URL,
244 content::Source<Profile>(profile_), 245 content::Source<Profile>(profile_),
245 content::Details<OmniboxLog>(&log)); 246 content::Details<OmniboxLog>(&log));
247 #endif
246 } 248 }
247 249
248 void AutocompleteControllerAndroid::DeleteSuggestion(JNIEnv* env, 250 void AutocompleteControllerAndroid::DeleteSuggestion(JNIEnv* env,
249 jobject obj, 251 jobject obj,
250 int selected_index) { 252 int selected_index) {
251 const AutocompleteResult& result = autocomplete_controller_->result(); 253 const AutocompleteResult& result = autocomplete_controller_->result();
252 const AutocompleteMatch& match = result.match_at(selected_index); 254 const AutocompleteMatch& match = result.match_at(selected_index);
253 if (match.SupportsDeletion()) 255 if (match.SupportsDeletion())
254 autocomplete_controller_->DeleteMatch(match); 256 autocomplete_controller_->DeleteMatch(match);
255 } 257 }
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 return; 559 return;
558 560
559 // ZeroSuggestPrefetcher deletes itself after it's done prefetching. 561 // ZeroSuggestPrefetcher deletes itself after it's done prefetching.
560 new ZeroSuggestPrefetcher(profile); 562 new ZeroSuggestPrefetcher(profile);
561 } 563 }
562 564
563 // Register native methods 565 // Register native methods
564 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) { 566 bool RegisterAutocompleteControllerAndroid(JNIEnv* env) {
565 return RegisterNativesImpl(env); 567 return RegisterNativesImpl(env);
566 } 568 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698