Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/search_engines/template_url_service.cc

Issue 13727003: Remove unused BuildQueryTerms from TemplateURLService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_service.h" 5 #include "chrome/browser/search_engines/template_url_service.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 return; 1903 return;
1904 1904
1905 // Synthesize a visit for the keyword. This ensures the url for the keyword is 1905 // Synthesize a visit for the keyword. This ensures the url for the keyword is
1906 // autocompleted even if the user doesn't type the url in directly. 1906 // autocompleted even if the user doesn't type the url in directly.
1907 history->AddPage(url, base::Time::Now(), NULL, 0, GURL(), 1907 history->AddPage(url, base::Time::Now(), NULL, 0, GURL(),
1908 history::RedirectList(), 1908 history::RedirectList(),
1909 content::PAGE_TRANSITION_KEYWORD_GENERATED, 1909 content::PAGE_TRANSITION_KEYWORD_GENERATED,
1910 history::SOURCE_BROWSED, false); 1910 history::SOURCE_BROWSED, false);
1911 } 1911 }
1912 1912
1913 // static
1914 bool TemplateURLService::BuildQueryTerms(const GURL& url,
1915 QueryTerms* query_terms) {
1916 url_parse::Component query = url.parsed_for_possibly_invalid_spec().query;
1917 url_parse::Component key, value;
1918 size_t valid_term_count = 0;
1919 while (url_parse::ExtractQueryKeyValue(url.spec().c_str(), &query, &key,
1920 &value)) {
1921 if (key.is_nonempty() && value.is_nonempty()) {
1922 std::string key_string = url.spec().substr(key.begin, key.len);
1923 std::string value_string = url.spec().substr(value.begin, value.len);
1924 QueryTerms::iterator query_terms_iterator =
1925 query_terms->find(key_string);
1926 if (query_terms_iterator != query_terms->end()) {
1927 if (!query_terms_iterator->second.empty() &&
1928 query_terms_iterator->second != value_string) {
1929 // The term occurs in multiple places with different values. Treat
1930 // this as if the term doesn't occur by setting the value to an empty
1931 // string.
1932 (*query_terms)[key_string] = std::string();
1933 DCHECK(valid_term_count > 0);
1934 valid_term_count--;
1935 }
1936 } else {
1937 valid_term_count++;
1938 (*query_terms)[key_string] = value_string;
1939 }
1940 }
1941 }
1942 return (valid_term_count > 0);
1943 }
1944
1945 void TemplateURLService::GoogleBaseURLChanged(const GURL& old_base_url) { 1913 void TemplateURLService::GoogleBaseURLChanged(const GURL& old_base_url) {
1946 bool something_changed = false; 1914 bool something_changed = false;
1947 for (TemplateURLVector::iterator i(template_urls_.begin()); 1915 for (TemplateURLVector::iterator i(template_urls_.begin());
1948 i != template_urls_.end(); ++i) { 1916 i != template_urls_.end(); ++i) {
1949 TemplateURL* t_url = *i; 1917 TemplateURL* t_url = *i;
1950 if (t_url->url_ref().HasGoogleBaseURLs() || 1918 if (t_url->url_ref().HasGoogleBaseURLs() ||
1951 t_url->suggestions_url_ref().HasGoogleBaseURLs()) { 1919 t_url->suggestions_url_ref().HasGoogleBaseURLs()) {
1952 TemplateURL updated_turl(t_url->profile(), t_url->data()); 1920 TemplateURL updated_turl(t_url->profile(), t_url->data());
1953 updated_turl.ResetKeywordIfNecessary(false); 1921 updated_turl.ResetKeywordIfNecessary(false);
1954 KeywordToTemplateMap::const_iterator existing_entry = 1922 KeywordToTemplateMap::const_iterator existing_entry =
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 // TODO(mpcomplete): If we allow editing extension keywords, then those 2482 // TODO(mpcomplete): If we allow editing extension keywords, then those
2515 // should be persisted to disk and synced. 2483 // should be persisted to disk and synced.
2516 if (template_url->sync_guid().empty() && 2484 if (template_url->sync_guid().empty() &&
2517 !template_url->IsExtensionKeyword()) { 2485 !template_url->IsExtensionKeyword()) {
2518 template_url->data_.sync_guid = base::GenerateGUID(); 2486 template_url->data_.sync_guid = base::GenerateGUID();
2519 if (service_.get()) 2487 if (service_.get())
2520 service_->UpdateKeyword(template_url->data()); 2488 service_->UpdateKeyword(template_url->data());
2521 } 2489 }
2522 } 2490 }
2523 } 2491 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service.h ('k') | chrome/browser/search_engines/template_url_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698