| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui_thread_search_terms_data.h" | 5 #include "chrome/browser/search_engines/ui_thread_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" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/google/google_brand.h" | 12 #include "chrome/browser/google/google_brand.h" |
| 13 #include "chrome/browser/google/google_profile_helper.h" | 13 #include "chrome/browser/google/google_url_tracker_factory.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/search/instant_service.h" | 15 #include "chrome/browser/search/instant_service.h" |
| 16 #include "chrome/browser/search/instant_service_factory.h" | 16 #include "chrome/browser/search/instant_service_factory.h" |
| 17 #include "chrome/browser/search/search.h" | 17 #include "chrome/browser/search/search.h" |
| 18 #include "chrome/browser/themes/theme_service.h" | 18 #include "chrome/browser/themes/theme_service.h" |
| 19 #include "chrome/browser/themes/theme_service_factory.h" | 19 #include "chrome/browser/themes/theme_service_factory.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
| 22 #include "components/google/core/browser/google_url_tracker.h" |
| 22 #include "components/google/core/browser/google_util.h" | 23 #include "components/google/core/browser/google_util.h" |
| 23 #include "components/omnibox/omnibox_field_trial.h" | 24 #include "components/omnibox/omnibox_field_trial.h" |
| 24 #include "components/search/search.h" | 25 #include "components/search/search.h" |
| 25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 26 #include "ui/base/device_form_factor.h" | 27 #include "ui/base/device_form_factor.h" |
| 27 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 28 | 29 |
| 29 #if defined(ENABLE_RLZ) | 30 #if defined(ENABLE_RLZ) |
| 30 #include "chrome/browser/rlz/rlz.h" | 31 #include "chrome/browser/rlz/rlz.h" |
| 31 #endif | 32 #endif |
| (...skipping 10 matching lines...) Expand all Loading... |
| 42 } | 43 } |
| 43 | 44 |
| 44 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { | 45 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { |
| 45 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 46 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
| 46 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 47 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 47 if (google_base_url_) | 48 if (google_base_url_) |
| 48 return *google_base_url_; | 49 return *google_base_url_; |
| 49 GURL base_url(google_util::CommandLineGoogleBaseURL()); | 50 GURL base_url(google_util::CommandLineGoogleBaseURL()); |
| 50 if (base_url.is_valid()) | 51 if (base_url.is_valid()) |
| 51 return base_url.spec(); | 52 return base_url.spec(); |
| 52 return profile_ ? | 53 |
| 53 google_profile_helper::GetGoogleHomePageURL(profile_).spec() : | 54 if (!profile_) |
| 54 SearchTermsData::GoogleBaseURLValue(); | 55 return SearchTermsData::GoogleBaseURLValue(); |
| 56 |
| 57 const GoogleURLTracker* tracker = |
| 58 GoogleURLTrackerFactory::GetForProfile(profile_); |
| 59 return tracker ? |
| 60 tracker->google_url().spec() : GoogleURLTracker::kDefaultGoogleHomepage; |
| 55 } | 61 } |
| 56 | 62 |
| 57 std::string UIThreadSearchTermsData::GetApplicationLocale() const { | 63 std::string UIThreadSearchTermsData::GetApplicationLocale() const { |
| 58 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 64 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
| 59 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 65 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 60 return g_browser_process->GetApplicationLocale(); | 66 return g_browser_process->GetApplicationLocale(); |
| 61 } | 67 } |
| 62 | 68 |
| 63 // Android implementations are in ui_thread_search_terms_data_android.cc. | 69 // Android implementations are in ui_thread_search_terms_data_android.cc. |
| 64 #if !defined(OS_ANDROID) | 70 #if !defined(OS_ANDROID) |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 if (!modifier.empty()) | 191 if (!modifier.empty()) |
| 186 version += " " + modifier; | 192 version += " " + modifier; |
| 187 return version; | 193 return version; |
| 188 } | 194 } |
| 189 | 195 |
| 190 // static | 196 // static |
| 191 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 197 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
| 192 delete google_base_url_; | 198 delete google_base_url_; |
| 193 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); | 199 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); |
| 194 } | 200 } |
| OLD | NEW |