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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 // EV are required to have an organization name and country. | 209 // EV are required to have an organization name and country. |
210 DCHECK(!cert->subject().organization_names.empty()); | 210 DCHECK(!cert->subject().organization_names.empty()); |
211 DCHECK(!cert->subject().country_name.empty()); | 211 DCHECK(!cert->subject().country_name.empty()); |
212 return l10n_util::GetStringFUTF16( | 212 return l10n_util::GetStringFUTF16( |
213 IDS_SECURE_CONNECTION_EV, | 213 IDS_SECURE_CONNECTION_EV, |
214 base::UTF8ToUTF16(cert->subject().organization_names[0]), | 214 base::UTF8ToUTF16(cert->subject().organization_names[0]), |
215 base::UTF8ToUTF16(cert->subject().country_name)); | 215 base::UTF8ToUTF16(cert->subject().country_name)); |
216 } | 216 } |
217 | 217 |
| 218 base::string16 ToolbarModelImpl::GetOriginDisplayName() const { |
| 219 std::string languages; // Empty if we don't have a |navigation_controller|. |
| 220 Profile* profile = GetProfile(); |
| 221 if (profile) |
| 222 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
| 223 |
| 224 GURL url(GetURL()); |
| 225 std::string displayed_origin; |
| 226 |
| 227 if ("https" == url.scheme() || "http" == url.scheme()) { |
| 228 displayed_origin = url.host(); |
| 229 if (url.port().length() > 0 && |
| 230 (("https" == url.scheme() && "443" != url.port()) || |
| 231 ("http" == url.scheme() && "80" != url.port()))) { |
| 232 displayed_origin += ":" + url.port(); |
| 233 } |
| 234 } else if ("file" == url.scheme()) { |
| 235 displayed_origin = url.path(); |
| 236 } else { |
| 237 // TODO(palmer): This is inefficient because we are just going to |
| 238 // convert it back into a GURL for net::FormatUrl. This function gets |
| 239 // called surprisingly often so it should be fast and clean. |
| 240 displayed_origin = url.GetOrigin().spec(); |
| 241 } |
| 242 |
| 243 // TODO(palmer): This is just testing: |
| 244 return base::ASCIIToUTF16(displayed_origin); |
| 245 |
| 246 //return net::FormatUrl(GURL(displayed_origin), languages); |
| 247 } |
| 248 |
218 bool ToolbarModelImpl::ShouldDisplayURL() const { | 249 bool ToolbarModelImpl::ShouldDisplayURL() const { |
219 // Note: The order here is important. | 250 // Note: The order here is important. |
220 // - The WebUI test must come before the extension scheme test because there | 251 // - The WebUI test must come before the extension scheme test because there |
221 // can be WebUIs that have extension schemes (e.g. the bookmark manager). In | 252 // can be WebUIs that have extension schemes (e.g. the bookmark manager). In |
222 // that case, we should prefer what the WebUI instance says. | 253 // that case, we should prefer what the WebUI instance says. |
223 // - The view-source test must come before the NTP test because of the case | 254 // - The view-source test must come before the NTP test because of the case |
224 // of view-source:chrome://newtab, which should display its URL despite what | 255 // of view-source:chrome://newtab, which should display its URL despite what |
225 // chrome://newtab says. | 256 // chrome://newtab says. |
226 NavigationController* controller = GetNavigationController(); | 257 NavigationController* controller = GetNavigationController(); |
227 NavigationEntry* entry = controller ? controller->GetVisibleEntry() : NULL; | 258 NavigationEntry* entry = controller ? controller->GetVisibleEntry() : NULL; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 if (entry && | 360 if (entry && |
330 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL())) | 361 google_util::StartsWithCommandLineGoogleBaseURL(entry->GetVirtualURL())) |
331 return search_terms; | 362 return search_terms; |
332 | 363 |
333 // Otherwise, extract search terms for HTTPS pages that do not have a security | 364 // Otherwise, extract search terms for HTTPS pages that do not have a security |
334 // error. | 365 // error. |
335 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing); | 366 ToolbarModel::SecurityLevel security_level = GetSecurityLevel(ignore_editing); |
336 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ? | 367 return ((security_level == NONE) || (security_level == SECURITY_ERROR)) ? |
337 base::string16() : search_terms; | 368 base::string16() : search_terms; |
338 } | 369 } |
OLD | NEW |