#include "chrome/browser/ui/views/supervised_user/parent_permission_dialog_view.h"
#include <string>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/supervised_user/supervised_user_browser_utils.h"
#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/ui/supervised_user/parent_permission_dialog.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/browser/ui/views/extensions/extension_permissions_view.h"
#include "chrome/grit/generated_resources.h"
#include "components/constrained_window/constrained_window_views.h"
#include "components/signin/public/identity_manager/access_token_fetcher.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/scope_set.h"
#include "components/supervised_user/core/browser/supervised_user_service.h"
#include "components/supervised_user/core/common/features.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_util.h"
#include "extensions/browser/supervised_user_extensions_delegate.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/icons/extension_icon_set.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/permissions/permission_set.h"
#include "google_apis/gaia/gaia_constants.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "ui/accessibility/ax_enums.mojom-shared.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/base/mojom/ui_base_types.mojom-shared.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/border.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/button/radio_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/controls/textfield/textfield_controller.h"
#include "ui/views/layout/box_layout_view.h"
#include "ui/views/layout/table_layout_view.h"
#include "ui/views/metadata/view_factory.h"
#include "ui/views/view.h"
#include "ui/views/view_class_properties.h"
namespace {
constexpr int kPermissionSectionPaddingTop = …;
constexpr int kPermissionSectionPaddingBottom = …;
constexpr int kInvalidCredentialLabelFontSizeDelta = …;
constexpr int kInvalidCredentialLabelTopPadding = …;
class MaybeEmptyLabel : public views::Label { … };
BEGIN_METADATA(…)
class MessageContentWrapper : public views::View { … };
BEGIN_METADATA(…)
TestParentPermissionDialogViewObserver* test_view_observer = …;
}
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(ParentPermissionDialog,
kDialogViewIdForTesting);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(
ParentPermissionDialog,
kExtensionsParentApprovalVerificationTextIdForTesting);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(ParentPermissionDialog,
kParentAccountTextIdForTesting);
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(ParentPermissionDialog,
kIncorrectParentPasswordIdForTesting);
class ParentPermissionInputSection : public views::TextfieldController { … };
struct ParentPermissionDialogView::Params { … };
ParentPermissionDialogView::Params::Params() = default;
ParentPermissionDialogView::Params::~Params() = default;
ParentPermissionDialogView::ParentPermissionDialogView(
std::unique_ptr<Params> params,
ParentPermissionDialogView::Observer* observer)
: … { … }
ParentPermissionDialogView::~ParentPermissionDialogView() { … }
void ParentPermissionDialogView::SetIdentityManagerForTesting(
signin::IdentityManager* identity_manager) { … }
void ParentPermissionDialogView::SetRepromptAfterIncorrectCredential(
bool reprompt) { … }
bool ParentPermissionDialogView::GetRepromptAfterIncorrectCredential() const { … }
void ParentPermissionDialogView::AddedToWidget() { … }
void ParentPermissionDialogView::OnThemeChanged() { … }
bool ParentPermissionDialogView::Cancel() { … }
bool ParentPermissionDialogView::Accept() { … }
std::u16string ParentPermissionDialogView::GetAccessibleWindowTitle() const { … }
void ParentPermissionDialogView::CreateContents() { … }
void ParentPermissionDialogView::ShowDialog() { … }
void ParentPermissionDialogView::CloseDialog() { … }
void ParentPermissionDialogView::RemoveObserver() { … }
void ParentPermissionDialogView::SetSelectedParentPermissionEmail(
const std::u16string& email_address) { … }
std::u16string ParentPermissionDialogView::GetSelectedParentPermissionEmail()
const { … }
void ParentPermissionDialogView::SetParentPermissionCredential(
const std::u16string& credential) { … }
std::u16string ParentPermissionDialogView::GetParentPermissionCredential()
const { … }
bool ParentPermissionDialogView::GetInvalidCredentialReceived() const { … }
void ParentPermissionDialogView::ShowDialogInternal() { … }
void ParentPermissionDialogView::LoadParentEmailAddresses() { … }
void ParentPermissionDialogView::CloseWithReason(
views::Widget::ClosedReason reason) { … }
std::string ParentPermissionDialogView::GetParentObfuscatedGaiaID(
const std::u16string& parent_email) const { … }
void ParentPermissionDialogView::StartReauthAccessTokenFetch(
const std::string& parent_obfuscated_gaia_id,
const std::string& parent_credential) { … }
void ParentPermissionDialogView::OnAccessTokenFetchComplete(
const std::string& parent_obfuscated_gaia_id,
const std::string& parent_credential,
GoogleServiceAuthError error,
signin::AccessTokenInfo access_token_info) { … }
void ParentPermissionDialogView::StartParentReauthProofTokenFetch(
const std::string& child_access_token,
const std::string& parent_obfuscated_gaia_id,
const std::string& credential) { … }
void ParentPermissionDialogView::SendResultOnce(
ParentPermissionDialog::Result result) { … }
void ParentPermissionDialogView::OnReAuthProofTokenSuccess(
const std::string& reauth_proof_token) { … }
void ParentPermissionDialogView::OnReAuthProofTokenFailure(
const GaiaAuthConsumer::ReAuthProofTokenStatus error) { … }
void ParentPermissionDialogView::InitializeExtensionData(
scoped_refptr<const extensions::Extension> extension) { … }
BEGIN_METADATA(…)
class ParentPermissionDialogImpl : public ParentPermissionDialog,
public ParentPermissionDialogView::Observer { … };
ParentPermissionDialogImpl::ParentPermissionDialogImpl(
std::unique_ptr<ParentPermissionDialogView::Params> params)
: … { … }
void ParentPermissionDialogImpl::ShowDialog() { … }
ParentPermissionDialogImpl::~ParentPermissionDialogImpl() { … }
void ParentPermissionDialogImpl::OnParentPermissionDialogViewDestroyed() { … }
std::unique_ptr<ParentPermissionDialog>
ParentPermissionDialog::CreateParentPermissionDialog(
Profile* profile,
gfx::NativeWindow window,
const gfx::ImageSkia& icon,
const std::u16string& message,
ParentPermissionDialog::DoneCallback done_callback) { … }
std::unique_ptr<ParentPermissionDialog>
ParentPermissionDialog::CreateParentPermissionDialogForExtension(
Profile* profile,
gfx::NativeWindow window,
const gfx::ImageSkia& icon,
const extensions::Extension* extension,
SupervisedUserExtensionParentApprovalEntryPoint
extension_approval_entry_point,
ParentPermissionDialog::DoneCallback done_callback) { … }
TestParentPermissionDialogViewObserver::TestParentPermissionDialogViewObserver(
TestParentPermissionDialogViewObserver* observer) { … }
TestParentPermissionDialogViewObserver::
~TestParentPermissionDialogViewObserver() { … }