#include "chrome/browser/renderer_context_menu/link_to_text_menu_observer.h"
#include <memory>
#include "base/memory/ptr_util.h"
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/enterprise/data_protection/data_protection_clipboard_utils.h"
#include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/toasts/api/toast_id.h"
#include "chrome/browser/ui/toasts/toast_controller.h"
#include "chrome/browser/ui/toasts/toast_features.h"
#include "chrome/grit/generated_resources.h"
#include "components/feature_engagement/public/tracker.h"
#include "components/renderer_context_menu/render_view_context_menu_proxy.h"
#include "components/shared_highlighting/core/common/disabled_sites.h"
#include "components/shared_highlighting/core/common/fragment_directives_constants.h"
#include "components/shared_highlighting/core/common/fragment_directives_utils.h"
#include "components/shared_highlighting/core/common/shared_highlighting_features.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/clipboard_types.h"
#include "content/public/browser/context_menu_params.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/process_manager.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "ui/base/data_transfer_policy/data_transfer_endpoint.h"
#include "ui/base/l10n/l10n_util.h"
LinkGenerationError;
LinkGenerationReadyStatus;
LinkGenerationStatus;
namespace {
void RemoveHighlightsInFrame(content::RenderFrameHost* render_frame_host) { … }
base::OnceCallback<void(const std::string& selector)>*
GetGenerationCompleteCallbackForTesting() { … }
std::vector<std::string> GetAggregatedSelectors(
std::unordered_map<content::GlobalRenderFrameHostId,
std::vector<std::string>,
content::GlobalRenderFrameHostIdHasher> frames_selectors,
std::vector<content::GlobalRenderFrameHostId> render_frame_host_ids) { … }
}
std::unique_ptr<LinkToTextMenuObserver> LinkToTextMenuObserver::Create(
RenderViewContextMenuProxy* proxy,
content::GlobalRenderFrameHostId render_frame_host_id,
ToastController* toast_controller) { … }
LinkToTextMenuObserver::LinkToTextMenuObserver(
RenderViewContextMenuProxy* proxy,
content::GlobalRenderFrameHostId render_frame_host_id,
ToastController* toast_controller)
: … { … }
LinkToTextMenuObserver::~LinkToTextMenuObserver() = default;
void LinkToTextMenuObserver::InitMenu(
const content::ContextMenuParams& params) { … }
bool LinkToTextMenuObserver::IsCommandIdSupported(int command_id) { … }
bool LinkToTextMenuObserver::IsCommandIdEnabled(int command_id) { … }
void LinkToTextMenuObserver::ExecuteCommand(int command_id) { … }
void LinkToTextMenuObserver::OnRequestLinkGenerationCompleted(
const std::string& selector,
LinkGenerationError error,
LinkGenerationReadyStatus ready_status) { … }
void LinkToTextMenuObserver::RegisterGenerationCompleteCallbackForTesting(
base::OnceCallback<void(const std::string& selector)> cb) { … }
void LinkToTextMenuObserver::RequestLinkGeneration() { … }
void LinkToTextMenuObserver::StartLinkGenerationRequestWithTimeout() { … }
void LinkToTextMenuObserver::ExecuteCopyLinkToText() { … }
void LinkToTextMenuObserver::Timeout() { … }
void LinkToTextMenuObserver::CompleteWithError(LinkGenerationError error) { … }
void LinkToTextMenuObserver::ReshareLink() { … }
void LinkToTextMenuObserver::OnGetExistingSelectorsComplete(
const std::vector<std::string>& aggregated_selectors) { … }
void LinkToTextMenuObserver::RemoveHighlights() { … }
mojo::Remote<blink::mojom::TextFragmentReceiver>&
LinkToTextMenuObserver::GetRemote() { … }
void LinkToTextMenuObserver::CopyTextToClipboard(const std::string& text) { … }