Chromium Code Reviews| Index: components/data_use_measurement/content/chrome_url_request_classifier.cc |
| diff --git a/components/data_use_measurement/content/chrome_url_request_classifier.cc b/components/data_use_measurement/content/chrome_url_request_classifier.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..88841fbb457eee6200399d7810bb55d1665c286b |
| --- /dev/null |
| +++ b/components/data_use_measurement/content/chrome_url_request_classifier.cc |
| @@ -0,0 +1,29 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/data_use_measurement/content/chrome_url_request_classifier.h" |
| + |
| +#include "content/public/browser/resource_request_info.h" |
| +#include "net/url_request/url_request.h" |
| + |
| +namespace data_use_measurement { |
| + |
| +bool IsUserInitiatedRequest(const net::URLRequest& request) { |
|
RyanSturm
2016/11/10 22:50:30
User Initiated usually means the user clicked a li
Raj
2016/11/10 23:20:26
Done.
|
| + // Having ResourceRequestInfo in the URL request is a sign that the request is |
|
RyanSturm
2016/11/10 22:50:30
This can probably be shortened to:
"The presence
Raj
2016/11/10 23:20:26
Done.
|
| + // for a web content from user. For now we could add a condition to check |
| + // ProcessType in info is content::PROCESS_TYPE_RENDERER, but it won't be |
| + // compatible with upcoming PlzNavigate architecture. So just existence of |
| + // ResourceRequestInfo is verified, and the current check should be compatible |
| + // with upcoming changes in PlzNavigate. |
| + // TODO(rajendrant): Verify this condition for different use cases. See |
| + // crbug.com/626063. |
| + return content::ResourceRequestInfo::ForRequest(&request) != nullptr; |
| +} |
| + |
| +bool ChromeURLRequestClassifier::IsUserInitiatedRequest( |
| + const net::URLRequest& request) const { |
| + return IsUserInitiatedRequest(request); |
| +} |
| + |
| +} // namespace data_use_measurement |