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_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" |
11 #include "base/guid.h" | 11 #include "base/guid.h" |
12 #include "base/i18n/case_conversion.h" | 12 #include "base/i18n/case_conversion.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
16 #include "base/string_split.h" | 16 #include "base/string_split.h" |
17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
18 #include "base/threading/thread_restrictions.h" | 18 #include "base/threading/thread_restrictions.h" |
| 19 #include "base/time.h" |
19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
21 #include "chrome/browser/google/google_url_tracker.h" | 22 #include "chrome/browser/google/google_url_tracker.h" |
22 #include "chrome/browser/history/history.h" | 23 #include "chrome/browser/history/history.h" |
23 #include "chrome/browser/history/history_notifications.h" | 24 #include "chrome/browser/history/history_notifications.h" |
24 #include "chrome/browser/history/history_service_factory.h" | 25 #include "chrome/browser/history/history_service_factory.h" |
25 #include "chrome/browser/net/url_fixer_upper.h" | 26 #include "chrome/browser/net/url_fixer_upper.h" |
26 #include "chrome/browser/prefs/pref_service.h" | 27 #include "chrome/browser/prefs/pref_service.h" |
27 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
28 #include "chrome/browser/protector/base_setting_change.h" | 29 #include "chrome/browser/protector/base_setting_change.h" |
(...skipping 1884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1913 if (!history) | 1914 if (!history) |
1914 return; | 1915 return; |
1915 | 1916 |
1916 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(t_url.keyword()), | 1917 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(t_url.keyword()), |
1917 std::string())); | 1918 std::string())); |
1918 if (!url.is_valid()) | 1919 if (!url.is_valid()) |
1919 return; | 1920 return; |
1920 | 1921 |
1921 // Synthesize a visit for the keyword. This ensures the url for the keyword is | 1922 // Synthesize a visit for the keyword. This ensures the url for the keyword is |
1922 // autocompleted even if the user doesn't type the url in directly. | 1923 // autocompleted even if the user doesn't type the url in directly. |
1923 history->AddPage(url, NULL, 0, GURL(), | 1924 history->AddPage(url, base::Time::Now(), NULL, 0, GURL(), |
| 1925 history::RedirectList(), |
1924 content::PAGE_TRANSITION_KEYWORD_GENERATED, | 1926 content::PAGE_TRANSITION_KEYWORD_GENERATED, |
1925 history::RedirectList(), history::SOURCE_BROWSED, false); | 1927 history::SOURCE_BROWSED, false); |
1926 } | 1928 } |
1927 | 1929 |
1928 // static | 1930 // static |
1929 bool TemplateURLService::BuildQueryTerms(const GURL& url, | 1931 bool TemplateURLService::BuildQueryTerms(const GURL& url, |
1930 QueryTerms* query_terms) { | 1932 QueryTerms* query_terms) { |
1931 url_parse::Component query = url.parsed_for_possibly_invalid_spec().query; | 1933 url_parse::Component query = url.parsed_for_possibly_invalid_spec().query; |
1932 url_parse::Component key, value; | 1934 url_parse::Component key, value; |
1933 size_t valid_term_count = 0; | 1935 size_t valid_term_count = 0; |
1934 while (url_parse::ExtractQueryKeyValue(url.spec().c_str(), &query, &key, | 1936 while (url_parse::ExtractQueryKeyValue(url.spec().c_str(), &query, &key, |
1935 &value)) { | 1937 &value)) { |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2522 // TODO(mpcomplete): If we allow editing extension keywords, then those | 2524 // TODO(mpcomplete): If we allow editing extension keywords, then those |
2523 // should be persisted to disk and synced. | 2525 // should be persisted to disk and synced. |
2524 if (template_url->sync_guid().empty() && | 2526 if (template_url->sync_guid().empty() && |
2525 !template_url->IsExtensionKeyword()) { | 2527 !template_url->IsExtensionKeyword()) { |
2526 template_url->data_.sync_guid = base::GenerateGUID(); | 2528 template_url->data_.sync_guid = base::GenerateGUID(); |
2527 if (service_.get()) | 2529 if (service_.get()) |
2528 service_->UpdateKeyword(template_url->data()); | 2530 service_->UpdateKeyword(template_url->data()); |
2529 } | 2531 } |
2530 } | 2532 } |
2531 } | 2533 } |
OLD | NEW |