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/omnibox_navigation_observer.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_navigation_observer.h" |
6 | 6 |
7 #include "chrome/browser/history/shortcuts_backend.h" | 7 #include "chrome/browser/history/shortcuts_backend.h" |
8 #include "chrome/browser/history/shortcuts_backend_factory.h" | 8 #include "chrome/browser/history/shortcuts_backend_factory.h" |
9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
10 #include "chrome/browser/intranet_redirect_detector.h" | 10 #include "chrome/browser/intranet_redirect_detector.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type); | 88 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type); |
89 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 89 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
90 content::NotificationService::AllSources()); | 90 content::NotificationService::AllSources()); |
91 content::NavigationController* controller = | 91 content::NavigationController* controller = |
92 content::Source<content::NavigationController>(source).ptr(); | 92 content::Source<content::NavigationController>(source).ptr(); |
93 if (fetcher_) { | 93 if (fetcher_) { |
94 fetcher_->SetRequestContext( | 94 fetcher_->SetRequestContext( |
95 controller->GetBrowserContext()->GetRequestContext()); | 95 controller->GetBrowserContext()->GetRequestContext()); |
96 } | 96 } |
97 WebContentsObserver::Observe(controller->GetWebContents()); | 97 WebContentsObserver::Observe(controller->GetWebContents()); |
98 // NavigateToPendingEntry() will be called for this load as well. | 98 // DidStartNavigationToPendingEntry() will be called for this load as well. |
99 } | 99 } |
100 | 100 |
101 void OmniboxNavigationObserver::NavigationEntryCommitted( | 101 void OmniboxNavigationObserver::NavigationEntryCommitted( |
102 const content::LoadCommittedDetails& load_details) { | 102 const content::LoadCommittedDetails& load_details) { |
103 load_state_ = LOAD_COMMITTED; | 103 load_state_ = LOAD_COMMITTED; |
104 if (ResponseCodeIndicatesSuccess(load_details.http_status_code) && | 104 if (ResponseCodeIndicatesSuccess(load_details.http_status_code) && |
105 IsValidNavigation(match_.destination_url, load_details.entry->GetURL())) | 105 IsValidNavigation(match_.destination_url, load_details.entry->GetURL())) |
106 OnSuccessfulNavigation(); | 106 OnSuccessfulNavigation(); |
107 if (!fetcher_ || (fetch_state_ != FETCH_NOT_COMPLETE)) | 107 if (!fetcher_ || (fetch_state_ != FETCH_NOT_COMPLETE)) |
108 OnAllLoadingFinished(); // deletes |this|! | 108 OnAllLoadingFinished(); // deletes |this|! |
109 } | 109 } |
110 | 110 |
111 void OmniboxNavigationObserver::WebContentsDestroyed( | 111 void OmniboxNavigationObserver::WebContentsDestroyed( |
112 content::WebContents* web_contents) { | 112 content::WebContents* web_contents) { |
113 delete this; | 113 delete this; |
114 } | 114 } |
115 | 115 |
116 void OmniboxNavigationObserver::NavigateToPendingEntry( | 116 void OmniboxNavigationObserver::DidStartNavigationToPendingEntry( |
117 const GURL& url, | 117 const GURL& url, |
118 content::NavigationController::ReloadType reload_type) { | 118 content::NavigationController::ReloadType reload_type) { |
119 if (load_state_ == LOAD_NOT_SEEN) { | 119 if (load_state_ == LOAD_NOT_SEEN) { |
120 load_state_ = LOAD_PENDING; | 120 load_state_ = LOAD_PENDING; |
121 if (fetcher_) | 121 if (fetcher_) |
122 fetcher_->Start(); | 122 fetcher_->Start(); |
123 } else { | 123 } else { |
124 delete this; | 124 delete this; |
125 } | 125 } |
126 } | 126 } |
(...skipping 14 matching lines...) Expand all Loading... |
141 OnAllLoadingFinished(); // deletes |this|! | 141 OnAllLoadingFinished(); // deletes |this|! |
142 } | 142 } |
143 | 143 |
144 void OmniboxNavigationObserver::OnAllLoadingFinished() { | 144 void OmniboxNavigationObserver::OnAllLoadingFinished() { |
145 if (fetch_state_ == FETCH_SUCCEEDED) { | 145 if (fetch_state_ == FETCH_SUCCEEDED) { |
146 AlternateNavInfoBarDelegate::Create( | 146 AlternateNavInfoBarDelegate::Create( |
147 web_contents(), text_, alternate_nav_match_, match_.destination_url); | 147 web_contents(), text_, alternate_nav_match_, match_.destination_url); |
148 } | 148 } |
149 delete this; | 149 delete this; |
150 } | 150 } |
OLD | NEW |