| OLD | NEW |
| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 net::UnescapeRule::NORMAL, NULL, NULL, NULL)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool ToolbarModel::ShouldDisplayURL() const { | 64 bool ToolbarModel::ShouldDisplayURL() const { |
| 65 // Note: The order here is important. | 65 // Note: The order here is important. |
| 66 // - The WebUI test must come before the extension scheme test because there | 66 // - The WebUI test must come before the extension scheme test because there |
| 67 // can be WebUIs that have extension schemes (e.g. the bookmark manager). In | 67 // can be WebUIs that have extension schemes (e.g. the bookmark manager). In |
| 68 // that case, we should prefer what the WebUI instance says. | 68 // that case, we should prefer what the WebUI instance says. |
| 69 // - The view-source test must come before the WebUI test because of the case | 69 // - The view-source test must come before the WebUI test because of the case |
| 70 // of view-source:chrome://newtab, which should display its URL despite what | 70 // of view-source:chrome://newtab, which should display its URL despite what |
| 71 // chrome://newtab's WebUI says. | 71 // chrome://newtab's WebUI says. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 UTF8ToUTF16(cert.subject().country_name)); | 164 UTF8ToUTF16(cert.subject().country_name)); |
| 165 } | 165 } |
| 166 | 166 |
| 167 NavigationController* ToolbarModel::GetNavigationController() const { | 167 NavigationController* ToolbarModel::GetNavigationController() const { |
| 168 // This |current_tab| can be NULL during the initialization of the | 168 // This |current_tab| can be NULL during the initialization of the |
| 169 // toolbar during window creation (i.e. before any tabs have been added | 169 // toolbar during window creation (i.e. before any tabs have been added |
| 170 // to the window). | 170 // to the window). |
| 171 TabContents* current_tab = browser_->GetSelectedTabContents(); | 171 TabContents* current_tab = browser_->GetSelectedTabContents(); |
| 172 return current_tab ? ¤t_tab->controller() : NULL; | 172 return current_tab ? ¤t_tab->controller() : NULL; |
| 173 } | 173 } |
| OLD | NEW |