// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_ENTERPRISE_CONNECTORS_ANALYSIS_CONTENT_ANALYSIS_DELEGATE_H_ #define CHROME_BROWSER_ENTERPRISE_CONNECTORS_ANALYSIS_CONTENT_ANALYSIS_DELEGATE_H_ #include <memory> #include <string> #include <vector> #include "base/files/file_path.h" #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "base/memory/read_only_shared_memory_region.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "chrome/browser/enterprise/connectors/analysis/content_analysis_delegate_base.h" #include "chrome/browser/enterprise/connectors/common.h" #include "chrome/browser/safe_browsing/cloud_content_scanning/binary_upload_service.h" #include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_utils.h" #include "components/enterprise/common/proto/connectors.pb.h" #include "components/enterprise/connectors/core/analysis_settings.h" #include "content/public/browser/clipboard_types.h" #include "url/gurl.h" class Profile; namespace content { class WebContent; } // namespace content namespace enterprise_connectors { class ContentAnalysisDialog; class FilesRequestHandler; // A BinaryUploadService::Request implementation that gets the data to scan // from a string. This class is public to allow testing. class StringAnalysisRequest : public safe_browsing::BinaryUploadService::Request { … }; // A class that performs deep scans of data (for example malicious or sensitive // content checks) before allowing a page to access it. // // If the UI is enabled, then a dialog is shown and blocks user interactions // with the page until a scan verdict is obtained. // // If the UI is not enabled, then the dialog is not shown and the delegate // proceeds as if all data (strings and files) have successfully passed the // deep checks. However the checks are still performed in the background and // verdicts reported, implementing an audit-only mode. // // Users of this class normally call IsEnabled() first to determine if deep // scanning is required for the given web page. If so, the caller fills in // the appropriate data members of `Data` and then call CreateForWebContents() // to start the scan. // // Example: // // contents::WebContent* contents = ... // Profile* profile = ... // safe_browsing::ContentAnalysisDelegate::Data data; // if (safe_browsing::ContentAnalysisDelegate::IsEnabled( // profile, contents->GetLastCommittedURL(), &data)) { // data.text.push_back(...); // As needed. // data.paths.push_back(...); // As needed. // safe_browsing::ContentAnalysisDelegate::CreateForWebContents( // contents, std::move(data), base::BindOnce(...)); // } class ContentAnalysisDelegate : public ContentAnalysisDelegateBase { … }; } // namespace enterprise_connectors #endif // CHROME_BROWSER_ENTERPRISE_CONNECTORS_ANALYSIS_CONTENT_ANALYSIS_DELEGATE_H_