chromium/chrome/browser/extensions/api/extension_action/extension_action_api.h

// Copyright 2012 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_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H_

#include <string>

#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "base/scoped_observation.h"
#include "base/values.h"
#include "chrome/browser/ui/extensions/extension_popup_types.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/extension_action.h"
#include "extensions/browser/extension_event_histogram_value.h"
#include "extensions/browser/extension_function.h"
#include "extensions/browser/extension_host_registry.h"
#include "extensions/common/extension_id.h"
#include "third_party/skia/include/core/SkColor.h"

namespace content {
class BrowserContext;
class WebContents;
}

namespace extensions {

class ExtensionHost;
class ExtensionPrefs;

class ExtensionActionAPI : public BrowserContextKeyedAPI {};

// Implementation of the browserAction and pageAction APIs.
//
// Divergent behaviour between the two is minimal (pageAction has required
// tabIds while browserAction's are optional, they have different internal
// browser notification requirements, and not all functions are defined for all
// APIs).
class ExtensionActionFunction : public ExtensionFunction {};

//
// Implementations of each extension action API.
//
// pageAction and browserAction bindings are created for these by extending them
// then declaring an EXTENSION_FUNCTION_NAME.
//

// show
class ExtensionActionShowFunction : public ExtensionActionFunction {};

// hide
class ExtensionActionHideFunction : public ExtensionActionFunction {};

// setIcon
class ExtensionActionSetIconFunction : public ExtensionActionFunction {};

// setTitle
class ExtensionActionSetTitleFunction : public ExtensionActionFunction {};

// setPopup
class ExtensionActionSetPopupFunction : public ExtensionActionFunction {};

// setBadgeText
class ExtensionActionSetBadgeTextFunction : public ExtensionActionFunction {};

// setBadgeBackgroundColor
class ExtensionActionSetBadgeBackgroundColorFunction
    : public ExtensionActionFunction {};

// getTitle
class ExtensionActionGetTitleFunction : public ExtensionActionFunction {};

// getPopup
class ExtensionActionGetPopupFunction : public ExtensionActionFunction {};

// getBadgeText
class ExtensionActionGetBadgeTextFunction : public ExtensionActionFunction {};

// getBadgeBackgroundColor
class ExtensionActionGetBadgeBackgroundColorFunction
    : public ExtensionActionFunction {};

//
// action.* aliases for supported action APIs.
//

class ActionSetIconFunction : public ExtensionActionSetIconFunction {};

class ActionGetPopupFunction : public ExtensionActionGetPopupFunction {};

class ActionSetPopupFunction : public ExtensionActionSetPopupFunction {};

class ActionGetTitleFunction : public ExtensionActionGetTitleFunction {};

class ActionSetTitleFunction : public ExtensionActionSetTitleFunction {};

class ActionGetBadgeTextFunction : public ExtensionActionGetBadgeTextFunction {};

class ActionSetBadgeTextFunction : public ExtensionActionSetBadgeTextFunction {};

class ActionGetBadgeBackgroundColorFunction
    : public ExtensionActionGetBadgeBackgroundColorFunction {};

class ActionSetBadgeBackgroundColorFunction
    : public ExtensionActionSetBadgeBackgroundColorFunction {};

class ActionGetBadgeTextColorFunction : public ExtensionActionFunction {};

class ActionSetBadgeTextColorFunction : public ExtensionActionFunction {};

class ActionEnableFunction : public ExtensionActionShowFunction {};

class ActionDisableFunction : public ExtensionActionHideFunction {};

class ActionIsEnabledFunction : public ExtensionActionFunction {};

class ActionGetUserSettingsFunction : public ExtensionFunction {};

// Note: action.openPopup() and browserAction.openPopup() have subtly different
// implementations:
//   * action.openPopup() allows the extension to specify a window ID.
//   * browserAction.openPopup() will time out after 10 seconds;
//     action.openPopup() does not time out and instead waits for the popup to
//     either be shown or encounter an error.
//   * browserAction.openPopup() returns a handle to the HTMLWindow of the
//     popup; action.openPopup() returns nothing.
// Due to these differences, the implementations are distinct classes.
class ActionOpenPopupFunction : public ExtensionFunction {};

//
// browserAction.* aliases for supported browserAction APIs.
//

class BrowserActionSetIconFunction : public ExtensionActionSetIconFunction {};

class BrowserActionSetTitleFunction : public ExtensionActionSetTitleFunction {};

class BrowserActionSetPopupFunction : public ExtensionActionSetPopupFunction {};

class BrowserActionGetTitleFunction : public ExtensionActionGetTitleFunction {};

class BrowserActionGetPopupFunction : public ExtensionActionGetPopupFunction {};

class BrowserActionSetBadgeTextFunction
    : public ExtensionActionSetBadgeTextFunction {};

class BrowserActionSetBadgeBackgroundColorFunction
    : public ExtensionActionSetBadgeBackgroundColorFunction {};

class BrowserActionGetBadgeTextFunction
    : public ExtensionActionGetBadgeTextFunction {};

class BrowserActionGetBadgeBackgroundColorFunction
    : public ExtensionActionGetBadgeBackgroundColorFunction {};

class BrowserActionEnableFunction : public ExtensionActionShowFunction {};

class BrowserActionDisableFunction : public ExtensionActionHideFunction {};

// Note: action.openPopup() and browserAction.openPopup() have subtly different
// implementations. See ActionOpenPopupFunction above.
// TODO(devlin): Remove browserAction.openPopup().
class BrowserActionOpenPopupFunction : public ExtensionFunction,
                                       public ExtensionHostRegistry::Observer {};

}  // namespace extensions

//
// pageAction.* aliases for supported pageAction APIs.
//

class PageActionShowFunction : public extensions::ExtensionActionShowFunction {};

class PageActionHideFunction : public extensions::ExtensionActionHideFunction {};

class PageActionSetIconFunction
    : public extensions::ExtensionActionSetIconFunction {};

class PageActionSetTitleFunction
    : public extensions::ExtensionActionSetTitleFunction {};

class PageActionSetPopupFunction
    : public extensions::ExtensionActionSetPopupFunction {};

class PageActionGetTitleFunction
    : public extensions::ExtensionActionGetTitleFunction {};

class PageActionGetPopupFunction
    : public extensions::ExtensionActionGetPopupFunction {};

#endif  // CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H_