| 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" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 ToolbarModel::~ToolbarModel() { | 33 ToolbarModel::~ToolbarModel() { |
| 34 } | 34 } |
| 35 | 35 |
| 36 // ToolbarModel Implementation. | 36 // ToolbarModel Implementation. |
| 37 std::wstring ToolbarModel::GetText() const { | 37 std::wstring 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 languages = navigation_controller->profile()->GetPrefs()->GetString( | 43 Profile* profile = static_cast<Profile*>(navigation_controller->context()); |
| 44 prefs::kAcceptLanguages); | 44 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
| 45 NavigationEntry* entry = navigation_controller->GetActiveEntry(); | 45 NavigationEntry* entry = navigation_controller->GetActiveEntry(); |
| 46 if (!navigation_controller->tab_contents()->ShouldDisplayURL()) { | 46 if (!navigation_controller->tab_contents()->ShouldDisplayURL()) { |
| 47 // Explicitly hide the URL for this tab. | 47 // Explicitly hide the URL for this tab. |
| 48 url = GURL(); | 48 url = GURL(); |
| 49 } else if (entry) { | 49 } else if (entry) { |
| 50 url = entry->virtual_url(); | 50 url = entry->virtual_url(); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 if (url.spec().length() > content::kMaxURLDisplayChars) | 53 if (url.spec().length() > content::kMaxURLDisplayChars) |
| 54 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); | 54 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 UTF8ToUTF16(cert.subject().country_name)); | 139 UTF8ToUTF16(cert.subject().country_name)); |
| 140 } | 140 } |
| 141 | 141 |
| 142 NavigationController* ToolbarModel::GetNavigationController() const { | 142 NavigationController* ToolbarModel::GetNavigationController() const { |
| 143 // This |current_tab| can be NULL during the initialization of the | 143 // This |current_tab| can be NULL during the initialization of the |
| 144 // toolbar during window creation (i.e. before any tabs have been added | 144 // toolbar during window creation (i.e. before any tabs have been added |
| 145 // to the window). | 145 // to the window). |
| 146 TabContents* current_tab = browser_->GetSelectedTabContents(); | 146 TabContents* current_tab = browser_->GetSelectedTabContents(); |
| 147 return current_tab ? ¤t_tab->controller() : NULL; | 147 return current_tab ? ¤t_tab->controller() : NULL; |
| 148 } | 148 } |
| OLD | NEW |