| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 : profile_(profile) { | 92 : profile_(profile) { |
| 98 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 93 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
| 99 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 94 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 100 } | 95 } |
| 101 | 96 |
| 102 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { | 97 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { |
| 103 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 98 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
| 104 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 99 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 105 if (google_base_url_) | 100 if (google_base_url_) |
| 106 return *google_base_url_; | 101 return *google_base_url_; |
| 102 std::string base_url = CommandLine::ForCurrentProcess()-> |
| 103 GetSwitchValueASCII(switches::kGoogleBaseURL); |
| 104 if (!base_url.empty()) |
| 105 return base_url; |
| 107 return profile_ ? GoogleURLTracker::GoogleURL(profile_).spec() : | 106 return profile_ ? GoogleURLTracker::GoogleURL(profile_).spec() : |
| 108 SearchTermsData::GoogleBaseURLValue(); | 107 SearchTermsData::GoogleBaseURLValue(); |
| 109 } | 108 } |
| 110 | 109 |
| 111 std::string UIThreadSearchTermsData::GetApplicationLocale() const { | 110 std::string UIThreadSearchTermsData::GetApplicationLocale() const { |
| 112 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 111 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
| 113 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 112 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 114 return g_browser_process->GetApplicationLocale(); | 113 return g_browser_process->GetApplicationLocale(); |
| 115 } | 114 } |
| 116 | 115 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 #endif // defined(ENABLE_THEMES) | 182 #endif // defined(ENABLE_THEMES) |
| 184 | 183 |
| 185 return std::string(); | 184 return std::string(); |
| 186 } | 185 } |
| 187 | 186 |
| 188 // static | 187 // static |
| 189 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 188 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
| 190 delete google_base_url_; | 189 delete google_base_url_; |
| 191 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); | 190 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); |
| 192 } | 191 } |
| OLD | NEW |