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

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

Issue 2709543002: Network traffic annotation added to chrome_omnibox_navigation_observer. (Closed)
Patch Set: Minor correction. Created 3 years, 10 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 | « no previous file | 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/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
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("omnibox_navigation_observer", R"(
70 semantics {
71 sender: "Omnibox"
72 description:
73 "Certain omnibox inputs, e.g. single words, may either be search "
74 "queries or attempts to navigate to intranet hostnames. When "
75 "such a hostname is not in the user's history, a background "
76 "request is made to see if it is navigable. If so, the browser "
77 "will display a prompt on the search results page asking if the "
78 "user wished to navigate instead of searching."
79 trigger:
80 "User attempts to search for a string that is plausibly a "
81 "navigable hostname but is not in the local history."
82 data:
83 "None. However, the hostname itself is a string the user "
84 "searched for, and thus can expose data about the user's "
85 "searches."
86 destination: WEBSITE
87 }
88 policy {
89 cookies_allowed: true
90 cookies_store: "user"
91 setting: "This feature cannot be disabled in settings."
92 policy_exception_justification:
93 "By disabling DefaultSearchProviderEnabled, one can disable "
94 "default search, and once users can't search, they can't hit "
95 "this. More fine-grained policies are requested to be "
96 "implemented (crbug.com/81226)."
97 })");
67 fetcher_ = net::URLFetcher::Create(alternate_nav_match_.destination_url, 98 fetcher_ = net::URLFetcher::Create(alternate_nav_match_.destination_url,
68 net::URLFetcher::HEAD, this); 99 net::URLFetcher::HEAD, this,
100 traffic_annotation);
69 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); 101 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
70 fetcher_->SetStopOnRedirect(true); 102 fetcher_->SetStopOnRedirect(true);
71 } 103 }
72 // We need to start by listening to AllSources, since we don't know which tab 104 // We need to start by listening to AllSources, since we don't know which tab
73 // the navigation might occur in. 105 // the navigation might occur in.
74 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 106 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
75 content::NotificationService::AllSources()); 107 content::NotificationService::AllSources());
76 } 108 }
77 109
78 ChromeOmniboxNavigationObserver::~ChromeOmniboxNavigationObserver() {} 110 ChromeOmniboxNavigationObserver::~ChromeOmniboxNavigationObserver() {}
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 OnAllLoadingFinished(); // deletes |this|! 213 OnAllLoadingFinished(); // deletes |this|!
182 } 214 }
183 215
184 void ChromeOmniboxNavigationObserver::OnAllLoadingFinished() { 216 void ChromeOmniboxNavigationObserver::OnAllLoadingFinished() {
185 if (fetch_state_ == FETCH_SUCCEEDED) { 217 if (fetch_state_ == FETCH_SUCCEEDED) {
186 AlternateNavInfoBarDelegate::Create( 218 AlternateNavInfoBarDelegate::Create(
187 web_contents(), text_, alternate_nav_match_, match_.destination_url); 219 web_contents(), text_, alternate_nav_match_, match_.destination_url);
188 } 220 }
189 delete this; 221 delete this;
190 } 222 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698