| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/instant/instant_controller.h" | 5 #include "chrome/browser/instant/instant_controller.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 std::vector<InstantAutocompleteResult> results; | 384 std::vector<InstantAutocompleteResult> results; |
| 385 for (ACProviders::const_iterator provider = providers.begin(); | 385 for (ACProviders::const_iterator provider = providers.begin(); |
| 386 provider != providers.end(); ++provider) { | 386 provider != providers.end(); ++provider) { |
| 387 for (ACMatches::const_iterator match = (*provider)->matches().begin(); | 387 for (ACMatches::const_iterator match = (*provider)->matches().begin(); |
| 388 match != (*provider)->matches().end(); ++match) { | 388 match != (*provider)->matches().end(); ++match) { |
| 389 InstantAutocompleteResult result; | 389 InstantAutocompleteResult result; |
| 390 result.provider = UTF8ToUTF16((*provider)->GetName()); | 390 result.provider = UTF8ToUTF16((*provider)->GetName()); |
| 391 result.type = UTF8ToUTF16(AutocompleteMatch::TypeToString(match->type)); | 391 result.type = UTF8ToUTF16(AutocompleteMatch::TypeToString(match->type)); |
| 392 result.description = match->description; | 392 result.description = match->description; |
| 393 result.destination_url = UTF8ToUTF16(match->destination_url.spec()); | 393 result.destination_url = UTF8ToUTF16(match->destination_url.spec()); |
| 394 result.transition = match->transition; |
| 394 result.relevance = match->relevance; | 395 result.relevance = match->relevance; |
| 395 DVLOG(1) << " " << result.relevance << " " << result.type << " " | 396 DVLOG(1) << " " << result.relevance << " " << result.type << " " |
| 396 << result.provider << " " << result.destination_url << " '" | 397 << result.provider << " " << result.destination_url << " '" |
| 397 << result.description << "'"; | 398 << result.description << "'"; |
| 398 results.push_back(result); | 399 results.push_back(result); |
| 399 } | 400 } |
| 400 } | 401 } |
| 401 | 402 |
| 402 if (instant_tab_) | 403 if (instant_tab_) |
| 403 instant_tab_->SendAutocompleteResults(results); | 404 instant_tab_->SendAutocompleteResults(results); |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 HideLoader(); | 834 HideLoader(); |
| 834 #else | 835 #else |
| 835 if (IsViewInContents(GetViewGainingFocus(view_gaining_focus), | 836 if (IsViewInContents(GetViewGainingFocus(view_gaining_focus), |
| 836 loader_->contents())) | 837 loader_->contents())) |
| 837 CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); | 838 CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); |
| 838 else | 839 else |
| 839 HideLoader(); | 840 HideLoader(); |
| 840 #endif | 841 #endif |
| 841 } | 842 } |
| 842 | 843 |
| 844 void InstantController::NavigateToURL(const GURL& url, |
| 845 content::PageTransition transition) { |
| 846 if (!extended_enabled_) |
| 847 return; |
| 848 if (loader_) |
| 849 HideLoader(); |
| 850 browser_->OpenURLInCurrentTab(url, transition); |
| 851 } |
| 852 |
| 843 bool InstantController::ResetLoader(const TemplateURL* template_url, | 853 bool InstantController::ResetLoader(const TemplateURL* template_url, |
| 844 const content::WebContents* active_tab) { | 854 const content::WebContents* active_tab) { |
| 845 std::string instant_url; | 855 std::string instant_url; |
| 846 if (!GetInstantURL(template_url, &instant_url)) | 856 if (!GetInstantURL(template_url, &instant_url)) |
| 847 return false; | 857 return false; |
| 848 | 858 |
| 849 if (loader_ && loader_->instant_url() == instant_url) | 859 if (loader_ && loader_->instant_url() == instant_url) |
| 850 return true; | 860 return true; |
| 851 | 861 |
| 852 HideInternal(); | 862 HideInternal(); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 } | 1098 } |
| 1089 | 1099 |
| 1090 std::map<std::string, int>::const_iterator iter = | 1100 std::map<std::string, int>::const_iterator iter = |
| 1091 blacklisted_urls_.find(*instant_url); | 1101 blacklisted_urls_.find(*instant_url); |
| 1092 if (iter != blacklisted_urls_.end() && | 1102 if (iter != blacklisted_urls_.end() && |
| 1093 iter->second > kMaxInstantSupportFailures) | 1103 iter->second > kMaxInstantSupportFailures) |
| 1094 return false; | 1104 return false; |
| 1095 | 1105 |
| 1096 return true; | 1106 return true; |
| 1097 } | 1107 } |
| OLD | NEW |