1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
// Copyright 2020 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_UI_WEBUI_BROWSER_COMMAND_BROWSER_COMMAND_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_BROWSER_COMMAND_BROWSER_COMMAND_HANDLER_H_
#include <memory>
#include "base/memory/raw_ptr.h"
#include "chrome/browser/command_updater_delegate.h"
#include "chrome/browser/feedback/show_feedback_page.h"
#include "chrome/browser/ui/user_education/start_tutorial_in_page.h"
#include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "ui/base/interaction/element_tracker.h"
#include "ui/base/window_open_disposition.h"
#include "ui/webui/resources/js/browser_command/browser_command.mojom.h"
#include "url/gurl.h"
class CommandUpdater;
class Profile;
namespace user_education {
class TutorialService;
}
// Struct containing the information needed to customize/configure the feedback
// form. Used to populate arguments passed to chrome::ShowFeedbackPage().
struct FeedbackCommandSettings {
FeedbackCommandSettings() = default;
FeedbackCommandSettings(const GURL& url,
feedback::FeedbackSource source,
std::string category)
: url(url), source(source), category(category) {}
GURL url;
feedback::FeedbackSource source = feedback::kFeedbackSourceCount;
std::string category;
};
// Handles browser commands send from JS.
class BrowserCommandHandler : public CommandUpdaterDelegate,
public browser_command::mojom::CommandHandler {
public:
static const char kPromoBrowserCommandHistogramName[];
BrowserCommandHandler(
mojo::PendingReceiver<browser_command::mojom::CommandHandler>
pending_page_handler,
Profile* profile,
std::vector<browser_command::mojom::Command> supported_commands,
content::WebContents* web_contents);
~BrowserCommandHandler() override;
// browser_command::mojom::CommandHandler:
void CanExecuteCommand(browser_command::mojom::Command command_id,
CanExecuteCommandCallback callback) override;
void ExecuteCommand(browser_command::mojom::Command command_id,
browser_command::mojom::ClickInfoPtr click_info,
ExecuteCommandCallback callback) override;
// CommandUpdaterDelegate:
void ExecuteCommandWithDisposition(
int command_id,
WindowOpenDisposition disposition) override;
void ConfigureFeedbackCommand(FeedbackCommandSettings settings);
protected:
void EnableSupportedCommands();
virtual CommandUpdater* GetCommandUpdater();
virtual bool BrowserSupportsTabGroups();
virtual bool DefaultSearchProviderIsGoogle();
virtual bool BrowserSupportsSavedTabGroups();
private:
FRIEND_TEST_ALL_PREFIXES(BrowserCommandHandlerTest,
StartPasswordManagerTutorialCommand);
FRIEND_TEST_ALL_PREFIXES(BrowserCommandHandlerTest,
StartSavedTabGroupTutorialCommand);
virtual void NavigateToURL(const GURL& url,
WindowOpenDisposition disposition);
virtual void OpenFeedbackForm();
virtual void OnTutorialStarted(
user_education::TutorialIdentifier tutorial_id,
user_education::TutorialService* tutorial_service);
virtual void StartTutorial(StartTutorialInPage::Params params);
virtual bool TutorialServiceExists();
virtual void NavigateToEnhancedProtectionSetting();
virtual void OpenPasswordManager();
virtual void OpenAISettings();
virtual void OpenGlic();
virtual void OpenGlicSettings();
void StartTabGroupTutorial();
void OpenNTPAndStartCustomizeChromeTutorial();
void StartPasswordManagerTutorial();
void StartSavedTabGroupTutorial();
FeedbackCommandSettings feedback_settings_;
raw_ptr<Profile, DanglingUntriaged> profile_;
std::vector<browser_command::mojom::Command> supported_commands_;
std::unique_ptr<CommandUpdater> command_updater_;
mojo::Receiver<browser_command::mojom::CommandHandler> page_handler_;
raw_ptr<content::WebContents> web_contents_;
};
#endif // CHROME_BROWSER_UI_WEBUI_BROWSER_COMMAND_BROWSER_COMMAND_HANDLER_H_
|