chromium/chrome/browser/ui/views/apps/app_info_dialog/app_info_footer_panel.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_footer_panel.h"

#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/grit/generated_resources.h"
#include "components/app_constants/constants.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/management_policy.h"
#include "extensions/browser/uninstall_reason.h"
#include "extensions/common/extension.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/events/event.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
// gn check complains on Linux Ozone.
#include "ash/public/cpp/shelf_model.h"  // nogncheck
#include "chrome/browser/ui/ash/shelf/app_shortcut_shelf_item_controller.h"
#include "chrome/browser/ui/ash/shelf/chrome_shelf_controller.h"
#include "chrome/browser/ui/ash/shelf/chrome_shelf_controller_util.h"
#endif

AppInfoFooterPanel::AppInfoFooterPanel(Profile* profile,
                                       const extensions::Extension* app)
    :{}

AppInfoFooterPanel::~AppInfoFooterPanel() {}

// static
std::unique_ptr<AppInfoFooterPanel> AppInfoFooterPanel::CreateFooterPanel(
    Profile* profile,
    const extensions::Extension* app) {}

void AppInfoFooterPanel::CreateButtons() {}

#if BUILDFLAG(IS_CHROMEOS_ASH)
void AppInfoFooterPanel::UpdatePinButtons(bool focus_visible_button) {
  if (pin_to_shelf_button_ && unpin_from_shelf_button_) {
    const bool was_pinned =
        ChromeShelfController::instance()->shelf_model()->IsAppPinned(
            app_->id());
    pin_to_shelf_button_->SetVisible(!was_pinned);
    unpin_from_shelf_button_->SetVisible(was_pinned);

    if (focus_visible_button) {
      views::View* button_to_focus = was_pinned ? unpin_from_shelf_button_.get()
                                                : pin_to_shelf_button_.get();
      button_to_focus->RequestFocus();
    }
  }
}
#endif

void AppInfoFooterPanel::OnExtensionUninstallDialogClosed(
    bool did_start_uninstall,
    const std::u16string& error) {}

void AppInfoFooterPanel::CreateShortcuts() {}

// static
bool AppInfoFooterPanel::CanCreateShortcuts(const extensions::Extension* app) {}

#if BUILDFLAG(IS_CHROMEOS_ASH)
void AppInfoFooterPanel::SetPinnedToShelf(bool value) {
  DCHECK(CanSetPinnedToShelf(profile_, app_));
  ash::ShelfModel* shelf_model =
      ChromeShelfController::instance()->shelf_model();
  DCHECK(shelf_model);
  ash::ShelfModel::ScopedUserTriggeredMutation user_triggered(shelf_model);
  if (value) {
    PinAppWithIDToShelf(app_->id());
  } else {
    UnpinAppWithIDFromShelf(app_->id());
  }

  UpdatePinButtons(true);
  DeprecatedLayoutImmediately();
}

// static
bool AppInfoFooterPanel::CanSetPinnedToShelf(Profile* profile,
                                             const extensions::Extension* app) {
  // The Chrome app can't be unpinned, and extensions can't be pinned.
  return app->id() != app_constants::kChromeAppId && !app->is_extension() &&
         (GetPinnableForAppID(app->id(), profile) ==
          AppListControllerDelegate::PIN_EDITABLE);
}
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

void AppInfoFooterPanel::UninstallApp() {}

// static
bool AppInfoFooterPanel::CanUninstallApp(Profile* profile,
                                         const extensions::Extension* app) {}

BEGIN_METADATA()