Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/template_url.h" | 5 #include "chrome/browser/search_engines/template_url.h" |
| 6 | 6 |
| 7 #include "app/gfx/favicon_size.h" | 7 #include "app/gfx/favicon_size.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/rlz/rlz.h" | |
| 13 #include "chrome/browser/google_url_tracker.h" | 12 #include "chrome/browser/google_url_tracker.h" |
| 14 #include "chrome/browser/search_engines/template_url_model.h" | 13 #include "chrome/browser/search_engines/template_url_model.h" |
| 15 #include "net/base/escape.h" | 14 #include "net/base/escape.h" |
| 16 | 15 |
| 16 #if defined(OS_WIN) | |
| 17 #include "chrome/browser/rlz/rlz.h" | |
| 18 #endif | |
| 19 | |
| 17 // The TemplateURLRef has any number of terms that need to be replaced. Each of | 20 // The TemplateURLRef has any number of terms that need to be replaced. Each of |
| 18 // the terms is enclosed in braces. If the character preceeding the final | 21 // the terms is enclosed in braces. If the character preceeding the final |
| 19 // brace is a ?, it indicates the term is optional and can be replaced with | 22 // brace is a ?, it indicates the term is optional and can be replaced with |
| 20 // an empty string. | 23 // an empty string. |
| 21 static const wchar_t kStartParameter = '{'; | 24 static const wchar_t kStartParameter = '{'; |
| 22 static const wchar_t kEndParameter = '}'; | 25 static const wchar_t kEndParameter = '}'; |
| 23 static const wchar_t kOptional = '?'; | 26 static const wchar_t kOptional = '?'; |
| 24 | 27 |
| 25 // Known parameters found in the URL. | 28 // Known parameters found in the URL. |
| 26 static const wchar_t kSearchTermsParameter[] = L"searchTerms"; | 29 static const wchar_t kSearchTermsParameter[] = L"searchTerms"; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 case GOOGLE_BASE_SUGGEST_URL: | 294 case GOOGLE_BASE_SUGGEST_URL: |
| 292 url.insert(i->index, GoogleBaseSuggestURLValue()); | 295 url.insert(i->index, GoogleBaseSuggestURLValue()); |
| 293 break; | 296 break; |
| 294 | 297 |
| 295 case GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION: | 298 case GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION: |
| 296 if (accepted_suggestion >= 0) | 299 if (accepted_suggestion >= 0) |
| 297 url.insert(i->index, L"oq=" + encoded_original_query + L"&"); | 300 url.insert(i->index, L"oq=" + encoded_original_query + L"&"); |
| 298 break; | 301 break; |
| 299 | 302 |
| 300 case GOOGLE_RLZ: { | 303 case GOOGLE_RLZ: { |
| 304 #if defined(OS_WIN) | |
|
Evan Stade
2009/09/25 01:07:23
move defines outside of case?
| |
| 301 std::wstring rlz_string; | 305 std::wstring rlz_string; |
| 302 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz_string); | 306 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz_string); |
| 303 if (!rlz_string.empty()) { | 307 if (!rlz_string.empty()) { |
| 304 rlz_string = L"rlz=" + rlz_string + L"&"; | 308 rlz_string = L"rlz=" + rlz_string + L"&"; |
| 305 url.insert(i->index, rlz_string); | 309 url.insert(i->index, rlz_string); |
| 306 } | 310 } |
| 307 break; | 311 break; |
| 312 #endif | |
|
Evan Stade
2009/09/25 19:54:41
still seems like this endif should come before the
| |
| 308 } | 313 } |
| 309 | 314 |
| 310 case GOOGLE_UNESCAPED_SEARCH_TERMS: { | 315 case GOOGLE_UNESCAPED_SEARCH_TERMS: { |
| 311 std::string unescaped_terms; | 316 std::string unescaped_terms; |
| 312 WideToCodepage(terms, WideToASCII(input_encoding).c_str(), | 317 WideToCodepage(terms, WideToASCII(input_encoding).c_str(), |
| 313 OnStringUtilConversionError::SKIP, &unescaped_terms); | 318 OnStringUtilConversionError::SKIP, &unescaped_terms); |
| 314 url.insert(i->index, std::wstring(unescaped_terms.begin(), | 319 url.insert(i->index, std::wstring(unescaped_terms.begin(), |
| 315 unescaped_terms.end())); | 320 unescaped_terms.end())); |
| 316 break; | 321 break; |
| 317 } | 322 } |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 568 } | 573 } |
| 569 return GURL(); | 574 return GURL(); |
| 570 } | 575 } |
| 571 | 576 |
| 572 void TemplateURL::InvalidateCachedValues() const { | 577 void TemplateURL::InvalidateCachedValues() const { |
| 573 url_.InvalidateCachedValues(); | 578 url_.InvalidateCachedValues(); |
| 574 suggestions_url_.InvalidateCachedValues(); | 579 suggestions_url_.InvalidateCachedValues(); |
| 575 if (autogenerate_keyword_) | 580 if (autogenerate_keyword_) |
| 576 keyword_.clear(); | 581 keyword_.clear(); |
| 577 } | 582 } |
| OLD | NEW |