| 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/search_engines/search_terms_data.h" | 5 #include "chrome/browser/search_engines/search_terms_data.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 8 #include "base/logging.h" | 7 #include "base/logging.h" |
| 9 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 10 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 11 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 12 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/google/google_url_tracker.h" | 12 #include "chrome/browser/google/google_url_tracker.h" |
| 14 #include "chrome/browser/google/google_util.h" | 13 #include "chrome/browser/google/google_util.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/search/search.h" | 15 #include "chrome/browser/search/search.h" |
| 17 #include "chrome/browser/themes/theme_service.h" | 16 #include "chrome/browser/themes/theme_service.h" |
| 18 #include "chrome/browser/themes/theme_service_factory.h" | 17 #include "chrome/browser/themes/theme_service_factory.h" |
| 19 #include "chrome/common/chrome_switches.h" | |
| 20 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 21 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 22 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
| 23 | 21 |
| 24 #if defined(ENABLE_RLZ) | 22 #if defined(ENABLE_RLZ) |
| 25 #include "chrome/browser/rlz/rlz.h" | 23 #include "chrome/browser/rlz/rlz.h" |
| 26 #endif | 24 #endif |
| 27 | 25 |
| 28 using content::BrowserThread; | 26 using content::BrowserThread; |
| 29 | 27 |
| 30 SearchTermsData::SearchTermsData() { | 28 SearchTermsData::SearchTermsData() { |
| 31 } | 29 } |
| 32 | 30 |
| 33 SearchTermsData::~SearchTermsData() { | 31 SearchTermsData::~SearchTermsData() { |
| 34 } | 32 } |
| 35 | 33 |
| 36 std::string SearchTermsData::GoogleBaseURLValue() const { | 34 std::string SearchTermsData::GoogleBaseURLValue() const { |
| 37 return GoogleURLTracker::kDefaultGoogleHomepage; | 35 return GoogleURLTracker::kDefaultGoogleHomepage; |
| 38 } | 36 } |
| 39 | 37 |
| 40 std::string SearchTermsData::GoogleBaseSuggestURLValue() const { | 38 std::string SearchTermsData::GoogleBaseSuggestURLValue() const { |
| 41 std::string base_suggest_url = CommandLine::ForCurrentProcess()-> | |
| 42 GetSwitchValueASCII(switches::kGoogleBaseSuggestURL); | |
| 43 if (!base_suggest_url.empty()) | |
| 44 return base_suggest_url; | |
| 45 | |
| 46 // Start with the Google base URL. | 39 // Start with the Google base URL. |
| 47 const GURL base_url(GoogleBaseURLValue()); | 40 const GURL base_url(GoogleBaseURLValue()); |
| 48 DCHECK(base_url.is_valid()); | 41 DCHECK(base_url.is_valid()); |
| 49 | 42 |
| 50 GURL::Replacements repl; | 43 GURL::Replacements repl; |
| 51 | 44 |
| 52 // Replace any existing path with "/complete/". | 45 // Replace any existing path with "/complete/". |
| 53 // SetPathStr() requires its argument to stay in scope as long as |repl| is, | 46 // SetPathStr() requires its argument to stay in scope as long as |repl| is, |
| 54 // so "/complete/" can't be passed to SetPathStr() directly, it needs to be in | 47 // so "/complete/" can't be passed to SetPathStr() directly, it needs to be in |
| 55 // a variable. | 48 // a variable. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 #endif // defined(ENABLE_THEMES) | 176 #endif // defined(ENABLE_THEMES) |
| 184 | 177 |
| 185 return std::string(); | 178 return std::string(); |
| 186 } | 179 } |
| 187 | 180 |
| 188 // static | 181 // static |
| 189 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 182 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
| 190 delete google_base_url_; | 183 delete google_base_url_; |
| 191 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); | 184 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); |
| 192 } | 185 } |
| OLD | NEW |