| 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" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 SearchTermsData::~SearchTermsData() { | 33 SearchTermsData::~SearchTermsData() { |
| 34 } | 34 } |
| 35 | 35 |
| 36 std::string SearchTermsData::GoogleBaseURLValue() const { | 36 std::string SearchTermsData::GoogleBaseURLValue() const { |
| 37 return GoogleURLTracker::kDefaultGoogleHomepage; | 37 return GoogleURLTracker::kDefaultGoogleHomepage; |
| 38 } | 38 } |
| 39 | 39 |
| 40 std::string SearchTermsData::GoogleBaseSuggestURLValue() const { | 40 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. | 41 // Start with the Google base URL. |
| 47 const GURL base_url(GoogleBaseURLValue()); | 42 const GURL base_url(GoogleBaseURLValue()); |
| 48 DCHECK(base_url.is_valid()); | 43 DCHECK(base_url.is_valid()); |
| 49 | 44 |
| 50 GURL::Replacements repl; | 45 GURL::Replacements repl; |
| 51 | 46 |
| 52 // Replace any existing path with "/complete/". | 47 // Replace any existing path with "/complete/". |
| 53 // SetPathStr() requires its argument to stay in scope as long as |repl| is, | 48 // 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 | 49 // so "/complete/" can't be passed to SetPathStr() directly, it needs to be in |
| 55 // a variable. | 50 // a variable. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 : profile_(profile) { | 88 : profile_(profile) { |
| 94 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 89 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
| 95 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 90 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 96 } | 91 } |
| 97 | 92 |
| 98 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { | 93 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { |
| 99 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 94 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
| 100 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 95 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 101 if (google_base_url_) | 96 if (google_base_url_) |
| 102 return *google_base_url_; | 97 return *google_base_url_; |
| 98 std::string base_url = CommandLine::ForCurrentProcess()-> |
| 99 GetSwitchValueASCII(switches::kGoogleBaseURL); |
| 100 if (!base_url.empty()) |
| 101 return base_url; |
| 103 return profile_ ? GoogleURLTracker::GoogleURL(profile_).spec() : | 102 return profile_ ? GoogleURLTracker::GoogleURL(profile_).spec() : |
| 104 SearchTermsData::GoogleBaseURLValue(); | 103 SearchTermsData::GoogleBaseURLValue(); |
| 105 } | 104 } |
| 106 | 105 |
| 107 std::string UIThreadSearchTermsData::GetApplicationLocale() const { | 106 std::string UIThreadSearchTermsData::GetApplicationLocale() const { |
| 108 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 107 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
| 109 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 108 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 110 return g_browser_process->GetApplicationLocale(); | 109 return g_browser_process->GetApplicationLocale(); |
| 111 } | 110 } |
| 112 | 111 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 #endif // defined(ENABLE_THEMES) | 173 #endif // defined(ENABLE_THEMES) |
| 175 | 174 |
| 176 return std::string(); | 175 return std::string(); |
| 177 } | 176 } |
| 178 | 177 |
| 179 // static | 178 // static |
| 180 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 179 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
| 181 delete google_base_url_; | 180 delete google_base_url_; |
| 182 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); | 181 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); |
| 183 } | 182 } |
| OLD | NEW |