Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1011)

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_model_impl.cc

Issue 14080004: Remove some chrome-specific methods from content::WebUI. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments and fix null check Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 return GURL(chrome::kAboutBlankURL); 140 return GURL(chrome::kAboutBlankURL);
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 NTP 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 // extensions can implement the NTP.
Avi (use Gerrit) 2013/04/11 00:51:19 "because extensions can implement the NTP"? Drop t
151 // that case, we should prefer what the WebUI instance says. 151 // - The view-source test must come before the NTP test because of the case
152 // - The view-source test must come before the WebUI test because of the case
153 // of view-source:chrome://newtab, which should display its URL despite what 152 // of view-source:chrome://newtab, which should display its URL despite what
154 // chrome://newtab's WebUI says. 153 // chrome://newtab says.
155 NavigationController* controller = GetNavigationController(); 154 NavigationController* controller = GetNavigationController();
156 NavigationEntry* entry = controller ? controller->GetVisibleEntry() : NULL; 155 NavigationEntry* entry = controller ? controller->GetVisibleEntry() : NULL;
157 if (entry) { 156 if (entry) {
158 if (entry->IsViewSourceMode() || 157 if (entry->IsViewSourceMode() ||
159 entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) { 158 entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) {
160 return true; 159 return true;
161 } 160 }
161
162 if (entry->GetURL().SchemeIs(chrome::kChromeUIScheme) &&
163 (entry->GetURL().host() == chrome::kChromeUINewTabHost ||
164 entry->GetURL().host() == chrome::kChromeUIExtensionActivityHost)) {
165 return false;
166 }
167
168 if (entry->GetURL().SchemeIs(extensions::kExtensionScheme))
169 return false;
170
171 #if defined(OS_CHROMEOS)
172 if (entry->GetURL().SchemeIs(chrome::kDriveScheme))
173 return false;
174 #endif
162 } 175 }
163 176
164 WebContents* web_contents = delegate_->GetActiveWebContents(); 177 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; 178 return false;
178 179
179 return true; 180 return true;
180 } 181 }
181 182
182 ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel() const { 183 ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel() const {
183 if (input_in_progress_) // When editing, assume no security style. 184 if (input_in_progress_) // When editing, assume no security style.
184 return NONE; 185 return NONE;
185 186
186 return GetSecurityLevelForWebContents(delegate_->GetActiveWebContents()); 187 return GetSecurityLevelForWebContents(delegate_->GetActiveWebContents());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 Profile* profile = 262 Profile* profile =
262 Profile::FromBrowserContext(contents->GetBrowserContext()); 263 Profile::FromBrowserContext(contents->GetBrowserContext());
263 AutocompleteClassifierFactory::GetForProfile(profile)->Classify( 264 AutocompleteClassifierFactory::GetForProfile(profile)->Classify(
264 search_terms, false, false, &match, NULL); 265 search_terms, false, false, &match, NULL);
265 if (!AutocompleteMatch::IsSearchType(match.type)) 266 if (!AutocompleteMatch::IsSearchType(match.type))
266 search_terms.clear(); 267 search_terms.clear();
267 } 268 }
268 269
269 return search_terms; 270 return search_terms;
270 } 271 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/webui/extensions/extension_activity_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698