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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 // ToolbarModelImpl Implementation. | 97 // ToolbarModelImpl Implementation. |
98 base::string16 ToolbarModelImpl::GetText() const { | 98 base::string16 ToolbarModelImpl::GetText() const { |
99 base::string16 search_terms(GetSearchTerms(false)); | 99 base::string16 search_terms(GetSearchTerms(false)); |
100 if (!search_terms.empty()) | 100 if (!search_terms.empty()) |
101 return search_terms; | 101 return search_terms; |
102 | 102 |
103 if (WouldOmitURLDueToOriginChip()) | 103 if (WouldOmitURLDueToOriginChip()) |
104 return base::string16(); | 104 return base::string16(); |
105 | 105 |
| 106 return GetFormattedURL(); |
| 107 } |
| 108 |
| 109 base::string16 ToolbarModelImpl::GetFormattedURL() const { |
106 std::string languages; // Empty if we don't have a |navigation_controller|. | 110 std::string languages; // Empty if we don't have a |navigation_controller|. |
107 Profile* profile = GetProfile(); | 111 Profile* profile = GetProfile(); |
108 if (profile) | 112 if (profile) |
109 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | 113 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
110 | 114 |
111 GURL url(GetURL()); | 115 GURL url(GetURL()); |
112 if (url.spec().length() > content::kMaxURLDisplayChars) | 116 if (url.spec().length() > content::kMaxURLDisplayChars) |
113 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); | 117 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); |
114 // Note that we can't unescape spaces here, because if the user copies this | 118 // Note that we can't unescape spaces here, because if the user copies this |
115 // and pastes it into another program, that program may think the URL ends at | 119 // and pastes it into another program, that program may think the URL ends at |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 if (entry && | 330 if (entry && |
327 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL())) | 331 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL())) |
328 return search_terms; | 332 return search_terms; |
329 | 333 |
330 // Otherwise, extract search terms for HTTPS pages that do not have a security | 334 // Otherwise, extract search terms for HTTPS pages that do not have a security |
331 // error. | 335 // error. |
332 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing); | 336 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing); |
333 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ? | 337 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ? |
334 base::string16() : search_terms; | 338 base::string16() : search_terms; |
335 } | 339 } |
OLD | NEW |