| 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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 10 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 GURL url = entry->GetURL(); | 183 GURL url = entry->GetURL(); |
| 184 GURL virtual_url = entry->GetVirtualURL(); | 184 GURL virtual_url = entry->GetVirtualURL(); |
| 185 if (url.SchemeIs(content::kChromeUIScheme) || | 185 if (url.SchemeIs(content::kChromeUIScheme) || |
| 186 virtual_url.SchemeIs(content::kChromeUIScheme)) { | 186 virtual_url.SchemeIs(content::kChromeUIScheme)) { |
| 187 if (!url.SchemeIs(content::kChromeUIScheme)) | 187 if (!url.SchemeIs(content::kChromeUIScheme)) |
| 188 url = virtual_url; | 188 url = virtual_url; |
| 189 return url.host() != chrome::kChromeUINewTabHost; | 189 return url.host() != chrome::kChromeUINewTabHost; |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 return !chrome::IsInstantNTP(delegate_->GetActiveWebContents()); | 193 return !search::IsInstantNTP(delegate_->GetActiveWebContents()); |
| 194 } | 194 } |
| 195 | 195 |
| 196 NavigationController* ToolbarModelImpl::GetNavigationController() const { | 196 NavigationController* ToolbarModelImpl::GetNavigationController() const { |
| 197 // This |current_tab| can be NULL during the initialization of the | 197 // This |current_tab| can be NULL during the initialization of the |
| 198 // toolbar during window creation (i.e. before any tabs have been added | 198 // toolbar during window creation (i.e. before any tabs have been added |
| 199 // to the window). | 199 // to the window). |
| 200 WebContents* current_tab = delegate_->GetActiveWebContents(); | 200 WebContents* current_tab = delegate_->GetActiveWebContents(); |
| 201 return current_tab ? ¤t_tab->GetController() : NULL; | 201 return current_tab ? ¤t_tab->GetController() : NULL; |
| 202 } | 202 } |
| 203 | 203 |
| 204 Profile* ToolbarModelImpl::GetProfile() const { | 204 Profile* ToolbarModelImpl::GetProfile() const { |
| 205 NavigationController* navigation_controller = GetNavigationController(); | 205 NavigationController* navigation_controller = GetNavigationController(); |
| 206 return navigation_controller ? | 206 return navigation_controller ? |
| 207 Profile::FromBrowserContext(navigation_controller->GetBrowserContext()) : | 207 Profile::FromBrowserContext(navigation_controller->GetBrowserContext()) : |
| 208 NULL; | 208 NULL; |
| 209 } | 209 } |
| 210 | 210 |
| 211 base::string16 ToolbarModelImpl::GetSearchTerms(bool ignore_editing) const { | 211 base::string16 ToolbarModelImpl::GetSearchTerms(bool ignore_editing) const { |
| 212 if (!url_replacement_enabled() || (input_in_progress() && !ignore_editing)) | 212 if (!url_replacement_enabled() || (input_in_progress() && !ignore_editing)) |
| 213 return base::string16(); | 213 return base::string16(); |
| 214 | 214 |
| 215 const WebContents* web_contents = delegate_->GetActiveWebContents(); | 215 const WebContents* web_contents = delegate_->GetActiveWebContents(); |
| 216 base::string16 search_terms(chrome::GetSearchTerms(web_contents)); | 216 base::string16 search_terms(search::GetSearchTerms(web_contents)); |
| 217 if (search_terms.empty()) { | 217 if (search_terms.empty()) { |
| 218 // We mainly do this to enforce the subsequent DCHECK. | 218 // We mainly do this to enforce the subsequent DCHECK. |
| 219 return base::string16(); | 219 return base::string16(); |
| 220 } | 220 } |
| 221 | 221 |
| 222 // If the page is still loading and the security style is unknown, consider | 222 // If the page is still loading and the security style is unknown, consider |
| 223 // the page secure. Without this, after the user hit enter on some search | 223 // the page secure. Without this, after the user hit enter on some search |
| 224 // terms, the omnibox would change to displaying the loading URL before | 224 // terms, the omnibox would change to displaying the loading URL before |
| 225 // changing back to the search terms once they could be extracted, thus | 225 // changing back to the search terms once they could be extracted, thus |
| 226 // causing annoying flicker. | 226 // causing annoying flicker. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 239 | 239 |
| 240 // Otherwise, extract search terms for HTTPS pages that do not have a security | 240 // Otherwise, extract search terms for HTTPS pages that do not have a security |
| 241 // error. | 241 // error. |
| 242 connection_security::SecurityLevel security_level = | 242 connection_security::SecurityLevel security_level = |
| 243 GetSecurityLevel(ignore_editing); | 243 GetSecurityLevel(ignore_editing); |
| 244 return ((security_level == connection_security::NONE) || | 244 return ((security_level == connection_security::NONE) || |
| 245 (security_level == connection_security::SECURITY_ERROR)) | 245 (security_level == connection_security::SECURITY_ERROR)) |
| 246 ? base::string16() | 246 ? base::string16() |
| 247 : search_terms; | 247 : search_terms; |
| 248 } | 248 } |
| OLD | NEW |