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

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: Adding sourceid changes 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
23 using content::BrowserThread; 21 using content::BrowserThread;
24 22
25 SearchTermsData::SearchTermsData() { 23 SearchTermsData::SearchTermsData() {
26 } 24 }
27 25
28 SearchTermsData::~SearchTermsData() { 26 SearchTermsData::~SearchTermsData() {
29 } 27 }
(...skipping 19 matching lines...) Expand all
49 // Clear the query and ref. 47 // Clear the query and ref.
50 repl.ClearQuery(); 48 repl.ClearQuery();
51 repl.ClearRef(); 49 repl.ClearRef();
52 return base_url.ReplaceComponents(repl).spec(); 50 return base_url.ReplaceComponents(repl).spec();
53 } 51 }
54 52
55 std::string SearchTermsData::GetApplicationLocale() const { 53 std::string SearchTermsData::GetApplicationLocale() const {
56 return "en"; 54 return "en";
57 } 55 }
58 56
59 #if defined(ENABLE_RLZ)
60 string16 SearchTermsData::GetRlzParameterValue() const { 57 string16 SearchTermsData::GetRlzParameterValue() const {
61 return string16(); 58 return string16();
62 } 59 }
63 #endif 60
61 std::string SearchTermsData::GetSearchClient() const {
62 return std::string();
63 }
64 64
65 std::string SearchTermsData::InstantEnabledParam() const { 65 std::string SearchTermsData::InstantEnabledParam() const {
66 return std::string(); 66 return std::string();
67 } 67 }
68 68
69 // static 69 // static
70 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; 70 std::string* UIThreadSearchTermsData::google_base_url_ = NULL;
71 71
72 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile) 72 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile)
73 : profile_(profile) { 73 : profile_(profile) {
74 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 74 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
75 BrowserThread::CurrentlyOn(BrowserThread::UI)); 75 BrowserThread::CurrentlyOn(BrowserThread::UI));
76 } 76 }
77 77
78 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { 78 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const {
79 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 79 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
80 BrowserThread::CurrentlyOn(BrowserThread::UI)); 80 BrowserThread::CurrentlyOn(BrowserThread::UI));
81 if (google_base_url_) 81 if (google_base_url_)
82 return *google_base_url_; 82 return *google_base_url_;
83 return profile_ ? GoogleURLTracker::GoogleURL(profile_).spec() : 83 return profile_ ? GoogleURLTracker::GoogleURL(profile_).spec() :
84 SearchTermsData::GoogleBaseURLValue(); 84 SearchTermsData::GoogleBaseURLValue();
85 } 85 }
86 86
87 std::string UIThreadSearchTermsData::GetApplicationLocale() const { 87 std::string UIThreadSearchTermsData::GetApplicationLocale() const {
88 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 88 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
89 BrowserThread::CurrentlyOn(BrowserThread::UI)); 89 BrowserThread::CurrentlyOn(BrowserThread::UI));
90 return g_browser_process->GetApplicationLocale(); 90 return g_browser_process->GetApplicationLocale();
91 } 91 }
92 92
93 #if defined(ENABLE_RLZ) 93 #if !defined(OS_ANDROID)
Peter Kasting 2012/12/06 07:02:37 Tiny nit: You might want an "Android implementatio
gone 2012/12/06 20:59:49 Done.
94 string16 UIThreadSearchTermsData::GetRlzParameterValue() const { 94 string16 UIThreadSearchTermsData::GetRlzParameterValue() const {
95 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 95 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
96 BrowserThread::CurrentlyOn(BrowserThread::UI)); 96 BrowserThread::CurrentlyOn(BrowserThread::UI));
97 string16 rlz_string; 97 string16 rlz_string;
98 #if defined(ENABLE_RLZ)
98 // For organic brandcodes do not use rlz at all. Empty brandcode usually 99 // For organic brandcodes do not use rlz at all. Empty brandcode usually
99 // means a chromium install. This is ok. 100 // means a chromium install. This is ok.
100 std::string brand; 101 std::string brand;
101 if (google_util::GetBrand(&brand) && !brand.empty() && 102 if (google_util::GetBrand(&brand) && !brand.empty() &&
102 !google_util::IsOrganic(brand)) { 103 !google_util::IsOrganic(brand)) {
103 // This call will return false the first time(s) it is called until the 104 // 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 105 // 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. 106 // search might not send the RLZ data but this is not really a problem.
106 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz_string); 107 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz_string);
107 } 108 }
109 #endif
108 return rlz_string; 110 return rlz_string;
109 } 111 }
112
113 std::string UIThreadSearchTermsData::GetSearchClient() const {
114 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
115 BrowserThread::CurrentlyOn(BrowserThread::UI));
116 return std::string();
117 }
110 #endif 118 #endif
111 119
112 std::string UIThreadSearchTermsData::InstantEnabledParam() const { 120 std::string UIThreadSearchTermsData::InstantEnabledParam() const {
113 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || 121 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
114 BrowserThread::CurrentlyOn(BrowserThread::UI)); 122 BrowserThread::CurrentlyOn(BrowserThread::UI));
115 if (chrome::search::IsInstantExtendedAPIEnabled(profile_)) 123 if (chrome::search::IsInstantExtendedAPIEnabled(profile_))
116 return std::string(google_util::kInstantExtendedAPIParam) + "=1&"; 124 return std::string(google_util::kInstantExtendedAPIParam) + "=1&";
117 if (chrome::BrowserInstantController::IsInstantEnabled(profile_)) 125 if (chrome::BrowserInstantController::IsInstantEnabled(profile_))
118 return "ion=1&"; 126 return "ion=1&";
119 return std::string(); 127 return std::string();
120 } 128 }
121 129
122 // static 130 // static
123 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { 131 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) {
124 delete google_base_url_; 132 delete google_base_url_;
125 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); 133 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url);
126 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698