feat: [extensions] implement a couple of tabs APIs (#21779)
This commit is contained in:
parent
8278a64e00
commit
b9eb68c0b4
21 changed files with 568 additions and 17 deletions
49
shell/browser/extensions/api/tabs/tabs_api.h
Normal file
49
shell/browser/extensions/api/tabs/tabs_api.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
// 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.
|
||||
|
||||
#ifndef SHELL_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
|
||||
#define SHELL_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "extensions/browser/api/execute_code_function.h"
|
||||
#include "extensions/browser/extension_function.h"
|
||||
#include "extensions/common/extension_resource.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
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;
|
||||
|
||||
private:
|
||||
~TabsExecuteScriptFunction() override {}
|
||||
|
||||
DECLARE_EXTENSION_FUNCTION("tabs.executeScript", TABS_EXECUTESCRIPT)
|
||||
};
|
||||
|
||||
} // namespace extensions
|
||||
|
||||
#endif // SHELL_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
|
Loading…
Add table
Add a link
Reference in a new issue