Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: chrome/browser/search_engines/search_terms_data.cc

Issue 11448005: Add Android-specific parameters to search_engines/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/field_trial.h"
9 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/google/google_url_tracker.h" 9 #include "chrome/browser/google/google_url_tracker.h"
11 #include "chrome/browser/google/google_util.h" 10 #include "chrome/browser/google/google_util.h"
12 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser_instant_controller.h" 12 #include "chrome/browser/ui/browser_instant_controller.h"
14 #include "chrome/browser/ui/search/search.h" 13 #include "chrome/browser/ui/search/search.h"
15 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
16 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
17 16
18 #if defined(ENABLE_RLZ) 17 #if defined(ENABLE_RLZ)
19 #include "chrome/browser/google/google_util.h"
20 #include "chrome/browser/rlz/rlz.h" 18 #include "chrome/browser/rlz/rlz.h"
21 #endif 19 #endif
22 20
21 #if defined(OS_ANDROID)
22 #include "chrome/browser/search_engines/search_terms_data_android.h"
23 #endif
24
23 using content::BrowserThread; 25 using content::BrowserThread;
24 26
25 SearchTermsData::SearchTermsData() { 27 SearchTermsData::SearchTermsData() {
26 } 28 }
27 29
28 SearchTermsData::~SearchTermsData() { 30 SearchTermsData::~SearchTermsData() {
29 } 31 }
30 32
31 std::string SearchTermsData::GoogleBaseURLValue() const { 33 std::string SearchTermsData::GoogleBaseURLValue() const {
32 return GoogleURLTracker::kDefaultGoogleHomepage; 34 return GoogleURLTracker::kDefaultGoogleHomepage;
(...skipping 16 matching lines...) Expand all
49 // Clear the query and ref. 51 // Clear the query and ref.
50 repl.ClearQuery(); 52 repl.ClearQuery();
51 repl.ClearRef(); 53 repl.ClearRef();
52 return base_url.ReplaceComponents(repl).spec(); 54 return base_url.ReplaceComponents(repl).spec();
53 } 55 }
54 56
55 std::string SearchTermsData::GetApplicationLocale() const { 57 std::string SearchTermsData::GetApplicationLocale() const {
56 return "en"; 58 return "en";
57 } 59 }
58 60
59 #if defined(ENABLE_RLZ)
60 string16 SearchTermsData::GetRlzParameterValue() const { 61 string16 SearchTermsData::GetRlzParameterValue() const {
61 return string16(); 62 return string16();
62 } 63 }
63 #endif 64
65 std::string SearchTermsData::GetSearchClient() const {
66 return std::string();
67 }
64 68
65 std::string SearchTermsData::InstantEnabledParam() const { 69 std::string SearchTermsData::InstantEnabledParam() const {
66 return std::string(); 70 return std::string();
67 } 71 }
68 72
69 // static 73 // static
70 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; 74 std::string* UIThreadSearchTermsData::google_base_url_ = NULL;
71 75
72 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile) 76 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile)
73 : profile_(profile) { 77 : profile_(profile) {
74 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 78 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
75 BrowserThread::CurrentlyOn(BrowserThread::UI)); 79 BrowserThread::CurrentlyOn(BrowserThread::UI));
76 } 80 }
77 81
78 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { 82 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const {
79 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 83 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
80 BrowserThread::CurrentlyOn(BrowserThread::UI)); 84 BrowserThread::CurrentlyOn(BrowserThread::UI));
81 if (google_base_url_) 85 if (google_base_url_)
82 return *google_base_url_; 86 return *google_base_url_;
83 return profile_ ? GoogleURLTracker::GoogleURL(profile_).spec() : 87 return profile_ ? GoogleURLTracker::GoogleURL(profile_).spec() :
84 SearchTermsData::GoogleBaseURLValue(); 88 SearchTermsData::GoogleBaseURLValue();
85 } 89 }
86 90
87 std::string UIThreadSearchTermsData::GetApplicationLocale() const { 91 std::string UIThreadSearchTermsData::GetApplicationLocale() const {
88 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 92 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
89 BrowserThread::CurrentlyOn(BrowserThread::UI)); 93 BrowserThread::CurrentlyOn(BrowserThread::UI));
90 return g_browser_process->GetApplicationLocale(); 94 return g_browser_process->GetApplicationLocale();
91 } 95 }
92 96
93 #if defined(ENABLE_RLZ)
94 string16 UIThreadSearchTermsData::GetRlzParameterValue() const { 97 string16 UIThreadSearchTermsData::GetRlzParameterValue() const {
95 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 98 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
96 BrowserThread::CurrentlyOn(BrowserThread::UI)); 99 BrowserThread::CurrentlyOn(BrowserThread::UI));
97 string16 rlz_string; 100 string16 rlz_string;
101 #if defined(ENABLE_RLZ)
98 // For organic brandcodes do not use rlz at all. Empty brandcode usually 102 // For organic brandcodes do not use rlz at all. Empty brandcode usually
99 // means a chromium install. This is ok. 103 // means a chromium install. This is ok.
100 std::string brand; 104 std::string brand;
101 if (google_util::GetBrand(&brand) && !brand.empty() && 105 if (google_util::GetBrand(&brand) && !brand.empty() &&
102 !google_util::IsOrganic(brand)) { 106 !google_util::IsOrganic(brand)) {
103 // This call will return false the first time(s) it is called until the 107 // This call will return false the first time(s) it is called until the
104 // value has been cached. This normally would mean that at most one omnibox 108 // value has been cached. This normally would mean that at most one omnibox
105 // search might not send the RLZ data but this is not really a problem. 109 // search might not send the RLZ data but this is not really a problem.
106 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz_string); 110 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz_string);
107 } 111 }
112 #elif defined(OS_ANDROID)
Peter Kasting 2012/12/05 21:28:47 Another way to do this: put these two entire funct
gone 2012/12/06 01:43:58 Done.
113 // Android doesn't use the rlz library. Instead, it manages the rlz string
114 // on its own.
115 return SearchTermsDataAndroid::GetRlzParameterValue();
116 #endif
108 return rlz_string; 117 return rlz_string;
109 } 118 }
119
120 std::string UIThreadSearchTermsData::GetSearchClient() const {
121 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
122 BrowserThread::CurrentlyOn(BrowserThread::UI));
123 #if defined(OS_ANDROID)
124 return SearchTermsDataAndroid::GetSearchClient();
125 #else
126 return std::string();
110 #endif 127 #endif
128 }
111 129
112 std::string UIThreadSearchTermsData::InstantEnabledParam() const { 130 std::string UIThreadSearchTermsData::InstantEnabledParam() const {
113 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 131 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
114 BrowserThread::CurrentlyOn(BrowserThread::UI)); 132 BrowserThread::CurrentlyOn(BrowserThread::UI));
115 if (chrome::search::IsInstantExtendedAPIEnabled(profile_)) 133 if (chrome::search::IsInstantExtendedAPIEnabled(profile_))
116 return std::string(google_util::kInstantExtendedAPIParam) + "=1&"; 134 return std::string(google_util::kInstantExtendedAPIParam) + "=1&";
117 if (chrome::BrowserInstantController::IsInstantEnabled(profile_)) 135 if (chrome::BrowserInstantController::IsInstantEnabled(profile_))
118 return "ion=1&"; 136 return "ion=1&";
119 return std::string(); 137 return std::string();
120 } 138 }
121 139
122 // static 140 // static
123 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { 141 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) {
124 delete google_base_url_; 142 delete google_base_url_;
125 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); 143 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url);
126 } 144 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698