Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_model.cc

Issue 7790018: Don't update URL bar or SSL icon for pending history navs until they commit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comment. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/tab_contents/navigation_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "chrome/browser/ui/toolbar/toolbar_model.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/autocomplete/autocomplete.h" 8 #include "chrome/browser/autocomplete/autocomplete.h"
9 #include "chrome/browser/autocomplete/autocomplete_edit.h" 9 #include "chrome/browser/autocomplete/autocomplete_edit.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 25 matching lines...) Expand all
36 // ToolbarModel Implementation. 36 // ToolbarModel Implementation.
37 string16 ToolbarModel::GetText() const { 37 string16 ToolbarModel::GetText() const {
38 GURL url(chrome::kAboutBlankURL); 38 GURL url(chrome::kAboutBlankURL);
39 std::string languages; // Empty if we don't have a |navigation_controller|. 39 std::string languages; // Empty if we don't have a |navigation_controller|.
40 40
41 NavigationController* navigation_controller = GetNavigationController(); 41 NavigationController* navigation_controller = GetNavigationController();
42 if (navigation_controller) { 42 if (navigation_controller) {
43 Profile* profile = 43 Profile* profile =
44 Profile::FromBrowserContext(navigation_controller->browser_context()); 44 Profile::FromBrowserContext(navigation_controller->browser_context());
45 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); 45 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
46 NavigationEntry* entry = navigation_controller->GetActiveEntry(); 46 NavigationEntry* entry = navigation_controller->GetVisibleEntry();
47 if (!navigation_controller->tab_contents()->ShouldDisplayURL()) { 47 if (!navigation_controller->tab_contents()->ShouldDisplayURL()) {
48 // Explicitly hide the URL for this tab. 48 // Explicitly hide the URL for this tab.
49 url = GURL(); 49 url = GURL();
50 } else if (entry) { 50 } else if (entry) {
51 url = entry->virtual_url(); 51 url = entry->virtual_url();
52 } 52 }
53 } 53 }
54 if (url.spec().length() > content::kMaxURLDisplayChars) 54 if (url.spec().length() > content::kMaxURLDisplayChars)
55 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); 55 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":");
56 // Note that we can't unescape spaces here, because if the user copies this 56 // Note that we can't unescape spaces here, because if the user copies this
57 // and pastes it into another program, that program may think the URL ends at 57 // and pastes it into another program, that program may think the URL ends at
58 // the space. 58 // the space.
59 return AutocompleteInput::FormattedStringWithEquivalentMeaning( 59 return AutocompleteInput::FormattedStringWithEquivalentMeaning(
60 url, net::FormatUrl(url, languages, net::kFormatUrlOmitAll, 60 url, net::FormatUrl(url, languages, net::kFormatUrlOmitAll,
61 UnescapeRule::NORMAL, NULL, NULL, NULL)); 61 UnescapeRule::NORMAL, NULL, NULL, NULL));
62 } 62 }
63 63
64 ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() const { 64 ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() const {
65 if (input_in_progress_) // When editing, assume no security style. 65 if (input_in_progress_) // When editing, assume no security style.
66 return NONE; 66 return NONE;
67 67
68 NavigationController* navigation_controller = GetNavigationController(); 68 NavigationController* navigation_controller = GetNavigationController();
69 if (!navigation_controller) // We might not have a controller on init. 69 if (!navigation_controller) // We might not have a controller on init.
70 return NONE; 70 return NONE;
71 71
72 NavigationEntry* entry = navigation_controller->GetActiveEntry(); 72 NavigationEntry* entry = navigation_controller->GetVisibleEntry();
73 if (!entry) 73 if (!entry)
74 return NONE; 74 return NONE;
75 75
76 const NavigationEntry::SSLStatus& ssl = entry->ssl(); 76 const NavigationEntry::SSLStatus& ssl = entry->ssl();
77 switch (ssl.security_style()) { 77 switch (ssl.security_style()) {
78 case SECURITY_STYLE_UNKNOWN: 78 case SECURITY_STYLE_UNKNOWN:
79 case SECURITY_STYLE_UNAUTHENTICATED: 79 case SECURITY_STYLE_UNAUTHENTICATED:
80 return NONE; 80 return NONE;
81 81
82 case SECURITY_STYLE_AUTHENTICATION_BROKEN: 82 case SECURITY_STYLE_AUTHENTICATION_BROKEN:
(...skipping 29 matching lines...) Expand all
112 DCHECK(arraysize(icon_ids) == NUM_SECURITY_LEVELS); 112 DCHECK(arraysize(icon_ids) == NUM_SECURITY_LEVELS);
113 return icon_ids[GetSecurityLevel()]; 113 return icon_ids[GetSecurityLevel()];
114 } 114 }
115 115
116 string16 ToolbarModel::GetEVCertName() const { 116 string16 ToolbarModel::GetEVCertName() const {
117 DCHECK_EQ(GetSecurityLevel(), EV_SECURE); 117 DCHECK_EQ(GetSecurityLevel(), EV_SECURE);
118 scoped_refptr<net::X509Certificate> cert; 118 scoped_refptr<net::X509Certificate> cert;
119 // Note: Navigation controller and active entry are guaranteed non-NULL or 119 // Note: Navigation controller and active entry are guaranteed non-NULL or
120 // the security level would be NONE. 120 // the security level would be NONE.
121 CertStore::GetInstance()->RetrieveCert( 121 CertStore::GetInstance()->RetrieveCert(
122 GetNavigationController()->GetActiveEntry()->ssl().cert_id(), &cert); 122 GetNavigationController()->GetVisibleEntry()->ssl().cert_id(), &cert);
123 return GetEVCertName(*cert); 123 return GetEVCertName(*cert);
124 } 124 }
125 125
126 // static 126 // static
127 string16 ToolbarModel::GetEVCertName(const net::X509Certificate& cert) { 127 string16 ToolbarModel::GetEVCertName(const net::X509Certificate& cert) {
128 // EV are required to have an organization name and country. 128 // EV are required to have an organization name and country.
129 if (cert.subject().organization_names.empty() || 129 if (cert.subject().organization_names.empty() ||
130 cert.subject().country_name.empty()) { 130 cert.subject().country_name.empty()) {
131 NOTREACHED(); 131 NOTREACHED();
132 return string16(); 132 return string16();
133 } 133 }
134 134
135 return l10n_util::GetStringFUTF16( 135 return l10n_util::GetStringFUTF16(
136 IDS_SECURE_CONNECTION_EV, 136 IDS_SECURE_CONNECTION_EV,
137 UTF8ToUTF16(cert.subject().organization_names[0]), 137 UTF8ToUTF16(cert.subject().organization_names[0]),
138 UTF8ToUTF16(cert.subject().country_name)); 138 UTF8ToUTF16(cert.subject().country_name));
139 } 139 }
140 140
141 NavigationController* ToolbarModel::GetNavigationController() const { 141 NavigationController* ToolbarModel::GetNavigationController() const {
142 // This |current_tab| can be NULL during the initialization of the 142 // This |current_tab| can be NULL during the initialization of the
143 // toolbar during window creation (i.e. before any tabs have been added 143 // toolbar during window creation (i.e. before any tabs have been added
144 // to the window). 144 // to the window).
145 TabContents* current_tab = browser_->GetSelectedTabContents(); 145 TabContents* current_tab = browser_->GetSelectedTabContents();
146 return current_tab ? &current_tab->controller() : NULL; 146 return current_tab ? &current_tab->controller() : NULL;
147 } 147 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/tab_contents/navigation_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698