| 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/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" | |
| 12 #include "chrome/browser/instant/instant_field_trial.h" | 11 #include "chrome/browser/instant/instant_field_trial.h" |
| 13 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 14 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 15 | 14 |
| 16 #if defined(ENABLE_RLZ) | 15 #if defined(ENABLE_RLZ) |
| 17 #include "chrome/browser/google/google_util.h" | 16 #include "chrome/browser/google/google_util.h" |
| 18 #include "chrome/browser/rlz/rlz.h" | 17 #include "chrome/browser/rlz/rlz.h" |
| 19 #endif | 18 #endif |
| 20 | 19 |
| 21 using content::BrowserThread; | 20 using content::BrowserThread; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #if defined(ENABLE_RLZ) | 56 #if defined(ENABLE_RLZ) |
| 58 string16 SearchTermsData::GetRlzParameterValue() const { | 57 string16 SearchTermsData::GetRlzParameterValue() const { |
| 59 return string16(); | 58 return string16(); |
| 60 } | 59 } |
| 61 #endif | 60 #endif |
| 62 | 61 |
| 63 std::string SearchTermsData::InstantEnabledParam() const { | 62 std::string SearchTermsData::InstantEnabledParam() const { |
| 64 return std::string(); | 63 return std::string(); |
| 65 } | 64 } |
| 66 | 65 |
| 67 std::string SearchTermsData::InstantFieldTrialUrlParam() const { | |
| 68 return std::string(); | |
| 69 } | |
| 70 | |
| 71 // static | 66 // static |
| 72 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; | 67 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; |
| 73 | 68 |
| 74 UIThreadSearchTermsData::UIThreadSearchTermsData() : profile_(NULL) { | 69 UIThreadSearchTermsData::UIThreadSearchTermsData() : profile_(NULL) { |
| 75 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 70 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
| 76 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 71 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 77 } | 72 } |
| 78 | 73 |
| 79 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { | 74 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { |
| 80 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 75 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
| (...skipping 23 matching lines...) Expand all Loading... |
| 104 // search might not send the RLZ data but this is not really a problem. | 99 // search might not send the RLZ data but this is not really a problem. |
| 105 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz_string); | 100 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz_string); |
| 106 } | 101 } |
| 107 return rlz_string; | 102 return rlz_string; |
| 108 } | 103 } |
| 109 #endif | 104 #endif |
| 110 | 105 |
| 111 std::string UIThreadSearchTermsData::InstantEnabledParam() const { | 106 std::string UIThreadSearchTermsData::InstantEnabledParam() const { |
| 112 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 107 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
| 113 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 108 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 114 return (profile_ && InstantController::IsEnabled(profile_) && | 109 return InstantFieldTrial::GetMode(profile_) == InstantFieldTrial::INSTANT ? |
| 115 !InstantFieldTrial::IsHiddenExperiment(profile_)) ? | |
| 116 "&ion=1" : std::string(); | 110 "&ion=1" : std::string(); |
| 117 } | 111 } |
| 118 | 112 |
| 119 std::string UIThreadSearchTermsData::InstantFieldTrialUrlParam() const { | |
| 120 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | |
| 121 BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 122 return InstantFieldTrial::GetGroupAsUrlParam(profile_); | |
| 123 } | |
| 124 | |
| 125 // static | 113 // static |
| 126 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 114 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
| 127 delete google_base_url_; | 115 delete google_base_url_; |
| 128 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); | 116 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); |
| 129 } | 117 } |
| OLD | NEW |