#include "chrome/browser/ui/views/permissions/chip/chip_controller.h"
#include <memory>
#include <string>
#include <utility>
#include "base/check.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/page_info/page_info_dialog.h"
#include "chrome/browser/ui/views/content_setting_bubble_contents.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
#include "chrome/browser/ui/views/page_info/page_info_bubble_view.h"
#include "chrome/browser/ui/views/permissions/chip/permission_dashboard_controller.h"
#include "chrome/browser/ui/views/permissions/chip/permission_dashboard_view.h"
#include "chrome/browser/ui/views/permissions/chip/permission_prompt_chip_model.h"
#include "chrome/browser/ui/views/permissions/permission_prompt_bubble_view_factory.h"
#include "chrome/browser/ui/views/permissions/permission_prompt_style.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/content_settings/core/common/features.h"
#include "components/permissions/features.h"
#include "components/permissions/permission_prompt.h"
#include "components/permissions/permission_request_manager.h"
#include "components/permissions/permission_util.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/visibility.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/button_controller.h"
#include "ui/views/widget/widget.h"
namespace {
constexpr auto kConfirmationDisplayDuration = …;
constexpr auto kCollapseDelay = …;
constexpr auto kDismissDelay = …;
constexpr auto kDismissDelayForAbusiveOrigins = …;
constexpr auto kLHSIndicatorCollapseAnimationDuration = …;
base::TimeDelta GetAnimationDuration(base::TimeDelta duration) { … }
}
class BubbleButtonController : public views::ButtonController { … };
ChipController::ChipController(
LocationBarView* location_bar_view,
PermissionChipView* chip_view,
PermissionDashboardView* permission_dashboard_view,
PermissionDashboardController* permission_dashboard_controller)
: … { … }
ChipController::~ChipController() { … }
void ChipController::OnPermissionRequestManagerDestructed() { … }
void ChipController::OnNavigation(
content::NavigationHandle* navigation_handle) { … }
void ChipController::OnTabVisibilityChanged(content::Visibility visibility) { … }
void ChipController::OnRequestsFinalized() { … }
void ChipController::OnPromptRemoved() { … }
void ChipController::OnRequestDecided(
permissions::PermissionAction permission_action) { … }
bool ChipController::IsBubbleShowing() { … }
bool ChipController::IsAnimating() const { … }
void ChipController::RestartTimersOnMouseHover() { … }
void ChipController::OnWidgetDestroying(views::Widget* widget) { … }
void ChipController::OnWidgetActivationChanged(views::Widget* widget,
bool active) { … }
bool ChipController::ShouldWaitForConfirmationToComplete() const { … }
bool ChipController::ShouldWaitForLHSIndicatorToCollapse() const { … }
void ChipController::InitializePermissionPrompt(
base::WeakPtr<permissions::PermissionPrompt::Delegate> delegate,
base::OnceCallback<void()> callback) { … }
void ChipController::ShowPermissionUi(
base::WeakPtr<permissions::PermissionPrompt::Delegate> delegate) { … }
void ChipController::ShowPermissionChip(
base::WeakPtr<permissions::PermissionPrompt::Delegate> delegate) { … }
void ChipController::ShowPermissionPrompt(
base::WeakPtr<permissions::PermissionPrompt::Delegate> delegate) { … }
void ChipController::RemoveBubbleObserverAndResetTimersAndChipCallbacks() { … }
void ChipController::ResetPermissionPromptChip() { … }
void ChipController::ResetPermissionRequestChip() { … }
void ChipController::ShowPageInfoDialog() { … }
void ChipController::OnPageInfoBubbleClosed(
views::Widget::ClosedReason closed_reason,
bool reload_prompt) { … }
void ChipController::CollapseConfirmation() { … }
bool ChipController::should_expand_for_testing() { … }
void ChipController::AnimateExpand() { … }
void ChipController::HandleConfirmation(
permissions::PermissionAction user_decision) { … }
void ChipController::AnnouncePermissionRequestForAccessibility(
const std::u16string& text) { … }
void ChipController::CollapsePrompt(bool allow_restart) { … }
void ChipController::OnExpandAnimationEnded() { … }
void ChipController::OnCollapseAnimationEnded() { … }
void ChipController::HideChip() { … }
void ChipController::OpenPermissionPromptBubble() { … }
void ChipController::ClosePermissionPromptBubbleWithReason(
views::Widget::ClosedReason reason) { … }
void ChipController::RecordRequestChipButtonPressed(const char* recordKey) { … }
void ChipController::ObservePromptBubble() { … }
void ChipController::OnPromptBubbleDismissed() { … }
void ChipController::OnPromptExpired() { … }
void ChipController::OnRequestChipButtonPressed() { … }
void ChipController::OnChipVisibilityChanged(bool is_visible) { … }
void ChipController::SyncChipWithModel() { … }
void ChipController::StartCollapseTimer() { … }
void ChipController::StartDismissTimer() { … }
void ChipController::ResetTimers() { … }
views::Widget* ChipController::GetBubbleWidget() { … }
PermissionPromptBubbleBaseView* ChipController::GetPromptBubbleView() { … }