Chromium Code Reviews| 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/navigation_handle.h" | 16 #include "content/public/browser/navigation_handle.h" |
| 17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/notification_types.h" | 18 #include "content/public/browser/notification_types.h" |
| 19 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
| 20 #include "content/public/browser/storage_partition.h" | 20 #include "content/public/browser/storage_partition.h" |
| 21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "net/base/load_flags.h" | 22 #include "net/base/load_flags.h" |
| 23 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 23 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 24 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 24 #include "net/url_request/url_fetcher.h" | 25 #include "net/url_request/url_fetcher.h" |
| 25 #include "net/url_request/url_request.h" | 26 #include "net/url_request/url_request.h" |
| 26 | 27 |
| 27 | 28 |
| 28 // Helpers -------------------------------------------------------------------- | 29 // Helpers -------------------------------------------------------------------- |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 // HTTP 2xx, 401, and 407 all indicate that the target address exists. | 33 // HTTP 2xx, 401, and 407 all indicate that the target address exists. |
| 33 bool ResponseCodeIndicatesSuccess(int response_code) { | 34 bool ResponseCodeIndicatesSuccess(int response_code) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 57 const base::string16& text, | 58 const base::string16& text, |
| 58 const AutocompleteMatch& match, | 59 const AutocompleteMatch& match, |
| 59 const AutocompleteMatch& alternate_nav_match) | 60 const AutocompleteMatch& alternate_nav_match) |
| 60 : text_(text), | 61 : text_(text), |
| 61 match_(match), | 62 match_(match), |
| 62 alternate_nav_match_(alternate_nav_match), | 63 alternate_nav_match_(alternate_nav_match), |
| 63 shortcuts_backend_(ShortcutsBackendFactory::GetForProfile(profile)), | 64 shortcuts_backend_(ShortcutsBackendFactory::GetForProfile(profile)), |
| 64 load_state_(LOAD_NOT_SEEN), | 65 load_state_(LOAD_NOT_SEEN), |
| 65 fetch_state_(FETCH_NOT_COMPLETE) { | 66 fetch_state_(FETCH_NOT_COMPLETE) { |
| 66 if (alternate_nav_match_.destination_url.is_valid()) { | 67 if (alternate_nav_match_.destination_url.is_valid()) { |
| 68 net::NetworkTrafficAnnotationTag traffic_annotation = | |
| 69 net::DefineNetworkTrafficAnnotation("...", R"( | |
| 70 semantics { | |
| 71 sender: "..." | |
|
Peter Kasting
2017/02/24 03:06:33
omnibox
Ramin Halavati
2017/02/24 07:38:51
Done.
| |
| 72 description: "..." | |
|
Peter Kasting
2017/02/24 03:06:33
Certain omnibox inputs, e.g. single words, may eit
Ramin Halavati
2017/02/24 07:38:52
Done.
| |
| 73 trigger: "..." | |
|
Peter Kasting
2017/02/24 03:06:33
User attempts to search for a string that is plaus
Ramin Halavati
2017/02/24 07:38:51
Done.
| |
| 74 data: "..." | |
|
Peter Kasting
2017/02/24 03:06:33
None. However, the hostname itself is a string th
Ramin Halavati
2017/02/24 07:38:51
Done.
| |
| 75 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
|
Peter Kasting
2017/02/24 03:06:34
WEBSITE
Ramin Halavati
2017/02/24 07:38:51
Done.
| |
| 76 } | |
| 77 policy { | |
| 78 cookies_allowed: false/true | |
|
Peter Kasting
2017/02/24 03:06:33
true
Ramin Halavati
2017/02/24 07:38:52
Done.
| |
| 79 cookies_store: "..." | |
|
Peter Kasting
2017/02/24 03:06:33
I'm not sure. The actual request context is on li
Ramin Halavati
2017/02/24 07:38:51
Done.
| |
| 80 setting: "..." | |
|
Peter Kasting
2017/02/24 03:06:33
NA
Ramin Halavati
2017/02/24 07:38:51
Done.
| |
| 81 policy { | |
| 82 [POLICY_NAME] { | |
| 83 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
| 84 value: ... | |
| 85 } | |
| 86 } | |
|
Peter Kasting
2017/02/24 03:06:33
The closest policy we have for this is DefaultSear
Ramin Halavati
2017/02/24 07:38:51
Done.
| |
| 87 policy_exception_justification: "..." | |
| 88 })"); | |
| 67 fetcher_ = net::URLFetcher::Create(alternate_nav_match_.destination_url, | 89 fetcher_ = net::URLFetcher::Create(alternate_nav_match_.destination_url, |
| 68 net::URLFetcher::HEAD, this); | 90 net::URLFetcher::HEAD, this, |
| 91 traffic_annotation); | |
| 69 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); | 92 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); |
| 70 fetcher_->SetStopOnRedirect(true); | 93 fetcher_->SetStopOnRedirect(true); |
| 71 } | 94 } |
| 72 // We need to start by listening to AllSources, since we don't know which tab | 95 // We need to start by listening to AllSources, since we don't know which tab |
| 73 // the navigation might occur in. | 96 // the navigation might occur in. |
| 74 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 97 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
| 75 content::NotificationService::AllSources()); | 98 content::NotificationService::AllSources()); |
| 76 } | 99 } |
| 77 | 100 |
| 78 ChromeOmniboxNavigationObserver::~ChromeOmniboxNavigationObserver() {} | 101 ChromeOmniboxNavigationObserver::~ChromeOmniboxNavigationObserver() {} |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 OnAllLoadingFinished(); // deletes |this|! | 204 OnAllLoadingFinished(); // deletes |this|! |
| 182 } | 205 } |
| 183 | 206 |
| 184 void ChromeOmniboxNavigationObserver::OnAllLoadingFinished() { | 207 void ChromeOmniboxNavigationObserver::OnAllLoadingFinished() { |
| 185 if (fetch_state_ == FETCH_SUCCEEDED) { | 208 if (fetch_state_ == FETCH_SUCCEEDED) { |
| 186 AlternateNavInfoBarDelegate::Create( | 209 AlternateNavInfoBarDelegate::Create( |
| 187 web_contents(), text_, alternate_nav_match_, match_.destination_url); | 210 web_contents(), text_, alternate_nav_match_, match_.destination_url); |
| 188 } | 211 } |
| 189 delete this; | 212 delete this; |
| 190 } | 213 } |
| OLD | NEW |