| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/search_engines/template_url.h" | 5 #include "components/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" | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" | 
| 23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" | 
| 24 #include "components/google/core/browser/google_util.h" | 24 #include "components/google/core/browser/google_util.h" | 
| 25 #include "components/metrics/proto/omnibox_input_type.pb.h" | 25 #include "components/metrics/proto/omnibox_input_type.pb.h" | 
| 26 #include "components/search_engines/search_engines_switches.h" | 26 #include "components/search_engines/search_engines_switches.h" | 
| 27 #include "components/search_engines/search_terms_data.h" | 27 #include "components/search_engines/search_terms_data.h" | 
| 28 #include "components/url_formatter/url_formatter.h" | 28 #include "components/url_formatter/url_formatter.h" | 
| 29 #include "google_apis/google_api_keys.h" | 29 #include "google_apis/google_api_keys.h" | 
| 30 #include "net/base/escape.h" | 30 #include "net/base/escape.h" | 
| 31 #include "net/base/mime_util.h" | 31 #include "net/base/mime_util.h" | 
| 32 #include "net/base/net_util.h" |  | 
| 33 #include "ui/base/device_form_factor.h" | 32 #include "ui/base/device_form_factor.h" | 
| 34 #include "url/gurl.h" | 33 #include "url/gurl.h" | 
| 35 | 34 | 
| 36 namespace { | 35 namespace { | 
| 37 | 36 | 
| 38 // The TemplateURLRef has any number of terms that need to be replaced. Each of | 37 // The TemplateURLRef has any number of terms that need to be replaced. Each of | 
| 39 // the terms is enclosed in braces. If the character preceeding the final | 38 // the terms is enclosed in braces. If the character preceeding the final | 
| 40 // brace is a ?, it indicates the term is optional and can be replaced with | 39 // brace is a ?, it indicates the term is optional and can be replaced with | 
| 41 // an empty string. | 40 // an empty string. | 
| 42 const char kStartParameter = '{'; | 41 const char kStartParameter = '{'; | 
| (...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1514       // patterns. This means that given patterns | 1513       // patterns. This means that given patterns | 
| 1515       //    [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], | 1514       //    [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], | 
| 1516       // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would | 1515       // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would | 
| 1517       // return false. This is important for at least Google, where such URLs | 1516       // return false. This is important for at least Google, where such URLs | 
| 1518       // are invalid. | 1517       // are invalid. | 
| 1519       return !search_terms->empty(); | 1518       return !search_terms->empty(); | 
| 1520     } | 1519     } | 
| 1521   } | 1520   } | 
| 1522   return false; | 1521   return false; | 
| 1523 } | 1522 } | 
| OLD | NEW | 
|---|