OLD | NEW |
1 // Copyright (c) 2010 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" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
(...skipping 21 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 = |
44 prefs::kAcceptLanguages); | 44 static_cast<Profile*>(navigation_controller->browser_context()); |
| 45 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
45 NavigationEntry* entry = navigation_controller->GetActiveEntry(); | 46 NavigationEntry* entry = navigation_controller->GetActiveEntry(); |
46 if (!navigation_controller->tab_contents()->ShouldDisplayURL()) { | 47 if (!navigation_controller->tab_contents()->ShouldDisplayURL()) { |
47 // Explicitly hide the URL for this tab. | 48 // Explicitly hide the URL for this tab. |
48 url = GURL(); | 49 url = GURL(); |
49 } else if (entry) { | 50 } else if (entry) { |
50 url = entry->virtual_url(); | 51 url = entry->virtual_url(); |
51 } | 52 } |
52 } | 53 } |
53 if (url.spec().length() > content::kMaxURLDisplayChars) | 54 if (url.spec().length() > content::kMaxURLDisplayChars) |
54 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); | 55 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)); | 140 UTF8ToUTF16(cert.subject().country_name)); |
140 } | 141 } |
141 | 142 |
142 NavigationController* ToolbarModel::GetNavigationController() const { | 143 NavigationController* ToolbarModel::GetNavigationController() const { |
143 // This |current_tab| can be NULL during the initialization of the | 144 // This |current_tab| can be NULL during the initialization of the |
144 // toolbar during window creation (i.e. before any tabs have been added | 145 // toolbar during window creation (i.e. before any tabs have been added |
145 // to the window). | 146 // to the window). |
146 TabContents* current_tab = browser_->GetSelectedTabContents(); | 147 TabContents* current_tab = browser_->GetSelectedTabContents(); |
147 return current_tab ? ¤t_tab->controller() : NULL; | 148 return current_tab ? ¤t_tab->controller() : NULL; |
148 } | 149 } |
OLD | NEW |