| 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/template_url.h" | 5 #include "chrome/browser/search_engines/template_url.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
| 13 #include "base/i18n/icu_string_conversions.h" | 13 #include "base/i18n/icu_string_conversions.h" |
| 14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/metrics/field_trial.h" | 16 #include "base/metrics/field_trial.h" |
| 17 #include "base/rand_util.h" | 17 #include "base/rand_util.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_split.h" | 19 #include "base/strings/string_split.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 23 #include "chrome/browser/omnibox/omnibox_field_trial.h" |
| 23 #include "chrome/browser/search/search.h" | 24 #include "chrome/browser/search/search.h" |
| 24 #include "chrome/browser/search_engines/template_url_service.h" | 25 #include "chrome/browser/search_engines/template_url_service.h" |
| 25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/chrome_version_info.h" | 27 #include "chrome/common/chrome_version_info.h" |
| 27 #include "components/google/core/browser/google_util.h" | 28 #include "components/google/core/browser/google_util.h" |
| 28 #include "components/metrics/proto/omnibox_input_type.pb.h" | 29 #include "components/metrics/proto/omnibox_input_type.pb.h" |
| 29 #include "components/search_engines/search_terms_data.h" | 30 #include "components/search_engines/search_terms_data.h" |
| 30 #include "extensions/common/constants.h" | 31 #include "extensions/common/constants.h" |
| 31 #include "google_apis/google_api_keys.h" | 32 #include "google_apis/google_api_keys.h" |
| 32 #include "net/base/escape.h" | 33 #include "net/base/escape.h" |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 start)); | 623 start)); |
| 623 } else if (parameter == kGooglePageClassificationParameter) { | 624 } else if (parameter == kGooglePageClassificationParameter) { |
| 624 replacements->push_back(Replacement(GOOGLE_PAGE_CLASSIFICATION, start)); | 625 replacements->push_back(Replacement(GOOGLE_PAGE_CLASSIFICATION, start)); |
| 625 } else if (parameter == kGoogleRLZParameter) { | 626 } else if (parameter == kGoogleRLZParameter) { |
| 626 replacements->push_back(Replacement(GOOGLE_RLZ, start)); | 627 replacements->push_back(Replacement(GOOGLE_RLZ, start)); |
| 627 } else if (parameter == kGoogleSearchClient) { | 628 } else if (parameter == kGoogleSearchClient) { |
| 628 replacements->push_back(Replacement(GOOGLE_SEARCH_CLIENT, start)); | 629 replacements->push_back(Replacement(GOOGLE_SEARCH_CLIENT, start)); |
| 629 } else if (parameter == kGoogleSearchFieldtrialParameter) { | 630 } else if (parameter == kGoogleSearchFieldtrialParameter) { |
| 630 replacements->push_back(Replacement(GOOGLE_SEARCH_FIELDTRIAL_GROUP, start)); | 631 replacements->push_back(Replacement(GOOGLE_SEARCH_FIELDTRIAL_GROUP, start)); |
| 631 } else if (parameter == kGoogleSearchVersion) { | 632 } else if (parameter == kGoogleSearchVersion) { |
| 632 if (CommandLine::ForCurrentProcess()->HasSwitch( | 633 if (OmniboxFieldTrial::EnableAnswersInSuggest()) |
| 633 switches::kEnableAnswersInSuggest)) | |
| 634 url->insert(start, "gs_rn=42&"); | 634 url->insert(start, "gs_rn=42&"); |
| 635 } else if (parameter == kGoogleSessionToken) { | 635 } else if (parameter == kGoogleSessionToken) { |
| 636 replacements->push_back(Replacement(GOOGLE_SESSION_TOKEN, start)); | 636 replacements->push_back(Replacement(GOOGLE_SESSION_TOKEN, start)); |
| 637 } else if (parameter == kGoogleSourceIdParameter) { | 637 } else if (parameter == kGoogleSourceIdParameter) { |
| 638 #if defined(OS_ANDROID) | 638 #if defined(OS_ANDROID) |
| 639 url->insert(start, "sourceid=chrome-mobile&"); | 639 url->insert(start, "sourceid=chrome-mobile&"); |
| 640 #else | 640 #else |
| 641 url->insert(start, "sourceid=chrome&"); | 641 url->insert(start, "sourceid=chrome&"); |
| 642 #endif | 642 #endif |
| 643 } else if (parameter == kGoogleSuggestAPIKeyParameter) { | 643 } else if (parameter == kGoogleSuggestAPIKeyParameter) { |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 // patterns. This means that given patterns | 1409 // patterns. This means that given patterns |
| 1410 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], | 1410 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], |
| 1411 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would | 1411 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would |
| 1412 // return false. This is important for at least Google, where such URLs | 1412 // return false. This is important for at least Google, where such URLs |
| 1413 // are invalid. | 1413 // are invalid. |
| 1414 return !search_terms->empty(); | 1414 return !search_terms->empty(); |
| 1415 } | 1415 } |
| 1416 } | 1416 } |
| 1417 return false; | 1417 return false; |
| 1418 } | 1418 } |
| OLD | NEW |