| 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/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" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ssl/ssl_error_info.h" | 12 #include "chrome/browser/ssl/ssl_error_info.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 17 #include "content/browser/cert_store.h" | 17 #include "content/browser/cert_store.h" |
| 18 #include "content/browser/tab_contents/navigation_controller.h" | 18 #include "content/browser/tab_contents/navigation_controller.h" |
| 19 #include "content/browser/tab_contents/navigation_entry.h" | 19 #include "content/browser/tab_contents/navigation_entry.h" |
| 20 #include "content/browser/tab_contents/tab_contents.h" | 20 #include "content/browser/tab_contents/tab_contents.h" |
| 21 #include "content/common/content_constants.h" |
| 21 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 22 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
| 23 #include "net/base/cert_status_flags.h" | 24 #include "net/base/cert_status_flags.h" |
| 24 #include "net/base/net_util.h" | 25 #include "net/base/net_util.h" |
| 25 | 26 |
| 26 ToolbarModel::ToolbarModel(Browser* browser) | 27 ToolbarModel::ToolbarModel(Browser* browser) |
| 27 : browser_(browser), | 28 : browser_(browser), |
| 28 input_in_progress_(false) { | 29 input_in_progress_(false) { |
| 29 } | 30 } |
| 30 | 31 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 41 languages = navigation_controller->profile()->GetPrefs()->GetString( | 42 languages = navigation_controller->profile()->GetPrefs()->GetString( |
| 42 prefs::kAcceptLanguages); | 43 prefs::kAcceptLanguages); |
| 43 NavigationEntry* entry = navigation_controller->GetActiveEntry(); | 44 NavigationEntry* entry = navigation_controller->GetActiveEntry(); |
| 44 if (!navigation_controller->tab_contents()->ShouldDisplayURL()) { | 45 if (!navigation_controller->tab_contents()->ShouldDisplayURL()) { |
| 45 // Explicitly hide the URL for this tab. | 46 // Explicitly hide the URL for this tab. |
| 46 url = GURL(); | 47 url = GURL(); |
| 47 } else if (entry) { | 48 } else if (entry) { |
| 48 url = entry->virtual_url(); | 49 url = entry->virtual_url(); |
| 49 } | 50 } |
| 50 } | 51 } |
| 51 if (url.spec().length() > chrome::kMaxURLDisplayChars) | 52 if (url.spec().length() > content::kMaxURLDisplayChars) |
| 52 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); | 53 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); |
| 53 // Note that we can't unescape spaces here, because if the user copies this | 54 // Note that we can't unescape spaces here, because if the user copies this |
| 54 // and pastes it into another program, that program may think the URL ends at | 55 // and pastes it into another program, that program may think the URL ends at |
| 55 // the space. | 56 // the space. |
| 56 return UTF16ToWideHack( | 57 return UTF16ToWideHack( |
| 57 AutocompleteInput::FormattedStringWithEquivalentMeaning( | 58 AutocompleteInput::FormattedStringWithEquivalentMeaning( |
| 58 url, | 59 url, |
| 59 net::FormatUrl(url, languages, net::kFormatUrlOmitAll, | 60 net::FormatUrl(url, languages, net::kFormatUrlOmitAll, |
| 60 UnescapeRule::NORMAL, NULL, NULL, NULL))); | 61 UnescapeRule::NORMAL, NULL, NULL, NULL))); |
| 61 } | 62 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return UTF16ToWideHack(SSLManager::GetEVCertName(*cert)); | 123 return UTF16ToWideHack(SSLManager::GetEVCertName(*cert)); |
| 123 } | 124 } |
| 124 | 125 |
| 125 NavigationController* ToolbarModel::GetNavigationController() const { | 126 NavigationController* ToolbarModel::GetNavigationController() const { |
| 126 // This |current_tab| can be NULL during the initialization of the | 127 // This |current_tab| can be NULL during the initialization of the |
| 127 // toolbar during window creation (i.e. before any tabs have been added | 128 // toolbar during window creation (i.e. before any tabs have been added |
| 128 // to the window). | 129 // to the window). |
| 129 TabContents* current_tab = browser_->GetSelectedTabContents(); | 130 TabContents* current_tab = browser_->GetSelectedTabContents(); |
| 130 return current_tab ? ¤t_tab->controller() : NULL; | 131 return current_tab ? ¤t_tab->controller() : NULL; |
| 131 } | 132 } |
| OLD | NEW |