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 11 matching lines...) Expand all Loading... |
22 #include "content/public/browser/ssl_status.h" | 22 #include "content/public/browser/ssl_status.h" |
23 #include "content/public/common/content_constants.h" | 23 #include "content/public/common/content_constants.h" |
24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
25 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
26 #include "net/base/cert_status_flags.h" | 26 #include "net/base/cert_status_flags.h" |
27 #include "net/base/net_util.h" | 27 #include "net/base/net_util.h" |
28 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
29 | 29 |
30 using content::NavigationEntry; | 30 using content::NavigationEntry; |
31 using content::SSLStatus; | 31 using content::SSLStatus; |
| 32 using content::WebContents; |
32 | 33 |
33 ToolbarModel::ToolbarModel(Browser* browser) | 34 ToolbarModel::ToolbarModel(Browser* browser) |
34 : browser_(browser), | 35 : browser_(browser), |
35 input_in_progress_(false) { | 36 input_in_progress_(false) { |
36 } | 37 } |
37 | 38 |
38 ToolbarModel::~ToolbarModel() { | 39 ToolbarModel::~ToolbarModel() { |
39 } | 40 } |
40 | 41 |
41 // ToolbarModel Implementation. | 42 // ToolbarModel Implementation. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // chrome://newtab's WebUI says. | 76 // chrome://newtab's WebUI says. |
76 NavigationController* controller = GetNavigationController(); | 77 NavigationController* controller = GetNavigationController(); |
77 NavigationEntry* entry = controller ? controller->GetVisibleEntry() : NULL; | 78 NavigationEntry* entry = controller ? controller->GetVisibleEntry() : NULL; |
78 if (entry) { | 79 if (entry) { |
79 if (entry->IsViewSourceMode() || | 80 if (entry->IsViewSourceMode() || |
80 entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) { | 81 entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) { |
81 return true; | 82 return true; |
82 } | 83 } |
83 } | 84 } |
84 | 85 |
85 TabContents* tab_contents = browser_->GetSelectedTabContents(); | 86 WebContents* web_contents = browser_->GetSelectedWebContents(); |
86 if (tab_contents && tab_contents->GetWebUIForCurrentState()) | 87 if (web_contents && web_contents->GetWebUIForCurrentState()) |
87 return !tab_contents->GetWebUIForCurrentState()->should_hide_url(); | 88 return !web_contents->GetWebUIForCurrentState()->should_hide_url(); |
88 | 89 |
89 if (entry && entry->GetURL().SchemeIs(chrome::kExtensionScheme)) | 90 if (entry && entry->GetURL().SchemeIs(chrome::kExtensionScheme)) |
90 return false; | 91 return false; |
91 | 92 |
92 return true; | 93 return true; |
93 } | 94 } |
94 | 95 |
95 ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() const { | 96 ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() const { |
96 if (input_in_progress_) // When editing, assume no security style. | 97 if (input_in_progress_) // When editing, assume no security style. |
97 return NONE; | 98 return NONE; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 UTF8ToUTF16(cert.subject().country_name)); | 169 UTF8ToUTF16(cert.subject().country_name)); |
169 } | 170 } |
170 | 171 |
171 NavigationController* ToolbarModel::GetNavigationController() const { | 172 NavigationController* ToolbarModel::GetNavigationController() const { |
172 // This |current_tab| can be NULL during the initialization of the | 173 // This |current_tab| can be NULL during the initialization of the |
173 // toolbar during window creation (i.e. before any tabs have been added | 174 // toolbar during window creation (i.e. before any tabs have been added |
174 // to the window). | 175 // to the window). |
175 TabContents* current_tab = browser_->GetSelectedTabContents(); | 176 TabContents* current_tab = browser_->GetSelectedTabContents(); |
176 return current_tab ? ¤t_tab->GetController() : NULL; | 177 return current_tab ? ¤t_tab->GetController() : NULL; |
177 } | 178 } |
OLD | NEW |