-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Extensions refactor] Use DialogModel in ExtensionInstallBlockedByPar…
…entDialog Bug: 1330637 Change-Id: Ie3116c6e00a67e77581644c099820c91d3fec78c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3816900 Commit-Queue: Emilia Paz <emiliapaz@chromium.org> Reviewed-by: Caroline Rising <corising@chromium.org> Cr-Commit-Position: refs/heads/main@{#1035121}
- Loading branch information
1 parent
91bed74
commit ea8d0b4
Showing
6 changed files
with
82 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright 2022 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include <string> | ||
#include <utility> | ||
|
||
#include "chrome/browser/ui/extensions/extensions_dialogs.h" | ||
#include "chrome/grit/chromium_strings.h" | ||
#include "chrome/grit/generated_resources.h" | ||
#include "chromeos/ui/vector_icons/vector_icons.h" | ||
#include "components/constrained_window/constrained_window_views.h" | ||
#include "components/strings/grit/components_strings.h" | ||
#include "content/public/browser/browser_thread.h" | ||
#include "content/public/browser/web_contents.h" | ||
#include "extensions/common/extension.h" | ||
#include "ui/base/l10n/l10n_util.h" | ||
#include "ui/base/models/dialog_model.h" | ||
#include "ui/base/models/image_model.h" | ||
#include "ui/gfx/paint_vector_icon.h" | ||
|
||
namespace { | ||
|
||
std::u16string GetExtensionType(const extensions::Extension* extension) { | ||
return l10n_util::GetStringUTF16( | ||
extension->is_app() | ||
? IDS_PARENT_PERMISSION_PROMPT_EXTENSION_TYPE_APP | ||
: IDS_PARENT_PERMISSION_PROMPT_EXTENSION_TYPE_EXTENSION); | ||
} | ||
|
||
std::u16string GetTitle( | ||
extensions::ExtensionInstalledBlockedByParentDialogAction action, | ||
std::u16string extension_type) { | ||
int title_id = | ||
action == extensions::ExtensionInstalledBlockedByParentDialogAction::kAdd | ||
? IDS_EXTENSION_INSTALL_BLOCKED_BY_PARENT_PROMPT_TITLE | ||
: IDS_EXTENSION_ENABLE_BLOCKED_BY_PARENT_PROMPT_TITLE; | ||
return l10n_util::GetStringFUTF16(title_id, extension_type); | ||
} | ||
|
||
std::u16string GetBodyText( | ||
extensions::ExtensionInstalledBlockedByParentDialogAction action, | ||
std::u16string extension_type) { | ||
int body_id = | ||
action == extensions::ExtensionInstalledBlockedByParentDialogAction::kAdd | ||
? IDS_EXTENSION_INSTALL_BLOCKED_BY_PARENT_PROMPT_MESSAGE | ||
: IDS_EXTENSION_ENABLE_BLOCKED_BY_PARENT_PROMPT_MESSAGE; | ||
return l10n_util::GetStringFUTF16(body_id, extension_type); | ||
} | ||
|
||
} // namespace | ||
|
||
namespace extensions { | ||
|
||
void ShowExtensionInstallBlockedByParentDialog( | ||
ExtensionInstalledBlockedByParentDialogAction action, | ||
const extensions::Extension* extension, | ||
content::WebContents* web_contents, | ||
base::OnceClosure done_callback) { | ||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | ||
std::u16string extension_type = GetExtensionType(extension); | ||
|
||
auto dialog_model = | ||
ui::DialogModel::Builder() | ||
.SetTitle(GetTitle(action, extension_type)) | ||
.SetIcon(ui::ImageModel::FromImageSkia(gfx::CreateVectorIcon( | ||
chromeos::kNotificationSupervisedUserIcon, ui::kColorIcon))) | ||
.AddBodyText( | ||
ui::DialogModelLabel(GetBodyText(action, extension_type))) | ||
.AddOkButton(base::DoNothing(), l10n_util::GetStringUTF16(IDS_OK)) | ||
.SetDialogDestroyingCallback(std::move(done_callback)) | ||
.Build(); | ||
|
||
gfx::NativeWindow parent_window = | ||
web_contents ? web_contents->GetTopLevelNativeWindow() : nullptr; | ||
constrained_window::ShowBrowserModal(std::move(dialog_model), parent_window); | ||
} | ||
|
||
} // namespace extensions |
2 changes: 1 addition & 1 deletion
2
...cked_by_parent_dialog_view_browsertest.cc → ...l_blocked_by_parent_dialog_browsertest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 0 additions & 153 deletions
153
chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_view.cc
This file was deleted.
Oops, something went wrong.
59 changes: 0 additions & 59 deletions
59
chrome/browser/ui/views/supervised_user/extension_install_blocked_by_parent_dialog_view.h
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters