Chromium Code Reviews| Index: chrome/browser/google/google_util.cc |
| diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc |
| index eda66b334eb9ae10da12bec84c65276edf8ab0cc..b25d9a28beef409b44b42f28cfb02b6e44fffbd0 100644 |
| --- a/chrome/browser/google/google_util.cc |
| +++ b/chrome/browser/google/google_util.cc |
| @@ -18,6 +18,7 @@ |
| #include "chrome/common/net/url_util.h" |
| #include "chrome/installer/util/google_update_settings.h" |
| #include "googleurl/src/gurl.h" |
| +#include "googleurl/src/url_parse.h" |
| #include "net/base/registry_controlled_domain.h" |
| #if defined(OS_MACOSX) |
| @@ -203,6 +204,26 @@ bool IsGoogleSearchUrl(const std::string& url) { |
| (!is_home_page_base && HasQueryParameter(query)); |
| } |
| +bool IsInstantExtendedAPIGoogleSearchUrl(const std::string& url) { |
| + if (!IsGoogleSearchUrl(url)) |
| + return false; |
| + |
| + const std::string embedded_search_key = "espv"; |
| + |
| + url_parse::Parsed parsed_url; |
| + url_parse::ParseStandardURL(url.c_str(), url.length(), &parsed_url); |
| + url_parse::Component key, value; |
| + while (url_parse::ExtractQueryKeyValue( |
| + url.c_str(), &parsed_url.query, &key, &value)) { |
|
Peter Kasting
2012/06/21 22:28:05
Nit: Unusual indenting... just 4 from beginning of
dhollowa
2012/06/21 23:53:42
Done. google-c-style.el did this for me...
|
| + // If the parameter key is |embedded_search_key| and the value is not 0 this |
| + // is an Instant Extended API Google search URL. |
| + if (url.substr(key.begin, key.len) == embedded_search_key) { |
|
Peter Kasting
2012/06/21 22:28:05
Nit: Cheaper:
if (!url.compare(key.begin, key.l
dhollowa
2012/06/21 23:53:42
Done.
|
| + return value.is_nonempty() && url.substr(value.begin, value.len) != "0"; |
|
Peter Kasting
2012/06/21 22:28:05
Nit: Seems like using base::StringToInt() might be
dhollowa
2012/06/21 23:53:42
Done. And added additional test for this case.
|
| + } |
| + } |
| + return false; |
| +} |
| + |
| bool IsOrganic(const std::string& brand) { |
| const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| if (command_line.HasSwitch(switches::kOrganicInstall)) |