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" |
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/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
17 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
18 #include "content/public/browser/render_frame_host.h" | 18 #include "content/public/browser/render_frame_host.h" |
19 #include "content/public/browser/storage_partition.h" | |
20 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
21 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
22 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 21 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
23 #include "net/url_request/url_fetcher.h" | 22 #include "net/url_request/url_fetcher.h" |
24 #include "net/url_request/url_request.h" | 23 #include "net/url_request/url_request.h" |
25 | 24 |
26 | 25 |
27 // Helpers -------------------------------------------------------------------- | 26 // Helpers -------------------------------------------------------------------- |
28 | 27 |
29 namespace { | 28 namespace { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // until then we ignore the incorrect navigation (and will be torn down | 110 // until then we ignore the incorrect navigation (and will be torn down |
112 // without having received the correct notification). | 111 // without having received the correct notification). |
113 if (match_.destination_url != | 112 if (match_.destination_url != |
114 content::Details<content::NavigationEntry>(details)->GetVirtualURL()) | 113 content::Details<content::NavigationEntry>(details)->GetVirtualURL()) |
115 return; | 114 return; |
116 | 115 |
117 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 116 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
118 content::NotificationService::AllSources()); | 117 content::NotificationService::AllSources()); |
119 if (fetcher_) { | 118 if (fetcher_) { |
120 fetcher_->SetRequestContext( | 119 fetcher_->SetRequestContext( |
121 content::BrowserContext::GetDefaultStoragePartition( | 120 controller->GetBrowserContext()->GetRequestContext()); |
122 controller->GetBrowserContext())->GetURLRequestContext()); | |
123 } | 121 } |
124 WebContentsObserver::Observe(web_contents); | 122 WebContentsObserver::Observe(web_contents); |
125 // DidStartNavigationToPendingEntry() will be called for this load as well. | 123 // DidStartNavigationToPendingEntry() will be called for this load as well. |
126 } | 124 } |
127 | 125 |
128 void ChromeOmniboxNavigationObserver::DidStartNavigationToPendingEntry( | 126 void ChromeOmniboxNavigationObserver::DidStartNavigationToPendingEntry( |
129 const GURL& url, | 127 const GURL& url, |
130 content::NavigationController::ReloadType reload_type) { | 128 content::NavigationController::ReloadType reload_type) { |
131 if (load_state_ == LOAD_NOT_SEEN) { | 129 if (load_state_ == LOAD_NOT_SEEN) { |
132 load_state_ = LOAD_PENDING; | 130 load_state_ = LOAD_PENDING; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 OnAllLoadingFinished(); // deletes |this|! | 177 OnAllLoadingFinished(); // deletes |this|! |
180 } | 178 } |
181 | 179 |
182 void ChromeOmniboxNavigationObserver::OnAllLoadingFinished() { | 180 void ChromeOmniboxNavigationObserver::OnAllLoadingFinished() { |
183 if (fetch_state_ == FETCH_SUCCEEDED) { | 181 if (fetch_state_ == FETCH_SUCCEEDED) { |
184 AlternateNavInfoBarDelegate::Create( | 182 AlternateNavInfoBarDelegate::Create( |
185 web_contents(), text_, alternate_nav_match_, match_.destination_url); | 183 web_contents(), text_, alternate_nav_match_, match_.destination_url); |
186 } | 184 } |
187 delete this; | 185 delete this; |
188 } | 186 } |
OLD | NEW |