| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/autocomplete/history_url_provider.h" | 5 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete_field_trial.h" | 17 #include "chrome/browser/autocomplete/autocomplete_field_trial.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_match.h" | 18 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 19 #include "chrome/browser/history/history.h" | 19 #include "chrome/browser/history/history.h" |
| 20 #include "chrome/browser/history/history_backend.h" | 20 #include "chrome/browser/history/history_backend.h" |
| 21 #include "chrome/browser/history/history_database.h" | 21 #include "chrome/browser/history/history_database.h" |
| 22 #include "chrome/browser/history/history_types.h" | 22 #include "chrome/browser/history/history_types.h" |
| 23 #include "chrome/browser/net/url_fixer_upper.h" | 23 #include "chrome/browser/net/url_fixer_upper.h" |
| 24 #include "chrome/browser/prefs/pref_service.h" | 24 #include "chrome/browser/prefs/pref_service.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 29 #include "content/public/browser/browser_thread.h" |
| 29 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
| 30 #include "googleurl/src/url_parse.h" | 31 #include "googleurl/src/url_parse.h" |
| 31 #include "googleurl/src/url_util.h" | 32 #include "googleurl/src/url_util.h" |
| 32 #include "net/base/net_util.h" | 33 #include "net/base/net_util.h" |
| 33 #include "net/base/registry_controlled_domain.h" | 34 #include "net/base/registry_controlled_domain.h" |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 // Ensures that |matches| contains an entry for |info|, which may mean adding a | 38 // Ensures that |matches| contains an entry for |info|, which may mean adding a |
| 38 // new such entry (using |input_location| and |match_in_scheme|). | 39 // new such entry (using |input_location| and |match_in_scheme|). |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // Either: switch_value == switches::kOmniboxAggressiveHistoryURLAuto | 341 // Either: switch_value == switches::kOmniboxAggressiveHistoryURLAuto |
| 341 // or someone passed an invalid command line flag. We'll default | 342 // or someone passed an invalid command line flag. We'll default |
| 342 // the latter case to automatic but report an error. | 343 // the latter case to automatic but report an error. |
| 343 if (!switch_value.empty() && | 344 if (!switch_value.empty() && |
| 344 (switch_value != switches::kOmniboxAggressiveHistoryURLAuto)) { | 345 (switch_value != switches::kOmniboxAggressiveHistoryURLAuto)) { |
| 345 LOG(ERROR) << "Invalid --omnibox-aggressive-with-history-url option " | 346 LOG(ERROR) << "Invalid --omnibox-aggressive-with-history-url option " |
| 346 << "received on command line: " << switch_value; | 347 << "received on command line: " << switch_value; |
| 347 LOG(ERROR) << "Making automatic."; | 348 LOG(ERROR) << "Making automatic."; |
| 348 } | 349 } |
| 349 // Automatic means eligible for the field trial. | 350 // Automatic means eligible for the field trial. |
| 351 // For the field trial stuff to work correctly, we must be running |
| 352 // on the same thread as the thread that created the field trial, |
| 353 // which happens via a call to AutocompleteFieldTrial::Active in |
| 354 // chrome_browser_main.cc on the main thread. Let's check this to |
| 355 // be sure. We check "if we've heard of the UI thread then we'd better |
| 356 // be on it." The first part is necessary so unit tests pass. (Many |
| 357 // unit tests don't set up the threading naming system; hence |
| 358 // CurrentlyOn(UI thread) will fail.) |
| 359 DCHECK(!content::BrowserThread::IsWellKnownThread( |
| 360 content::BrowserThread::UI) || |
| 361 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 350 if (AutocompleteFieldTrial::InAggressiveHUPFieldTrial()) { | 362 if (AutocompleteFieldTrial::InAggressiveHUPFieldTrial()) { |
| 351 if (AutocompleteFieldTrial::InAggressiveHUPFieldTrialExperimentGroup()) { | 363 if (AutocompleteFieldTrial::InAggressiveHUPFieldTrialExperimentGroup()) { |
| 352 enable_aggressive_scoring_ = true; | 364 enable_aggressive_scoring_ = true; |
| 353 aggressiveness_option = AGGRESSIVENESS_FIELD_TRIAL_EXPERIMENT_GROUP; | 365 aggressiveness_option = AGGRESSIVENESS_FIELD_TRIAL_EXPERIMENT_GROUP; |
| 354 } else { | 366 } else { |
| 355 enable_aggressive_scoring_ = false; | 367 enable_aggressive_scoring_ = false; |
| 356 aggressiveness_option = AGGRESSIVENESS_FIELD_TRIAL_DEFAULT_GROUP; | 368 aggressiveness_option = AGGRESSIVENESS_FIELD_TRIAL_DEFAULT_GROUP; |
| 357 } | 369 } |
| 358 } else { | 370 } else { |
| 359 enable_aggressive_scoring_ = false; | 371 enable_aggressive_scoring_ = false; |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 &match.contents_class); | 1009 &match.contents_class); |
| 998 } | 1010 } |
| 999 match.description = info.title(); | 1011 match.description = info.title(); |
| 1000 AutocompleteMatch::ClassifyMatchInString(params->input.text(), | 1012 AutocompleteMatch::ClassifyMatchInString(params->input.text(), |
| 1001 info.title(), | 1013 info.title(), |
| 1002 ACMatchClassification::NONE, | 1014 ACMatchClassification::NONE, |
| 1003 &match.description_class); | 1015 &match.description_class); |
| 1004 | 1016 |
| 1005 return match; | 1017 return match; |
| 1006 } | 1018 } |
| OLD | NEW |