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