Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: chrome/browser/ui/omnibox/chrome_omnibox_navigation_observer.cc

Issue 2636183004: Convert ChromeOmniboxNavigationObserver to use the new navigation callbacks. (Closed)
Patch Set: closer to original Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/omnibox/chrome_omnibox_navigation_observer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "components/omnibox/browser/shortcuts_backend.h" 11 #include "components/omnibox/browser/shortcuts_backend.h"
12 #include "content/public/browser/browser_context.h" 12 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/navigation_controller.h" 13 #include "content/public/browser/navigation_controller.h"
14 #include "content/public/browser/navigation_details.h" 14 #include "content/public/browser/navigation_details.h"
15 #include "content/public/browser/navigation_entry.h" 15 #include "content/public/browser/navigation_entry.h"
16 #include "content/public/browser/navigation_handle.h"
16 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
17 #include "content/public/browser/notification_types.h" 18 #include "content/public/browser/notification_types.h"
18 #include "content/public/browser/render_frame_host.h" 19 #include "content/public/browser/render_frame_host.h"
19 #include "content/public/browser/storage_partition.h" 20 #include "content/public/browser/storage_partition.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 #include "net/base/load_flags.h" 22 #include "net/base/load_flags.h"
22 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 23 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
23 #include "net/url_request/url_fetcher.h" 24 #include "net/url_request/url_fetcher.h"
24 #include "net/url_request/url_request.h" 25 #include "net/url_request/url_request.h"
25 26
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 content::NotificationService::AllSources()); 119 content::NotificationService::AllSources());
119 if (fetcher_) { 120 if (fetcher_) {
120 fetcher_->SetRequestContext( 121 fetcher_->SetRequestContext(
121 content::BrowserContext::GetDefaultStoragePartition( 122 content::BrowserContext::GetDefaultStoragePartition(
122 controller->GetBrowserContext())->GetURLRequestContext()); 123 controller->GetBrowserContext())->GetURLRequestContext());
123 } 124 }
124 WebContentsObserver::Observe(web_contents); 125 WebContentsObserver::Observe(web_contents);
125 // DidStartNavigationToPendingEntry() will be called for this load as well. 126 // DidStartNavigationToPendingEntry() will be called for this load as well.
126 } 127 }
127 128
128 void ChromeOmniboxNavigationObserver::DidStartNavigationToPendingEntry( 129 void ChromeOmniboxNavigationObserver::DidStartNavigation(
129 const GURL& url, 130 content::NavigationHandle* navigation_handle) {
130 content::ReloadType reload_type) { 131 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage())
132 return;
133
131 if (load_state_ == LOAD_NOT_SEEN) { 134 if (load_state_ == LOAD_NOT_SEEN) {
132 load_state_ = LOAD_PENDING; 135 load_state_ = LOAD_PENDING;
133 if (fetcher_) 136 if (fetcher_)
134 fetcher_->Start(); 137 fetcher_->Start();
135 } else { 138 } else {
136 delete this; 139 delete this;
137 } 140 }
138 } 141 }
139 142
140 void ChromeOmniboxNavigationObserver::DidFailProvisionalLoad( 143 void ChromeOmniboxNavigationObserver::DidFinishNavigation(
141 content::RenderFrameHost* render_frame_host, 144 content::NavigationHandle* navigation_handle) {
142 const GURL& validated_url, 145 if ((load_state_ != LOAD_COMMITTED) &&
143 int error_code, 146 navigation_handle->IsErrorPage() &&
Peter Kasting 2017/01/24 00:15:31 Does IsErrorPage() mean the same thing that "faile
jam 2017/01/24 00:21:51 Yep should be. A failing provisional load is equiv
jam 2017/01/24 00:22:26 but if you have any test cases that aren't in exis
144 const base::string16& error_description, 147 navigation_handle->IsInMainFrame() &&
145 bool was_ignored_by_handler) { 148 !navigation_handle->IsSamePage())
146 if ((load_state_ != LOAD_COMMITTED) && !render_frame_host->GetParent())
147 delete this; 149 delete this;
148 } 150 }
149 151
150 void ChromeOmniboxNavigationObserver::NavigationEntryCommitted( 152 void ChromeOmniboxNavigationObserver::NavigationEntryCommitted(
151 const content::LoadCommittedDetails& load_details) { 153 const content::LoadCommittedDetails& load_details) {
152 load_state_ = LOAD_COMMITTED; 154 load_state_ = LOAD_COMMITTED;
153 if (ResponseCodeIndicatesSuccess(load_details.http_status_code) && 155 if (ResponseCodeIndicatesSuccess(load_details.http_status_code) &&
154 IsValidNavigation(match_.destination_url, 156 IsValidNavigation(match_.destination_url,
155 load_details.entry->GetVirtualURL())) 157 load_details.entry->GetVirtualURL()))
156 OnSuccessfulNavigation(); 158 OnSuccessfulNavigation();
(...skipping 22 matching lines...) Expand all
179 OnAllLoadingFinished(); // deletes |this|! 181 OnAllLoadingFinished(); // deletes |this|!
180 } 182 }
181 183
182 void ChromeOmniboxNavigationObserver::OnAllLoadingFinished() { 184 void ChromeOmniboxNavigationObserver::OnAllLoadingFinished() {
183 if (fetch_state_ == FETCH_SUCCEEDED) { 185 if (fetch_state_ == FETCH_SUCCEEDED) {
184 AlternateNavInfoBarDelegate::Create( 186 AlternateNavInfoBarDelegate::Create(
185 web_contents(), text_, alternate_nav_match_, match_.destination_url); 187 web_contents(), text_, alternate_nav_match_, match_.destination_url);
186 } 188 }
187 delete this; 189 delete this;
188 } 190 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/chrome_omnibox_navigation_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698