OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_impl.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 bool ToolbarModelImpl::WouldReplaceSearchURLWithSearchTerms() const { | 143 bool ToolbarModelImpl::WouldReplaceSearchURLWithSearchTerms() const { |
144 return !GetSearchTerms().empty(); | 144 return !GetSearchTerms().empty(); |
145 } | 145 } |
146 | 146 |
147 bool ToolbarModelImpl::ShouldDisplayURL() const { | 147 bool ToolbarModelImpl::ShouldDisplayURL() const { |
148 // Note: The order here is important. | 148 // Note: The order here is important. |
149 // - The WebUI test must come before the extension scheme test because there | 149 // - The WebUI test must come before the extension scheme test because there |
150 // can be WebUIs that have extension schemes (e.g. the bookmark manager). In | 150 // can be WebUIs that have extension schemes (e.g. the bookmark manager). In |
151 // that case, we should prefer what the WebUI instance says. | 151 // that case, we should prefer what the WebUI instance says. |
152 // - The view-source test must come before the WebUI test because of the case | 152 // - The view-source test must come before the NTP test because of the case |
153 // of view-source:chrome://newtab, which should display its URL despite what | 153 // of view-source:chrome://newtab, which should display its URL despite what |
154 // chrome://newtab's WebUI says. | 154 // chrome://newtab says. |
155 NavigationController* controller = GetNavigationController(); | 155 NavigationController* controller = GetNavigationController(); |
156 NavigationEntry* entry = controller ? controller->GetVisibleEntry() : NULL; | 156 NavigationEntry* entry = controller ? controller->GetVisibleEntry() : NULL; |
157 if (entry) { | 157 if (entry) { |
158 if (entry->IsViewSourceMode() || | 158 if (entry->IsViewSourceMode() || |
159 entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) { | 159 entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) { |
160 return true; | 160 return true; |
161 } | 161 } |
| 162 |
| 163 GURL url = entry->GetURL(); |
| 164 GURL virtual_url = entry->GetVirtualURL(); |
| 165 if (url.SchemeIs(chrome::kChromeUIScheme) || |
| 166 virtual_url.SchemeIs(chrome::kChromeUIScheme)) { |
| 167 if (!url.SchemeIs(chrome::kChromeUIScheme)) |
| 168 url = virtual_url; |
| 169 return url.host() != chrome::kChromeUINewTabHost; |
| 170 } |
| 171 |
| 172 if (url.SchemeIs(extensions::kExtensionScheme)) |
| 173 return false; |
| 174 |
| 175 #if defined(OS_CHROMEOS) |
| 176 if (url.SchemeIs(chrome::kDriveScheme)) |
| 177 return false; |
| 178 #endif |
162 } | 179 } |
163 | 180 |
164 WebContents* web_contents = delegate_->GetActiveWebContents(); | 181 if (chrome::IsInstantNTP(delegate_->GetActiveWebContents())) |
165 if (web_contents && web_contents->GetWebUIForCurrentState()) | |
166 return !web_contents->GetWebUIForCurrentState()->ShouldHideURL(); | |
167 | |
168 if (entry && entry->GetURL().SchemeIs(extensions::kExtensionScheme)) | |
169 return false; | |
170 | |
171 #if defined(OS_CHROMEOS) | |
172 if (entry && entry->GetURL().SchemeIs(chrome::kDriveScheme)) | |
173 return false; | |
174 #endif | |
175 | |
176 if (chrome::IsInstantNTP(web_contents)) | |
177 return false; | 182 return false; |
178 | 183 |
179 return true; | 184 return true; |
180 } | 185 } |
181 | 186 |
182 ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel() const { | 187 ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel() const { |
183 if (input_in_progress_) // When editing, assume no security style. | 188 if (input_in_progress_) // When editing, assume no security style. |
184 return NONE; | 189 return NONE; |
185 | 190 |
186 return GetSecurityLevelForWebContents(delegate_->GetActiveWebContents()); | 191 return GetSecurityLevelForWebContents(delegate_->GetActiveWebContents()); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 Profile* profile = | 266 Profile* profile = |
262 Profile::FromBrowserContext(contents->GetBrowserContext()); | 267 Profile::FromBrowserContext(contents->GetBrowserContext()); |
263 AutocompleteClassifierFactory::GetForProfile(profile)->Classify( | 268 AutocompleteClassifierFactory::GetForProfile(profile)->Classify( |
264 search_terms, false, false, &match, NULL); | 269 search_terms, false, false, &match, NULL); |
265 if (!AutocompleteMatch::IsSearchType(match.type)) | 270 if (!AutocompleteMatch::IsSearchType(match.type)) |
266 search_terms.clear(); | 271 search_terms.clear(); |
267 } | 272 } |
268 | 273 |
269 return search_terms; | 274 return search_terms; |
270 } | 275 } |
OLD | NEW |