| Index: components/data_use_measurement/content/data_use_measurement_util.cc
|
| diff --git a/components/data_use_measurement/content/data_use_measurement_util.cc b/components/data_use_measurement/content/data_use_measurement_util.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1049a207225a1e55cf91f2d80cd41a110ff37c80
|
| --- /dev/null
|
| +++ b/components/data_use_measurement/content/data_use_measurement_util.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/data_use_measurement_util.h"
|
| +
|
| +#include "content/public/browser/resource_request_info.h"
|
| +#include "net/url_request/url_request.h"
|
| +
|
| +namespace data_use_measurement {
|
| +
|
| +DataUseMeasurement::IsUserInitiatedRequestCallbackType
|
| +GetIsUserInitiatedRequestCallback() {
|
| + return base::Bind(&IsUserInitiatedRequest);
|
| +}
|
| +
|
| +bool IsUserInitiatedRequest(const net::URLRequest& request) {
|
| + // Having ResourceRequestInfo in the URL request is a sign that the request is
|
| + // 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;
|
| +}
|
| +
|
| +} // namespace data_use_measurement
|
|
|