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/lazy_instance.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/google/google_url_tracker.h" | 11 #include "chrome/browser/google/google_url_tracker.h" |
11 #include "chrome/browser/instant/instant_field_trial.h" | 12 #include "chrome/browser/instant/instant_field_trial.h" |
12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
15 | 16 |
16 #if defined(ENABLE_RLZ) | 17 #if defined(ENABLE_RLZ) |
17 #include "chrome/browser/google/google_util.h" | 18 #include "chrome/browser/google/google_util.h" |
18 #include "chrome/browser/rlz/rlz.h" | 19 #include "chrome/browser/rlz/rlz.h" |
19 #endif | 20 #endif |
20 | 21 |
| 22 #if defined(OS_ANDROID) |
| 23 namespace { |
| 24 base::LazyInstance::Leaky<string16> g_static_rlz = LAZY_INSTANCE_INITIALIZER; |
| 25 } |
| 26 #endif |
| 27 |
21 using content::BrowserThread; | 28 using content::BrowserThread; |
22 | 29 |
23 SearchTermsData::SearchTermsData() { | 30 SearchTermsData::SearchTermsData() { |
24 } | 31 } |
25 | 32 |
26 SearchTermsData::~SearchTermsData() { | 33 SearchTermsData::~SearchTermsData() { |
27 } | 34 } |
28 | 35 |
29 std::string SearchTermsData::GoogleBaseURLValue() const { | 36 std::string SearchTermsData::GoogleBaseURLValue() const { |
30 return GoogleURLTracker::kDefaultGoogleHomepage; | 37 return GoogleURLTracker::kDefaultGoogleHomepage; |
(...skipping 20 matching lines...) Expand all Loading... |
51 } | 58 } |
52 | 59 |
53 std::string SearchTermsData::GetApplicationLocale() const { | 60 std::string SearchTermsData::GetApplicationLocale() const { |
54 return "en"; | 61 return "en"; |
55 } | 62 } |
56 | 63 |
57 #if defined(ENABLE_RLZ) | 64 #if defined(ENABLE_RLZ) |
58 string16 SearchTermsData::GetRlzParameterValue() const { | 65 string16 SearchTermsData::GetRlzParameterValue() const { |
59 return string16(); | 66 return string16(); |
60 } | 67 } |
| 68 |
| 69 #elif defined(OS_ANDROID) |
| 70 string16 SearchTermsData::GetRlzParameterValue() const { |
| 71 return g_static_rlz == NULL ? string16() : g_static_rlz.Get(); |
| 72 } |
| 73 |
| 74 void SearchTermsData::SetStaticRlz(const string16& rlz) { |
| 75 g_static_rlz.Get() = rlz; |
| 76 } |
61 #endif | 77 #endif |
62 | 78 |
63 std::string SearchTermsData::InstantEnabledParam() const { | 79 std::string SearchTermsData::InstantEnabledParam() const { |
64 return std::string(); | 80 return std::string(); |
65 } | 81 } |
66 | 82 |
67 // static | 83 // static |
68 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; | 84 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; |
69 | 85 |
70 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile) | 86 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 128 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
113 return InstantFieldTrial::GetMode(profile_) == InstantFieldTrial::INSTANT ? | 129 return InstantFieldTrial::GetMode(profile_) == InstantFieldTrial::INSTANT ? |
114 "&ion=1" : std::string(); | 130 "&ion=1" : std::string(); |
115 } | 131 } |
116 | 132 |
117 // static | 133 // static |
118 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 134 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
119 delete google_base_url_; | 135 delete google_base_url_; |
120 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); | 136 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); |
121 } | 137 } |
OLD | NEW |