Chromium Code Reviews| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 } | 141 } |
| 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. |
|
Avi (use Gerrit)
2013/04/11 17:01:37
Oh, that's much clearer. Thanks.
| |
| 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 const GURL& url = entry->GetURL(); | |
| 164 if (url.SchemeIs(chrome::kChromeUIScheme) && | |
| 165 (url.host() == chrome::kChromeUINewTabHost || | |
| 166 url.host() == chrome::kChromeUIExtensionActivityHost)) { | |
| 167 return false; | |
| 168 } | |
| 169 | |
| 170 if (entry->GetVirtualURL().SchemeIs(chrome::kChromeUIScheme) && | |
| 171 entry->GetVirtualURL().host() == chrome::kChromeUIBookmarksHost) { | |
| 172 return true; | |
| 173 } | |
| 174 | |
| 175 if (url.SchemeIs(extensions::kExtensionScheme)) | |
| 176 return false; | |
| 177 | |
| 178 #if defined(OS_CHROMEOS) | |
| 179 if (url.SchemeIs(chrome::kDriveScheme)) | |
| 180 return false; | |
| 181 #endif | |
| 162 } | 182 } |
| 163 | 183 |
| 164 WebContents* web_contents = delegate_->GetActiveWebContents(); | 184 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; | 185 return false; |
| 178 | 186 |
| 179 return true; | 187 return true; |
| 180 } | 188 } |
| 181 | 189 |
| 182 ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel() const { | 190 ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel() const { |
| 183 if (input_in_progress_) // When editing, assume no security style. | 191 if (input_in_progress_) // When editing, assume no security style. |
| 184 return NONE; | 192 return NONE; |
| 185 | 193 |
| 186 return GetSecurityLevelForWebContents(delegate_->GetActiveWebContents()); | 194 return GetSecurityLevelForWebContents(delegate_->GetActiveWebContents()); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 Profile* profile = | 269 Profile* profile = |
| 262 Profile::FromBrowserContext(contents->GetBrowserContext()); | 270 Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 263 AutocompleteClassifierFactory::GetForProfile(profile)->Classify( | 271 AutocompleteClassifierFactory::GetForProfile(profile)->Classify( |
| 264 search_terms, false, false, &match, NULL); | 272 search_terms, false, false, &match, NULL); |
| 265 if (!AutocompleteMatch::IsSearchType(match.type)) | 273 if (!AutocompleteMatch::IsSearchType(match.type)) |
| 266 search_terms.clear(); | 274 search_terms.clear(); |
| 267 } | 275 } |
| 268 | 276 |
| 269 return search_terms; | 277 return search_terms; |
| 270 } | 278 } |
| OLD | NEW |