| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/omnibox/chrome_omnibox_navigation_observer.h" | 5 #include "chrome/browser/ui/omnibox/chrome_omnibox_navigation_observer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" | 7 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" |
| 8 #include "chrome/browser/infobars/infobar_service.h" | 8 #include "chrome/browser/infobars/infobar_service.h" |
| 9 #include "chrome/browser/intranet_redirect_detector.h" | 9 #include "chrome/browser/intranet_redirect_detector.h" |
| 10 #include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h" | 10 #include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 fetcher_->SetRequestContext( | 153 fetcher_->SetRequestContext( |
| 154 content::BrowserContext::GetDefaultStoragePartition( | 154 content::BrowserContext::GetDefaultStoragePartition( |
| 155 controller->GetBrowserContext())->GetURLRequestContext()); | 155 controller->GetBrowserContext())->GetURLRequestContext()); |
| 156 } | 156 } |
| 157 WebContentsObserver::Observe(web_contents); | 157 WebContentsObserver::Observe(web_contents); |
| 158 // DidStartNavigationToPendingEntry() will be called for this load as well. | 158 // DidStartNavigationToPendingEntry() will be called for this load as well. |
| 159 } | 159 } |
| 160 | 160 |
| 161 void ChromeOmniboxNavigationObserver::DidStartNavigation( | 161 void ChromeOmniboxNavigationObserver::DidStartNavigation( |
| 162 content::NavigationHandle* navigation_handle) { | 162 content::NavigationHandle* navigation_handle) { |
| 163 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage()) | 163 if (!navigation_handle->IsInMainFrame() || |
| 164 navigation_handle->IsSameDocument()) { |
| 164 return; | 165 return; |
| 166 } |
| 165 | 167 |
| 166 if (load_state_ == LOAD_NOT_SEEN) { | 168 if (load_state_ == LOAD_NOT_SEEN) { |
| 167 load_state_ = LOAD_PENDING; | 169 load_state_ = LOAD_PENDING; |
| 168 if (fetcher_) | 170 if (fetcher_) |
| 169 fetcher_->Start(); | 171 fetcher_->Start(); |
| 170 } else { | 172 } else { |
| 171 delete this; | 173 delete this; |
| 172 } | 174 } |
| 173 } | 175 } |
| 174 | 176 |
| 175 void ChromeOmniboxNavigationObserver::DidFinishNavigation( | 177 void ChromeOmniboxNavigationObserver::DidFinishNavigation( |
| 176 content::NavigationHandle* navigation_handle) { | 178 content::NavigationHandle* navigation_handle) { |
| 177 if ((load_state_ != LOAD_COMMITTED) && | 179 if ((load_state_ != LOAD_COMMITTED) && navigation_handle->IsErrorPage() && |
| 178 navigation_handle->IsErrorPage() && | |
| 179 navigation_handle->IsInMainFrame() && | 180 navigation_handle->IsInMainFrame() && |
| 180 !navigation_handle->IsSamePage()) | 181 !navigation_handle->IsSameDocument()) |
| 181 delete this; | 182 delete this; |
| 182 } | 183 } |
| 183 | 184 |
| 184 void ChromeOmniboxNavigationObserver::NavigationEntryCommitted( | 185 void ChromeOmniboxNavigationObserver::NavigationEntryCommitted( |
| 185 const content::LoadCommittedDetails& load_details) { | 186 const content::LoadCommittedDetails& load_details) { |
| 186 load_state_ = LOAD_COMMITTED; | 187 load_state_ = LOAD_COMMITTED; |
| 187 if (ResponseCodeIndicatesSuccess(load_details.http_status_code) && | 188 if (ResponseCodeIndicatesSuccess(load_details.http_status_code) && |
| 188 IsValidNavigation(match_.destination_url, | 189 IsValidNavigation(match_.destination_url, |
| 189 load_details.entry->GetVirtualURL())) | 190 load_details.entry->GetVirtualURL())) |
| 190 OnSuccessfulNavigation(); | 191 OnSuccessfulNavigation(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 213 OnAllLoadingFinished(); // deletes |this|! | 214 OnAllLoadingFinished(); // deletes |this|! |
| 214 } | 215 } |
| 215 | 216 |
| 216 void ChromeOmniboxNavigationObserver::OnAllLoadingFinished() { | 217 void ChromeOmniboxNavigationObserver::OnAllLoadingFinished() { |
| 217 if (fetch_state_ == FETCH_SUCCEEDED) { | 218 if (fetch_state_ == FETCH_SUCCEEDED) { |
| 218 AlternateNavInfoBarDelegate::Create( | 219 AlternateNavInfoBarDelegate::Create( |
| 219 web_contents(), text_, alternate_nav_match_, match_.destination_url); | 220 web_contents(), text_, alternate_nav_match_, match_.destination_url); |
| 220 } | 221 } |
| 221 delete this; | 222 delete this; |
| 222 } | 223 } |
| OLD | NEW |