2020-01-15 23:11:51 +00:00
|
|
|
// Copyright (c) 2019 Slack Technologies, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
|
2020-01-15 23:11:51 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2023-05-11 20:07:39 +00:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2020-01-15 23:11:51 +00:00
|
|
|
#include "extensions/browser/api/execute_code_function.h"
|
|
|
|
#include "extensions/browser/extension_function.h"
|
|
|
|
#include "extensions/common/extension_resource.h"
|
2021-07-02 00:51:37 +00:00
|
|
|
|
|
|
|
class GURL;
|
2020-01-15 23:11:51 +00:00
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
|
|
|
|
// Implement API call tabs.executeScript and tabs.insertCSS.
|
|
|
|
class ExecuteCodeInTabFunction : public ExecuteCodeFunction {
|
|
|
|
public:
|
|
|
|
ExecuteCodeInTabFunction();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
~ExecuteCodeInTabFunction() override;
|
|
|
|
|
|
|
|
// Initializes |execute_tab_id_| and |details_|.
|
|
|
|
InitResult Init() override;
|
|
|
|
bool CanExecuteScriptOnPage(std::string* error) override;
|
|
|
|
ScriptExecutor* GetScriptExecutor(std::string* error) override;
|
|
|
|
bool IsWebView() const override;
|
|
|
|
const GURL& GetWebViewSrc() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Id of tab which executes code.
|
|
|
|
int execute_tab_id_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction {
|
|
|
|
protected:
|
|
|
|
bool ShouldInsertCSS() const override;
|
2020-10-16 01:30:41 +00:00
|
|
|
bool ShouldRemoveCSS() const override;
|
2020-01-15 23:11:51 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
~TabsExecuteScriptFunction() override {}
|
|
|
|
|
|
|
|
DECLARE_EXTENSION_FUNCTION("tabs.executeScript", TABS_EXECUTESCRIPT)
|
|
|
|
};
|
|
|
|
|
2022-04-11 20:51:10 +00:00
|
|
|
class TabsReloadFunction : public ExtensionFunction {
|
|
|
|
~TabsReloadFunction() override {}
|
|
|
|
|
|
|
|
ResponseAction Run() override;
|
|
|
|
|
|
|
|
DECLARE_EXTENSION_FUNCTION("tabs.reload", TABS_RELOAD)
|
|
|
|
};
|
|
|
|
|
2020-02-13 00:39:12 +00:00
|
|
|
class TabsGetFunction : public ExtensionFunction {
|
|
|
|
~TabsGetFunction() override {}
|
2022-04-11 20:51:10 +00:00
|
|
|
|
2020-02-13 00:39:12 +00:00
|
|
|
ResponseAction Run() override;
|
2022-04-11 20:51:10 +00:00
|
|
|
|
2020-02-13 00:39:12 +00:00
|
|
|
DECLARE_EXTENSION_FUNCTION("tabs.get", TABS_GET)
|
|
|
|
};
|
|
|
|
|
|
|
|
class TabsSetZoomFunction : public ExtensionFunction {
|
|
|
|
private:
|
|
|
|
~TabsSetZoomFunction() override {}
|
|
|
|
|
|
|
|
ResponseAction Run() override;
|
|
|
|
|
|
|
|
DECLARE_EXTENSION_FUNCTION("tabs.setZoom", TABS_SETZOOM)
|
|
|
|
};
|
|
|
|
|
|
|
|
class TabsGetZoomFunction : public ExtensionFunction {
|
|
|
|
private:
|
|
|
|
~TabsGetZoomFunction() override {}
|
|
|
|
|
|
|
|
ResponseAction Run() override;
|
|
|
|
|
|
|
|
DECLARE_EXTENSION_FUNCTION("tabs.getZoom", TABS_GETZOOM)
|
|
|
|
};
|
|
|
|
|
|
|
|
class TabsSetZoomSettingsFunction : public ExtensionFunction {
|
|
|
|
private:
|
|
|
|
~TabsSetZoomSettingsFunction() override {}
|
|
|
|
|
|
|
|
ResponseAction Run() override;
|
|
|
|
|
|
|
|
DECLARE_EXTENSION_FUNCTION("tabs.setZoomSettings", TABS_SETZOOMSETTINGS)
|
|
|
|
};
|
|
|
|
|
|
|
|
class TabsGetZoomSettingsFunction : public ExtensionFunction {
|
|
|
|
private:
|
|
|
|
~TabsGetZoomSettingsFunction() override {}
|
|
|
|
|
|
|
|
ResponseAction Run() override;
|
|
|
|
|
|
|
|
DECLARE_EXTENSION_FUNCTION("tabs.getZoomSettings", TABS_GETZOOMSETTINGS)
|
|
|
|
};
|
|
|
|
|
2021-07-27 20:36:22 +00:00
|
|
|
class TabsUpdateFunction : public ExtensionFunction {
|
|
|
|
public:
|
|
|
|
TabsUpdateFunction();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
~TabsUpdateFunction() override {}
|
|
|
|
bool UpdateURL(const std::string& url, int tab_id, std::string* error);
|
|
|
|
ResponseValue GetResult();
|
|
|
|
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<content::WebContents> web_contents_;
|
2021-07-27 20:36:22 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
ResponseAction Run() override;
|
|
|
|
|
|
|
|
DECLARE_EXTENSION_FUNCTION("tabs.update", TABS_UPDATE)
|
|
|
|
};
|
2020-01-15 23:11:51 +00:00
|
|
|
} // namespace extensions
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
|