Chromium Code Reviews| Index: chrome/browser/ui/omnibox/omnibox_navigation_observer.cc |
| =================================================================== |
| --- chrome/browser/ui/omnibox/omnibox_navigation_observer.cc (revision 228523) |
| +++ chrome/browser/ui/omnibox/omnibox_navigation_observer.cc (working copy) |
| @@ -4,6 +4,8 @@ |
| #include "chrome/browser/ui/omnibox/omnibox_navigation_observer.h" |
| +#include "chrome/browser/history/shortcuts_backend.h" |
| +#include "chrome/browser/history/shortcuts_backend_factory.h" |
| #include "chrome/browser/infobars/infobar_service.h" |
| #include "chrome/browser/intranet_redirect_detector.h" |
| #include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h" |
| @@ -49,8 +51,14 @@ |
| // OmniboxNavigationObserver -------------------------------------------------- |
| OmniboxNavigationObserver::OmniboxNavigationObserver( |
| + Profile* profile, |
| + const string16& text, |
| + const AutocompleteMatch& match, |
| const GURL& alternate_nav_url) |
| - : alternate_nav_url_(alternate_nav_url), |
| + : text_(text), |
| + match_(match), |
| + alternate_nav_url_(alternate_nav_url), |
| + shortcuts_backend_(ShortcutsBackendFactory::GetForProfile(profile)), |
| load_state_(LOAD_NOT_SEEN), |
| fetch_state_(FETCH_NOT_COMPLETE) { |
| if (alternate_nav_url_.is_valid()) { |
| @@ -68,6 +76,11 @@ |
| OmniboxNavigationObserver::~OmniboxNavigationObserver() { |
| } |
| +void OmniboxNavigationObserver::OnSuccessfulNavigation() { |
| + if (shortcuts_backend_) |
|
Bart N.
2013/10/16 17:42:47
This looks odd. The only place where you assign sh
|
| + shortcuts_backend_->OnOmniboxNavigation(text_, match_); |
| +} |
| + |
| void OmniboxNavigationObserver::Observe( |
| int type, |
| const content::NotificationSource& source, |
| @@ -88,6 +101,9 @@ |
| void OmniboxNavigationObserver::NavigationEntryCommitted( |
| const content::LoadCommittedDetails& load_details) { |
| load_state_ = LOAD_COMMITTED; |
| + if (ResponseCodeIndicatesSuccess(load_details.http_status_code) && |
| + IsValidNavigation(match_.destination_url, load_details.entry->GetURL())) |
| + OnSuccessfulNavigation(); |
| if (!fetcher_ || (fetch_state_ != FETCH_NOT_COMPLETE)) |
| OnAllLoadingFinished(); // deletes |this|! |
| } |
| @@ -111,6 +127,7 @@ |
| void OmniboxNavigationObserver::OnURLFetchComplete( |
| const net::URLFetcher* source) { |
| + DCHECK_EQ(fetcher_.get(), source); |
| const net::URLRequestStatus& status = source->GetStatus(); |
| int response_code = source->GetResponseCode(); |
| fetch_state_ = |