| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/search_engines/search_terms_data.h" | 5 #include "chrome/browser/search_engines/search_terms_data.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/google/google_url_tracker.h" | 10 #include "chrome/browser/google/google_url_tracker.h" |
| 11 #include "chrome/browser/instant/instant_controller.h" |
| 11 #include "chrome/browser/instant/instant_field_trial.h" | 12 #include "chrome/browser/instant/instant_field_trial.h" |
| 12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 14 | 15 |
| 15 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 16 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
| 16 #include "chrome/browser/google/google_util.h" | 17 #include "chrome/browser/google/google_util.h" |
| 17 #include "chrome/browser/rlz/rlz.h" | 18 #include "chrome/browser/rlz/rlz.h" |
| 18 #endif | 19 #endif |
| 19 | 20 |
| 20 using content::BrowserThread; | 21 using content::BrowserThread; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 38 // a variable. | 39 // a variable. |
| 39 const std::string suggest_path("/complete/"); | 40 const std::string suggest_path("/complete/"); |
| 40 repl.SetPathStr(suggest_path); | 41 repl.SetPathStr(suggest_path); |
| 41 | 42 |
| 42 // Clear the query and ref. | 43 // Clear the query and ref. |
| 43 repl.ClearQuery(); | 44 repl.ClearQuery(); |
| 44 repl.ClearRef(); | 45 repl.ClearRef(); |
| 45 return base_url.ReplaceComponents(repl).spec(); | 46 return base_url.ReplaceComponents(repl).spec(); |
| 46 } | 47 } |
| 47 | 48 |
| 49 std::string SearchTermsData::InstantEnabledParam() const { |
| 50 return std::string(); |
| 51 } |
| 52 |
| 48 std::string SearchTermsData::InstantFieldTrialUrlParam() const { | 53 std::string SearchTermsData::InstantFieldTrialUrlParam() const { |
| 49 return std::string(); | 54 return std::string(); |
| 50 } | 55 } |
| 51 | 56 |
| 52 // static | 57 // static |
| 53 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; | 58 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; |
| 54 | 59 |
| 55 UIThreadSearchTermsData::UIThreadSearchTermsData() : profile_(NULL) { | 60 UIThreadSearchTermsData::UIThreadSearchTermsData() : profile_(NULL) { |
| 56 // GoogleURLTracker::GoogleURL() DCHECKs this also, but adding it here helps | 61 // GoogleURLTracker::GoogleURL() DCHECKs this also, but adding it here helps |
| 57 // us catch bad behavior at a more common place in this code. | 62 // us catch bad behavior at a more common place in this code. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 84 !google_util::IsOrganic(brand)) { | 89 !google_util::IsOrganic(brand)) { |
| 85 // This call will return false the first time(s) it is called until the | 90 // This call will return false the first time(s) it is called until the |
| 86 // value has been cached. This normally would mean that at most one omnibox | 91 // value has been cached. This normally would mean that at most one omnibox |
| 87 // search might not send the RLZ data but this is not really a problem. | 92 // search might not send the RLZ data but this is not really a problem. |
| 88 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz_string); | 93 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz_string); |
| 89 } | 94 } |
| 90 return rlz_string; | 95 return rlz_string; |
| 91 } | 96 } |
| 92 #endif | 97 #endif |
| 93 | 98 |
| 99 std::string UIThreadSearchTermsData::InstantEnabledParam() const { |
| 100 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
| 101 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 102 if (profile_ && InstantController::IsEnabled(profile_) && |
| 103 !InstantFieldTrial::IsHiddenExperiment(profile_)) { |
| 104 return "&ion=1"; |
| 105 } |
| 106 return std::string(); |
| 107 } |
| 108 |
| 94 std::string UIThreadSearchTermsData::InstantFieldTrialUrlParam() const { | 109 std::string UIThreadSearchTermsData::InstantFieldTrialUrlParam() const { |
| 95 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 110 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
| 96 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 111 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 97 return InstantFieldTrial::GetGroupAsUrlParam(profile_); | 112 return InstantFieldTrial::GetGroupAsUrlParam(profile_); |
| 98 } | 113 } |
| 99 | 114 |
| 100 // static | 115 // static |
| 101 void UIThreadSearchTermsData::SetGoogleBaseURL(std::string* google_base_url) { | 116 void UIThreadSearchTermsData::SetGoogleBaseURL(std::string* google_base_url) { |
| 102 delete google_base_url_; | 117 delete google_base_url_; |
| 103 google_base_url_ = google_base_url; | 118 google_base_url_ = google_base_url; |
| 104 } | 119 } |
| OLD | NEW |