OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" | 8 #include "base/metrics/field_trial.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/google/google_url_tracker.h" | 10 #include "chrome/browser/google/google_url_tracker.h" |
11 #include "chrome/browser/instant/instant_field_trial.h" | |
11 #include "content/browser/browser_thread.h" | 12 #include "content/browser/browser_thread.h" |
12 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
13 | 14 |
14 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 15 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
15 #include "chrome/browser/rlz/rlz.h" | 16 #include "chrome/browser/rlz/rlz.h" |
16 #include "chrome/installer/util/google_update_settings.h" | 17 #include "chrome/installer/util/google_update_settings.h" |
17 #endif | 18 #endif |
18 | 19 |
19 SearchTermsData::SearchTermsData() { | 20 SearchTermsData::SearchTermsData() { |
20 } | 21 } |
(...skipping 27 matching lines...) Expand all Loading... | |
48 // Replace any existing path with "/complete/". | 49 // Replace any existing path with "/complete/". |
49 static const std::string suggest_path("/complete/"); | 50 static const std::string suggest_path("/complete/"); |
50 repl.SetPathStr(suggest_path); | 51 repl.SetPathStr(suggest_path); |
51 | 52 |
52 // Clear the query and ref. | 53 // Clear the query and ref. |
53 repl.ClearQuery(); | 54 repl.ClearQuery(); |
54 repl.ClearRef(); | 55 repl.ClearRef(); |
55 return base_url.ReplaceComponents(repl).spec(); | 56 return base_url.ReplaceComponents(repl).spec(); |
56 } | 57 } |
57 | 58 |
59 std::string SearchTermsData::InstantFieldTrialUrlParam() const { | |
60 return ""; | |
Peter Kasting
2011/08/10 20:54:06
Nit: Use std::string() instead of ""
| |
61 } | |
62 | |
58 // static | 63 // static |
59 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; | 64 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; |
60 | 65 |
61 UIThreadSearchTermsData::UIThreadSearchTermsData() { | 66 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile) |
67 : profile_(profile) { | |
62 // GoogleURLTracker::GoogleURL() DCHECKs this also, but adding it here helps | 68 // GoogleURLTracker::GoogleURL() DCHECKs this also, but adding it here helps |
63 // us catch bad behavior at a more common place in this code. | 69 // us catch bad behavior at a more common place in this code. |
64 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 70 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
65 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 71 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
66 } | 72 } |
67 | 73 |
68 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { | 74 std::string UIThreadSearchTermsData::GoogleBaseURLValue() const { |
69 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 75 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
70 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 76 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
71 return google_base_url_ ? | 77 return google_base_url_ ? |
(...skipping 18 matching lines...) Expand all Loading... | |
90 !GoogleUpdateSettings::IsOrganic(brand)) { | 96 !GoogleUpdateSettings::IsOrganic(brand)) { |
91 // This call will return false the first time(s) it is called until the | 97 // This call will return false the first time(s) it is called until the |
92 // value has been cached. This normally would mean that at most one omnibox | 98 // value has been cached. This normally would mean that at most one omnibox |
93 // search might not send the RLZ data but this is not really a problem. | 99 // search might not send the RLZ data but this is not really a problem. |
94 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz_string); | 100 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz_string); |
95 } | 101 } |
96 return rlz_string; | 102 return rlz_string; |
97 } | 103 } |
98 #endif | 104 #endif |
99 | 105 |
106 std::string UIThreadSearchTermsData::InstantFieldTrialUrlParam() const { | |
107 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | |
108 BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
109 DCHECK(profile_); | |
Peter Kasting
2011/08/10 20:54:06
Remove this (in conjunction with the changes to In
| |
110 return InstantFieldTrial::GetGroupAsUrlParam(profile_); | |
111 } | |
112 | |
100 // static | 113 // static |
101 void UIThreadSearchTermsData::SetGoogleBaseURL(std::string* google_base_url) { | 114 void UIThreadSearchTermsData::SetGoogleBaseURL(std::string* google_base_url) { |
102 delete google_base_url_; | 115 delete google_base_url_; |
103 google_base_url_ = google_base_url; | 116 google_base_url_ = google_base_url; |
104 } | 117 } |
OLD | NEW |