OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/toolbar/toolbar_model_impl.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 10 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
11 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 11 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/search/search.h" | 13 #include "chrome/browser/search/search.h" |
14 #include "chrome/browser/ssl/connection_security.h" | 14 #include "chrome/browser/ssl/connection_security.h" |
15 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h" | 15 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
18 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
19 #include "components/google/core/browser/google_util.h" | 19 #include "components/google/core/browser/google_util.h" |
20 #include "components/omnibox/browser/autocomplete_classifier.h" | 20 #include "components/omnibox/browser/autocomplete_classifier.h" |
21 #include "components/omnibox/browser/autocomplete_input.h" | 21 #include "components/omnibox/browser/autocomplete_input.h" |
22 #include "components/omnibox/browser/autocomplete_match.h" | 22 #include "components/omnibox/browser/autocomplete_match.h" |
23 #include "components/url_formatter/url_formatter.h" | |
24 #include "content/public/browser/cert_store.h" | 23 #include "content/public/browser/cert_store.h" |
25 #include "content/public/browser/navigation_controller.h" | 24 #include "content/public/browser/navigation_controller.h" |
26 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
27 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
28 #include "content/public/browser/web_ui.h" | 27 #include "content/public/browser/web_ui.h" |
29 #include "content/public/common/content_constants.h" | 28 #include "content/public/common/content_constants.h" |
30 #include "content/public/common/ssl_status.h" | 29 #include "content/public/common/ssl_status.h" |
31 #include "grit/components_scaled_resources.h" | 30 #include "grit/components_scaled_resources.h" |
32 #include "grit/theme_resources.h" | 31 #include "grit/theme_resources.h" |
| 32 #include "net/base/net_util.h" |
33 #include "net/cert/cert_status_flags.h" | 33 #include "net/cert/cert_status_flags.h" |
34 #include "net/cert/x509_certificate.h" | 34 #include "net/cert/x509_certificate.h" |
35 #include "net/ssl/ssl_connection_status_flags.h" | 35 #include "net/ssl/ssl_connection_status_flags.h" |
36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
37 | 37 |
38 using content::NavigationController; | 38 using content::NavigationController; |
39 using content::NavigationEntry; | 39 using content::NavigationEntry; |
40 using content::WebContents; | 40 using content::WebContents; |
41 | 41 |
42 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate) | 42 ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate) |
(...skipping 18 matching lines...) Expand all Loading... |
61 if (profile) | 61 if (profile) |
62 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | 62 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
63 | 63 |
64 GURL url(GetURL()); | 64 GURL url(GetURL()); |
65 if (url.spec().length() > content::kMaxURLDisplayChars) | 65 if (url.spec().length() > content::kMaxURLDisplayChars) |
66 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); | 66 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); |
67 // Note that we can't unescape spaces here, because if the user copies this | 67 // Note that we can't unescape spaces here, because if the user copies this |
68 // and pastes it into another program, that program may think the URL ends at | 68 // and pastes it into another program, that program may think the URL ends at |
69 // the space. | 69 // the space. |
70 return AutocompleteInput::FormattedStringWithEquivalentMeaning( | 70 return AutocompleteInput::FormattedStringWithEquivalentMeaning( |
71 url, url_formatter::FormatUrl( | 71 url, net::FormatUrl(url, languages, net::kFormatUrlOmitAll, |
72 url, languages, url_formatter::kFormatUrlOmitAll, | 72 net::UnescapeRule::NORMAL, NULL, prefix_end, NULL), |
73 net::UnescapeRule::NORMAL, nullptr, prefix_end, nullptr), | |
74 ChromeAutocompleteSchemeClassifier(profile)); | 73 ChromeAutocompleteSchemeClassifier(profile)); |
75 } | 74 } |
76 | 75 |
77 base::string16 ToolbarModelImpl::GetCorpusNameForMobile() const { | 76 base::string16 ToolbarModelImpl::GetCorpusNameForMobile() const { |
78 if (!WouldPerformSearchTermReplacement(false)) | 77 if (!WouldPerformSearchTermReplacement(false)) |
79 return base::string16(); | 78 return base::string16(); |
80 GURL url(GetURL()); | 79 GURL url(GetURL()); |
81 // If there is a query in the url fragment look for the corpus name there, | 80 // If there is a query in the url fragment look for the corpus name there, |
82 // otherwise look for the corpus name in the query parameters. | 81 // otherwise look for the corpus name in the query parameters. |
83 const std::string& query_str(google_util::HasGoogleSearchQueryParam( | 82 const std::string& query_str(google_util::HasGoogleSearchQueryParam( |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 239 |
241 // Otherwise, extract search terms for HTTPS pages that do not have a security | 240 // Otherwise, extract search terms for HTTPS pages that do not have a security |
242 // error. | 241 // error. |
243 connection_security::SecurityLevel security_level = | 242 connection_security::SecurityLevel security_level = |
244 GetSecurityLevel(ignore_editing); | 243 GetSecurityLevel(ignore_editing); |
245 return ((security_level == connection_security::NONE) || | 244 return ((security_level == connection_security::NONE) || |
246 (security_level == connection_security::SECURITY_ERROR)) | 245 (security_level == connection_security::SECURITY_ERROR)) |
247 ? base::string16() | 246 ? base::string16() |
248 : search_terms; | 247 : search_terms; |
249 } | 248 } |
OLD | NEW |