#include "chrome/browser/extensions/api/declarative_content/content_action.h"
#include <map>
#include "base/lazy_instance.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/extension_ui_util.h"
#include "chrome/browser/profiles/profile.h"
#include "components/sessions/content/session_tab_helper.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_action.h"
#include "extensions/browser/extension_action_manager.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/extension_user_script_loader.h"
#include "extensions/browser/extension_web_contents_observer.h"
#include "extensions/browser/script_injection_tracker.h"
#include "extensions/browser/user_script_manager.h"
#include "extensions/common/api/declarative/declarative_constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/image_util.h"
#include "extensions/common/mojom/host_id.mojom.h"
#include "extensions/common/mojom/run_location.mojom-shared.h"
#include "extensions/common/script_constants.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
namespace extensions {
namespace {
const char kInvalidIconDictionary[] = …;
const char kInvalidInstanceTypeError[] = …;
const char kMissingInstanceTypeError[] = …;
const char kMissingParameter[] = …;
const char kNoAction[] = …;
const char kNoPageOrBrowserAction[] = …;
const char kIconNotSufficientlyVisible[] = …;
bool g_allow_invisible_icons_content_action = …;
void RecordContentActionCreated(
declarative_content_constants::ContentActionType type) { … }
class ShowExtensionAction : public ContentAction { … };
class SetIcon : public ContentAction { … };
static bool AppendJSStringsToCPPStrings(const base::Value::List& append_strings,
std::vector<std::string>* append_to) { … }
struct ContentActionFactory { … };
base::LazyInstance<ContentActionFactory>::Leaky
g_content_action_factory = …;
}
struct RequestContentScript::ScriptData { … };
RequestContentScript::ScriptData::ScriptData()
: … { … }
RequestContentScript::ScriptData::~ScriptData() { … }
std::unique_ptr<ContentAction> RequestContentScript::Create(
content::BrowserContext* browser_context,
const Extension* extension,
const base::Value::Dict* dict,
std::string* error) { … }
bool RequestContentScript::InitScriptData(const base::Value::Dict* dict,
std::string* error,
ScriptData* script_data) { … }
RequestContentScript::RequestContentScript(
content::BrowserContext* browser_context,
const Extension* extension,
const ScriptData& script_data) { … }
RequestContentScript::~RequestContentScript() { … }
void RequestContentScript::InitScript(const mojom::HostID& host_id,
const Extension* extension,
const ScriptData& script_data) { … }
void RequestContentScript::AddScript() { … }
void RequestContentScript::Apply(const ApplyInfo& apply_info) const { … }
void RequestContentScript::Reapply(const ApplyInfo& apply_info) const { … }
void RequestContentScript::Revert(const ApplyInfo& apply_info) const { … }
void RequestContentScript::InstructRenderProcessToInject(
content::WebContents* contents,
const Extension* extension) const { … }
void RequestContentScript::OnScriptsLoaded(
UserScriptLoader* loader,
content::BrowserContext* browser_context) { … }
void RequestContentScript::OnUserScriptLoaderDestroyed(
UserScriptLoader* loader) { … }
std::unique_ptr<ContentAction> SetIcon::Create(
content::BrowserContext* browser_context,
const Extension* extension,
const base::Value::Dict* dict,
std::string* error) { … }
ContentAction::~ContentAction() { … }
std::unique_ptr<ContentAction> ContentAction::Create(
content::BrowserContext* browser_context,
const Extension* extension,
const base::Value::Dict& json_action_dict,
std::string* error) { … }
void ContentAction::SetAllowInvisibleIconsForTest(bool value) { … }
ContentAction::ContentAction() { … }
}