| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 return EV_SECURE; | 88 return EV_SECURE; |
| 89 return SECURE; | 89 return SECURE; |
| 90 } | 90 } |
| 91 default: | 91 default: |
| 92 NOTREACHED(); | 92 NOTREACHED(); |
| 93 return NONE; | 93 return NONE; |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 // ToolbarModelImpl Implementation. | 97 // ToolbarModelImpl Implementation. |
| 98 string16 ToolbarModelImpl::GetText(bool allow_search_term_replacement) const { | 98 string16 ToolbarModelImpl::GetText() const { |
| 99 if (allow_search_term_replacement) { | 99 string16 search_terms(GetSearchTerms(false)); |
| 100 string16 search_terms(GetSearchTerms(false)); | 100 if (!search_terms.empty()) |
| 101 if (!search_terms.empty()) | 101 return search_terms; |
| 102 return search_terms; | 102 |
| 103 } | |
| 104 std::string languages; // Empty if we don't have a |navigation_controller|. | 103 std::string languages; // Empty if we don't have a |navigation_controller|. |
| 105 Profile* profile = GetProfile(); | 104 Profile* profile = GetProfile(); |
| 106 if (profile) | 105 if (profile) |
| 107 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | 106 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
| 108 | 107 |
| 109 GURL url(GetURL()); | 108 GURL url(GetURL()); |
| 110 if (url.spec().length() > content::kMaxURLDisplayChars) | 109 if (url.spec().length() > content::kMaxURLDisplayChars) |
| 111 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); | 110 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); |
| 112 // Note that we can't unescape spaces here, because if the user copies this | 111 // Note that we can't unescape spaces here, because if the user copies this |
| 113 // and pastes it into another program, that program may think the URL ends at | 112 // and pastes it into another program, that program may think the URL ends at |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 if (entry && | 278 if (entry && |
| 280 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL())) | 279 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL())) |
| 281 return search_terms; | 280 return search_terms; |
| 282 | 281 |
| 283 // Otherwise, extract search terms for HTTPS pages that do not have a security | 282 // Otherwise, extract search terms for HTTPS pages that do not have a security |
| 284 // error. | 283 // error. |
| 285 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing); | 284 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing); |
| 286 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ? | 285 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ? |
| 287 string16() : search_terms; | 286 string16() : search_terms; |
| 288 } | 287 } |
| OLD | NEW |