Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/omnibox/omnibox_current_page_delegate_impl.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_current_page_delegate_impl.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/autocomplete/autocomplete_match.h" | 8 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 9 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 9 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
| 10 #include "chrome/browser/predictors/autocomplete_action_predictor.h" | 10 #include "chrome/browser/predictors/autocomplete_action_predictor.h" |
| 11 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" | 11 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/search/search.h" | 13 #include "chrome/browser/search/search.h" |
| 14 #include "chrome/browser/search_engines/template_url_service.h" | |
| 15 #include "chrome/browser/search_engines/template_url_service_factory.h" | |
| 14 #include "chrome/browser/sessions/session_tab_helper.h" | 16 #include "chrome/browser/sessions/session_tab_helper.h" |
| 15 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 17 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
| 16 #include "chrome/browser/ui/search/search_tab_helper.h" | 18 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 17 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
| 18 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 19 #include "content/public/browser/web_contents_view.h" | 21 #include "content/public/browser/web_contents_view.h" |
| 20 #include "ui/base/window_open_disposition.h" | 22 #include "ui/base/window_open_disposition.h" |
| 21 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 22 | 24 |
| 23 OmniboxCurrentPageDelegateImpl::OmniboxCurrentPageDelegateImpl( | 25 OmniboxCurrentPageDelegateImpl::OmniboxCurrentPageDelegateImpl( |
| 24 OmniboxEditController* controller, | 26 OmniboxEditController* controller, |
| 25 Profile* profile) | 27 Profile* profile) |
| 26 : controller_(controller), | 28 : controller_(controller), |
| 27 profile_(profile) {} | 29 profile_(profile) {} |
| 28 | 30 |
| 29 OmniboxCurrentPageDelegateImpl::~OmniboxCurrentPageDelegateImpl() {} | 31 OmniboxCurrentPageDelegateImpl::~OmniboxCurrentPageDelegateImpl() {} |
| 30 | 32 |
| 31 bool OmniboxCurrentPageDelegateImpl::CurrentPageExists() const { | 33 bool OmniboxCurrentPageDelegateImpl::CurrentPageExists() const { |
| 32 return (controller_->GetWebContents() != NULL); | 34 return (controller_->GetWebContents() != NULL); |
| 33 } | 35 } |
| 34 | 36 |
| 35 const GURL& OmniboxCurrentPageDelegateImpl::GetURL() const { | 37 const GURL& OmniboxCurrentPageDelegateImpl::GetURL() const { |
| 36 return controller_->GetWebContents()->GetURL(); | 38 return controller_->GetWebContents()->GetURL(); |
| 37 } | 39 } |
| 38 | 40 |
| 39 bool OmniboxCurrentPageDelegateImpl::IsInstantNTP() const { | 41 bool OmniboxCurrentPageDelegateImpl::IsInstantNTP() const { |
| 40 return chrome::IsInstantNTP(controller_->GetWebContents()); | 42 return chrome::IsInstantNTP(controller_->GetWebContents()); |
| 41 } | 43 } |
| 42 | 44 |
| 45 bool OmniboxCurrentPageDelegateImpl::IsSearchResultsPage() const { | |
| 46 content::WebContents* web_contents = controller_->GetWebContents(); | |
| 47 Profile* profile = | |
| 48 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | |
| 49 return TemplateURLServiceFactory::GetForProfile(profile)-> | |
| 50 IsSearchResultsPageFromDefaultSearchProvider(GetURL()); | |
|
Mark P
2013/08/06 19:38:36
optional nit: consider web_contents->GetURL()
(oth
Peter Kasting
2013/08/06 21:32:19
I'd probably resolve this by just inlining the fir
rpetterson
2013/08/06 23:04:17
I was trying to make it more readable. I've cleane
| |
| 51 } | |
| 52 | |
| 43 bool OmniboxCurrentPageDelegateImpl::IsLoading() const { | 53 bool OmniboxCurrentPageDelegateImpl::IsLoading() const { |
| 44 return controller_->GetWebContents()->IsLoading(); | 54 return controller_->GetWebContents()->IsLoading(); |
| 45 } | 55 } |
| 46 | 56 |
| 47 content::NavigationController& | 57 content::NavigationController& |
| 48 OmniboxCurrentPageDelegateImpl::GetNavigationController() const { | 58 OmniboxCurrentPageDelegateImpl::GetNavigationController() const { |
| 49 return controller_->GetWebContents()->GetController(); | 59 return controller_->GetWebContents()->GetController(); |
| 50 } | 60 } |
| 51 | 61 |
| 52 const SessionID& OmniboxCurrentPageDelegateImpl::GetSessionID() const { | 62 const SessionID& OmniboxCurrentPageDelegateImpl::GetSessionID() const { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 const AutocompleteMatch& match) { | 96 const AutocompleteMatch& match) { |
| 87 content::WebContents* web_contents = controller_->GetWebContents(); | 97 content::WebContents* web_contents = controller_->GetWebContents(); |
| 88 gfx::Rect container_bounds; | 98 gfx::Rect container_bounds; |
| 89 web_contents->GetView()->GetContainerBounds(&container_bounds); | 99 web_contents->GetView()->GetContainerBounds(&container_bounds); |
| 90 predictors::AutocompleteActionPredictorFactory::GetForProfile(profile_)-> | 100 predictors::AutocompleteActionPredictorFactory::GetForProfile(profile_)-> |
| 91 StartPrerendering( | 101 StartPrerendering( |
| 92 match.destination_url, | 102 match.destination_url, |
| 93 web_contents->GetController().GetSessionStorageNamespaceMap(), | 103 web_contents->GetController().GetSessionStorageNamespaceMap(), |
| 94 container_bounds.size()); | 104 container_bounds.size()); |
| 95 } | 105 } |
| OLD | NEW |