| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/toolbar_model.h" | 5 #include "chrome/browser/toolbar_model.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/cert_store.h" | 9 #include "chrome/browser/cert_store.h" |
| 10 #include "chrome/browser/pref_service.h" | 10 #include "chrome/browser/pref_service.h" |
| 11 #include "chrome/browser/profile.h" | 11 #include "chrome/browser/profile.h" |
| 12 #include "chrome/browser/ssl/ssl_error_info.h" | 12 #include "chrome/browser/ssl/ssl_error_info.h" |
| 13 #include "chrome/browser/tab_contents/navigation_controller.h" | 13 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 14 #include "chrome/browser/tab_contents/navigation_entry.h" | 14 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 15 #include "chrome/browser/tab_contents/tab_contents.h" | 15 #include "chrome/browser/tab_contents/tab_contents.h" |
| 16 #include "chrome/common/chrome_constants.h" |
| 16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 19 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
| 20 #include "net/base/cert_status_flags.h" | 21 #include "net/base/cert_status_flags.h" |
| 21 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
| 22 | 23 |
| 23 ToolbarModel::ToolbarModel(Browser* browser) | 24 ToolbarModel::ToolbarModel(Browser* browser) |
| 24 : browser_(browser), | 25 : browser_(browser), |
| 25 input_in_progress_(false) { | 26 input_in_progress_(false) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 38 languages = navigation_controller->profile()->GetPrefs()->GetString( | 39 languages = navigation_controller->profile()->GetPrefs()->GetString( |
| 39 prefs::kAcceptLanguages); | 40 prefs::kAcceptLanguages); |
| 40 NavigationEntry* entry = navigation_controller->GetActiveEntry(); | 41 NavigationEntry* entry = navigation_controller->GetActiveEntry(); |
| 41 if (!navigation_controller->tab_contents()->ShouldDisplayURL()) { | 42 if (!navigation_controller->tab_contents()->ShouldDisplayURL()) { |
| 42 // Explicitly hide the URL for this tab. | 43 // Explicitly hide the URL for this tab. |
| 43 url = GURL(); | 44 url = GURL(); |
| 44 } else if (entry) { | 45 } else if (entry) { |
| 45 url = entry->virtual_url(); | 46 url = entry->virtual_url(); |
| 46 } | 47 } |
| 47 } | 48 } |
| 49 if (url.spec().length() > chrome::kMaxURLDisplayChars) { |
| 50 if (url.IsStandard()) { |
| 51 url = url.GetOrigin(); |
| 52 } else { |
| 53 url = GURL(url.scheme() + ":"); |
| 54 } |
| 55 } |
| 48 return net::FormatUrl(url, languages, true, UnescapeRule::NORMAL, NULL, NULL, | 56 return net::FormatUrl(url, languages, true, UnescapeRule::NORMAL, NULL, NULL, |
| 49 NULL); | 57 NULL); |
| 50 } | 58 } |
| 51 | 59 |
| 52 ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() const { | 60 ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() const { |
| 53 if (input_in_progress_) // When editing, assume no security style. | 61 if (input_in_progress_) // When editing, assume no security style. |
| 54 return NONE; | 62 return NONE; |
| 55 | 63 |
| 56 NavigationController* navigation_controller = GetNavigationController(); | 64 NavigationController* navigation_controller = GetNavigationController(); |
| 57 if (!navigation_controller) // We might not have a controller on init. | 65 if (!navigation_controller) // We might not have a controller on init. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 *text = errors[0].short_description(); | 197 *text = errors[0].short_description(); |
| 190 } else { | 198 } else { |
| 191 // Multiple errors. | 199 // Multiple errors. |
| 192 *text = l10n_util::GetString(IDS_SEVERAL_SSL_ERRORS); | 200 *text = l10n_util::GetString(IDS_SEVERAL_SSL_ERRORS); |
| 193 for (size_t i = 0; i < errors.size(); ++i) { | 201 for (size_t i = 0; i < errors.size(); ++i) { |
| 194 text->append(L"\n"); | 202 text->append(L"\n"); |
| 195 text->append(errors[i].short_description()); | 203 text->append(errors[i].short_description()); |
| 196 } | 204 } |
| 197 } | 205 } |
| 198 } | 206 } |
| OLD | NEW |