#include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
#include <algorithm>
#include <memory>
#include <string>
#include <vector>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_functions.h"
#include "base/not_fatal_until.h"
#include "base/numerics/safe_conversions.h"
#include "base/observer_list.h"
#include "base/one_shot_event.h"
#include "base/ranges/algorithm.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/profile_util.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/extensions/extension_action_view_controller.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_model_factory.h"
#include "chrome/browser/ui/web_applications/app_browser_controller.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_action_manager.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/extension_util.h"
#include "extensions/browser/permissions_manager.h"
#include "extensions/browser/pref_names.h"
#include "extensions/browser/unloaded_extension_reason.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/permissions/permissions_data.h"
ToolbarActionsModel::ToolbarActionsModel(
Profile* profile,
extensions::ExtensionPrefs* extension_prefs)
: … { … }
ToolbarActionsModel::~ToolbarActionsModel() { … }
ToolbarActionsModel* ToolbarActionsModel::Get(Profile* profile) { … }
void ToolbarActionsModel::AddObserver(Observer* observer) { … }
void ToolbarActionsModel::RemoveObserver(Observer* observer) { … }
void ToolbarActionsModel::OnExtensionActionUpdated(
extensions::ExtensionAction* extension_action,
content::WebContents* web_contents,
content::BrowserContext* browser_context) { … }
void ToolbarActionsModel::OnExtensionLoaded(
content::BrowserContext* browser_context,
const extensions::Extension* extension) { … }
void ToolbarActionsModel::OnExtensionUnloaded(
content::BrowserContext* browser_context,
const extensions::Extension* extension,
extensions::UnloadedExtensionReason reason) { … }
void ToolbarActionsModel::OnExtensionUninstalled(
content::BrowserContext* browser_context,
const extensions::Extension* extension,
extensions::UninstallReason reason) { … }
void ToolbarActionsModel::OnExtensionManagementSettingsChanged() { … }
void ToolbarActionsModel::OnExtensionPermissionsUpdated(
const extensions::Extension& extension,
const extensions::PermissionSet& permissions,
extensions::PermissionsManager::UpdateReason reason) { … }
void ToolbarActionsModel::OnActiveTabPermissionGranted(
const extensions::Extension& extension) { … }
void ToolbarActionsModel::Shutdown() { … }
void ToolbarActionsModel::RemovePref(const ActionId& action_id) { … }
void ToolbarActionsModel::OnReady() { … }
bool ToolbarActionsModel::ShouldAddExtension(
const extensions::Extension* extension) { … }
void ToolbarActionsModel::AddAction(const ActionId& action_id) { … }
void ToolbarActionsModel::RemoveAction(const ActionId& action_id) { … }
const std::u16string ToolbarActionsModel::GetExtensionName(
const ActionId& action_id) const { … }
bool ToolbarActionsModel::HasAction(const ActionId& action_id) const { … }
bool ToolbarActionsModel::CanShowActionsInToolbar(const Browser& browser) { … }
bool ToolbarActionsModel::IsRestrictedUrl(const GURL& url) const { … }
bool ToolbarActionsModel::IsPolicyBlockedHost(const GURL& url) const { … }
bool ToolbarActionsModel::IsActionPinned(const ActionId& action_id) const { … }
bool ToolbarActionsModel::IsActionForcePinned(const ActionId& action_id) const { … }
void ToolbarActionsModel::MovePinnedAction(const ActionId& action_id,
size_t target_index) { … }
void ToolbarActionsModel::InitializeActionList() { … }
void ToolbarActionsModel::Populate() { … }
void ToolbarActionsModel::IncognitoPopulate() { … }
void ToolbarActionsModel::SetActionVisibility(const ActionId& action_id,
bool is_now_visible) { … }
const extensions::Extension* ToolbarActionsModel::GetExtensionById(
const ActionId& action_id) const { … }
void ToolbarActionsModel::UpdatePinnedActionIds() { … }
std::vector<ToolbarActionsModel::ActionId>
ToolbarActionsModel::GetFilteredPinnedActionIds() const { … }
void ToolbarActionsModel::NotifyToolbarActionUpdated(
const ActionId& action_id) { … }