[cr143] Remove no longer used first run dialog code.
We don't use first run dialog on any platform any more.
This commit is contained in:
@@ -1133,33 +1133,6 @@ Or change later at <ph name="SETTINGS_EXTENIONS_LINK">$2<ex>brave://settings/ext
|
||||
Reading List
|
||||
</message>
|
||||
|
||||
<!--First-run dialog messages -->
|
||||
<message name="IDS_FIRSTRUN_DLG_HEADER_TEXT" desc="Text for FirstRun dialog header">
|
||||
Ready for the best privacy online?
|
||||
</message>
|
||||
<message name="IDS_FIRSTRUN_DLG_CONTENTS_TEXT" desc="Text for FirstRun dialog contents">
|
||||
Set Brave as your default browser to get Brave's privacy protections on every web page you open.
|
||||
</message>
|
||||
<message name="IDS_FIRSTRUN_DLG_OK_BUTTON_LABEL" desc="Text for FirstRun dialog ok button">
|
||||
Set Brave as default
|
||||
</message>
|
||||
<message name="IDS_FIRSTRUN_DLG_CANCEL_BUTTON_LABEL" desc="Text for FirstRun dialog cancel button">
|
||||
Maybe later
|
||||
</message>
|
||||
|
||||
<if expr="enable_pin_shortcut">
|
||||
<if expr="is_win">
|
||||
<message name="IDS_FIRSTRUN_DLG_PIN_SHORTCUT_TEXT" desc="Text for pin to taskbar checkbox">
|
||||
Pin to taskbar
|
||||
</message>
|
||||
</if>
|
||||
<if expr="is_macosx">
|
||||
<message name="IDS_FIRSTRUN_DLG_PIN_SHORTCUT_TEXT" desc="Text for pin to taskbar checkbox">
|
||||
Keep in Dock
|
||||
</message>
|
||||
</if>
|
||||
</if>
|
||||
|
||||
<!-- Importer -->
|
||||
<message name="IDS_BRAVE_IMPORT_FROM_EDGE" desc="browser combo box: Microsoft Edge Legacy">
|
||||
Microsoft Edge Legacy
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
# Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
source_set("unit_tests") {
|
||||
testonly = true
|
||||
if (is_mac) {
|
||||
sources = [ "first_run_unittest.cc" ]
|
||||
|
||||
deps = [
|
||||
"//chrome/browser",
|
||||
"//chrome/browser/ui:ui_features",
|
||||
"//testing/gtest",
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "chrome/browser/ui/ui_features.h"
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
TEST(FirstRunTest, FeatureTestOnMac) {
|
||||
// To detect macOS specific FirstRun dialog deprecation.
|
||||
// When it's deprecated, we can delete first_run_dialog_controller.mm
|
||||
// overrides.
|
||||
EXPECT_FALSE(base::FeatureList::IsEnabled(features::kViewsFirstRunDialog));
|
||||
}
|
||||
#endif
|
||||
@@ -501,8 +501,6 @@ source_set("ui") {
|
||||
"views/bookmarks/brave_bookmark_context_menu.h",
|
||||
"views/bookmarks/saved_tab_groups/brave_saved_tab_group_button.cc",
|
||||
"views/bookmarks/saved_tab_groups/brave_saved_tab_group_button.h",
|
||||
"views/brave_first_run_dialog.cc",
|
||||
"views/brave_first_run_dialog.h",
|
||||
"views/brave_javascript_tab_modal_dialog_view_views.cc",
|
||||
"views/brave_javascript_tab_modal_dialog_view_views.h",
|
||||
"views/brave_layout_provider.cc",
|
||||
|
||||
@@ -1,189 +0,0 @@
|
||||
/* Copyright (c) 2022 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "brave/browser/ui/views/brave_first_run_dialog.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "brave/grit/brave_generated_resources.h"
|
||||
#include "chrome/browser/first_run/first_run.h"
|
||||
#include "chrome/browser/first_run/first_run_dialog.h"
|
||||
#include "chrome/browser/ui/ui_features.h"
|
||||
#include "chrome/grit/branded_strings.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/metadata/metadata_impl_macros.h"
|
||||
#include "ui/base/mojom/dialog_button.mojom.h"
|
||||
#include "ui/gfx/font.h"
|
||||
#include "ui/gfx/geometry/insets.h"
|
||||
#include "ui/views/controls/button/checkbox.h"
|
||||
#include "ui/views/controls/label.h"
|
||||
#include "ui/views/layout/box_layout.h"
|
||||
#include "ui/views/window/dialog_delegate.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_PIN_SHORTCUT)
|
||||
#include "brave/browser/brave_shell_integration.h"
|
||||
#else // BUILDFLAG(ENABLE_PIN_SHORTCUT)
|
||||
#include "chrome/browser/shell_integration.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
void ShowBraveFirstRunDialogViews() {
|
||||
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
|
||||
BraveFirstRunDialog::Show(run_loop.QuitClosure());
|
||||
run_loop.Run();
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_PIN_SHORTCUT)
|
||||
class PinShortcutCheckbox : public views::Checkbox {
|
||||
METADATA_HEADER(PinShortcutCheckbox, views::Checkbox)
|
||||
public:
|
||||
|
||||
PinShortcutCheckbox() {
|
||||
SetFontList();
|
||||
SetText(l10n_util::GetStringUTF16(IDS_FIRSTRUN_DLG_PIN_SHORTCUT_TEXT));
|
||||
}
|
||||
~PinShortcutCheckbox() override = default;
|
||||
PinShortcutCheckbox(const PinShortcutCheckbox&) = delete;
|
||||
PinShortcutCheckbox& operator=(const PinShortcutCheckbox&) = delete;
|
||||
|
||||
private:
|
||||
void SetFontList() {
|
||||
gfx::FontList font_list;
|
||||
constexpr int kFontSize = 14;
|
||||
font_list.Derive(kFontSize - font_list.GetFontSize(),
|
||||
font_list.GetFontStyle(), gfx::Font::Weight::NORMAL);
|
||||
label()->SetFontList(font_list);
|
||||
}
|
||||
};
|
||||
|
||||
BEGIN_METADATA(PinShortcutCheckbox)
|
||||
END_METADATA
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace first_run {
|
||||
|
||||
void ShowFirstRunDialog() {
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
if (base::FeatureList::IsEnabled(features::kViewsFirstRunDialog))
|
||||
ShowBraveFirstRunDialogViews();
|
||||
else
|
||||
ShowFirstRunDialogCocoa();
|
||||
#else
|
||||
ShowBraveFirstRunDialogViews();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace first_run
|
||||
|
||||
// static
|
||||
void BraveFirstRunDialog::Show(base::RepeatingClosure quit_runloop) {
|
||||
BraveFirstRunDialog* dialog =
|
||||
new BraveFirstRunDialog(std::move(quit_runloop));
|
||||
views::DialogDelegate::CreateDialogWidget(dialog, gfx::NativeWindow(),
|
||||
gfx::NativeView())
|
||||
->Show();
|
||||
}
|
||||
|
||||
BraveFirstRunDialog::BraveFirstRunDialog(base::RepeatingClosure quit_runloop)
|
||||
: quit_runloop_(quit_runloop) {
|
||||
set_should_ignore_snapping(true);
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
SetTitle(IDS_FIRST_RUN_DIALOG_WINDOW_TITLE);
|
||||
#endif
|
||||
SetButtonLabel(ui::mojom::DialogButton::kOk,
|
||||
l10n_util::GetStringUTF16(IDS_FIRSTRUN_DLG_OK_BUTTON_LABEL));
|
||||
SetButtonLabel(
|
||||
ui::mojom::DialogButton::kCancel,
|
||||
l10n_util::GetStringUTF16(IDS_FIRSTRUN_DLG_CANCEL_BUTTON_LABEL));
|
||||
|
||||
constexpr int kHeaderFontSize = 16;
|
||||
int size_diff =
|
||||
kHeaderFontSize - views::Label::GetDefaultFontList().GetFontSize();
|
||||
views::Label::CustomFont header_font = {
|
||||
views::Label::GetDefaultFontList()
|
||||
.DeriveWithSizeDelta(size_diff)
|
||||
.DeriveWithWeight(gfx::Font::Weight::SEMIBOLD)};
|
||||
auto* header_label = AddChildView(std::make_unique<views::Label>(
|
||||
l10n_util::GetStringUTF16(IDS_FIRSTRUN_DLG_HEADER_TEXT), header_font));
|
||||
header_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
||||
|
||||
constexpr int kContentFontSize = 15;
|
||||
size_diff =
|
||||
kContentFontSize - views::Label::GetDefaultFontList().GetFontSize();
|
||||
views::Label::CustomFont contents_font = {
|
||||
views::Label::GetDefaultFontList()
|
||||
.DeriveWithSizeDelta(size_diff)
|
||||
.DeriveWithWeight(gfx::Font::Weight::NORMAL)};
|
||||
auto* contents_label = AddChildView(std::make_unique<views::Label>(
|
||||
l10n_util::GetStringUTF16(IDS_FIRSTRUN_DLG_CONTENTS_TEXT),
|
||||
contents_font));
|
||||
contents_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
||||
contents_label->SetMultiLine(true);
|
||||
constexpr int kMaxWidth = 350;
|
||||
contents_label->SetMaximumWidth(kMaxWidth);
|
||||
|
||||
#if BUILDFLAG(ENABLE_PIN_SHORTCUT)
|
||||
pin_shortcut_checkbox_ =
|
||||
AddChildView(std::make_unique<PinShortcutCheckbox>());
|
||||
#endif
|
||||
|
||||
constexpr int kChildSpacing = 16;
|
||||
constexpr int kPadding = 24;
|
||||
constexpr int kTopPadding = 20;
|
||||
int kBottomPadding = 55;
|
||||
|
||||
#if BUILDFLAG(ENABLE_PIN_SHORTCUT)
|
||||
kBottomPadding -= pin_shortcut_checkbox_->GetPreferredSize().height();
|
||||
#endif
|
||||
|
||||
SetLayoutManager(std::make_unique<views::BoxLayout>(
|
||||
views::BoxLayout::Orientation::kVertical,
|
||||
gfx::Insets::TLBR(kTopPadding, kPadding, kBottomPadding, kPadding),
|
||||
kChildSpacing));
|
||||
}
|
||||
|
||||
BraveFirstRunDialog::~BraveFirstRunDialog() = default;
|
||||
|
||||
void BraveFirstRunDialog::Done() {
|
||||
CHECK(!quit_runloop_.is_null());
|
||||
quit_runloop_.Run();
|
||||
}
|
||||
|
||||
bool BraveFirstRunDialog::Accept() {
|
||||
GetWidget()->Hide();
|
||||
|
||||
#if BUILDFLAG(ENABLE_PIN_SHORTCUT)
|
||||
base::MakeRefCounted<shell_integration::BraveDefaultBrowserWorker>()
|
||||
->StartSetAsDefault(base::BindOnce(
|
||||
[](bool pin_to_shortcut,
|
||||
shell_integration::DefaultWebClientState state) {
|
||||
if (pin_to_shortcut &&
|
||||
state == shell_integration::DefaultWebClientState::IS_DEFAULT) {
|
||||
// Try to pin to taskbar when Brave is set as a default browser.
|
||||
shell_integration::PinShortcut();
|
||||
}
|
||||
},
|
||||
pin_shortcut_checkbox_->GetChecked()));
|
||||
#else
|
||||
shell_integration::SetAsDefaultBrowser();
|
||||
#endif
|
||||
|
||||
Done();
|
||||
return true;
|
||||
}
|
||||
|
||||
void BraveFirstRunDialog::WindowClosing() {
|
||||
Done();
|
||||
}
|
||||
|
||||
BEGIN_METADATA(BraveFirstRunDialog)
|
||||
END_METADATA
|
||||
@@ -1,48 +0,0 @@
|
||||
/* Copyright (c) 2022 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BRAVE_BROWSER_UI_VIEWS_BRAVE_FIRST_RUN_DIALOG_H_
|
||||
#define BRAVE_BROWSER_UI_VIEWS_BRAVE_FIRST_RUN_DIALOG_H_
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "brave/browser/shell_integrations/buildflags/buildflags.h"
|
||||
#include "ui/base/metadata/metadata_header_macros.h"
|
||||
#include "ui/views/window/dialog_delegate.h"
|
||||
|
||||
namespace views {
|
||||
class Checkbox;
|
||||
} // namespace views
|
||||
|
||||
class BraveFirstRunDialog : public views::DialogDelegateView {
|
||||
METADATA_HEADER(BraveFirstRunDialog, views::DialogDelegateView)
|
||||
public:
|
||||
|
||||
BraveFirstRunDialog(const BraveFirstRunDialog&) = delete;
|
||||
BraveFirstRunDialog& operator=(const BraveFirstRunDialog&) = delete;
|
||||
|
||||
static void Show(base::RepeatingClosure quit_runloop);
|
||||
|
||||
private:
|
||||
explicit BraveFirstRunDialog(base::RepeatingClosure quit_runloop);
|
||||
~BraveFirstRunDialog() override;
|
||||
|
||||
// This terminates the nested message-loop.
|
||||
void Done();
|
||||
|
||||
// views::DialogDelegate overrides:
|
||||
bool Accept() override;
|
||||
|
||||
// views::WidgetDelegate overrides:
|
||||
void WindowClosing() override;
|
||||
|
||||
base::RepeatingClosure quit_runloop_;
|
||||
|
||||
#if BUILDFLAG(ENABLE_PIN_SHORTCUT)
|
||||
raw_ptr<views::Checkbox> pin_shortcut_checkbox_ = nullptr;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // BRAVE_BROWSER_UI_VIEWS_BRAVE_FIRST_RUN_DIALOG_H_
|
||||
@@ -1,27 +0,0 @@
|
||||
/* Copyright (c) 2022 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_FIRST_RUN_FIRST_RUN_DIALOG_H_
|
||||
#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_FIRST_RUN_FIRST_RUN_DIALOG_H_
|
||||
|
||||
#include <chrome/browser/first_run/first_run_dialog.h> // IWYU pragma: export
|
||||
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
|
||||
class Profile;
|
||||
|
||||
namespace first_run {
|
||||
|
||||
// Enable first run dialog on Win also.
|
||||
// Upstream only uses it for macOS/Linux.
|
||||
void ShowFirstRunDialog();
|
||||
|
||||
} // namespace first_run
|
||||
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_FIRST_RUN_FIRST_RUN_DIALOG_H_
|
||||
@@ -1,202 +0,0 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "chrome/browser/ui/cocoa/first_run_dialog_controller.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "base/i18n/rtl.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "brave/browser/brave_shell_integration.h"
|
||||
#include "brave/browser/metrics/metrics_reporting_util.h"
|
||||
#include "brave/grit/brave_generated_resources.h"
|
||||
#include "chrome/grit/branded_strings.h"
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
#import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTweaker.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/l10n/l10n_util_mac.h"
|
||||
#include "ui/color/color_provider_key.h"
|
||||
|
||||
@implementation FirstRunDialogViewController {
|
||||
BOOL _setAsDefaultBrowser;
|
||||
NSButton* _dockCheckbox;
|
||||
}
|
||||
|
||||
- (instancetype)initWithStatsCheckboxInitiallyChecked:(BOOL)checked {
|
||||
if ((self = [super init])) {
|
||||
_setAsDefaultBrowser = NO;
|
||||
_dockCheckbox = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)loadView {
|
||||
constexpr int kDialogMinWidth = 400;
|
||||
constexpr int kPadding = 24;
|
||||
constexpr int kLabelSpacing = 16;
|
||||
constexpr int kTopPadding = 20;
|
||||
constexpr int kCheckboxTopMargin = 20;
|
||||
constexpr int kButtonTopMargin = 40;
|
||||
constexpr int kButtonBottomMargin = 20;
|
||||
constexpr int kButtonHorizontalMargin = 20;
|
||||
constexpr int kButtonSpacing = 3;
|
||||
|
||||
NSButton* maybeLaterButton =
|
||||
[NSButton buttonWithTitle:l10n_util::GetNSString(
|
||||
IDS_FIRSTRUN_DLG_CANCEL_BUTTON_LABEL)
|
||||
target:self
|
||||
action:@selector(cancel:)];
|
||||
[maybeLaterButton sizeToFit];
|
||||
|
||||
NSButton* makeDefaultButton = [NSButton
|
||||
buttonWithTitle:l10n_util::GetNSString(IDS_FIRSTRUN_DLG_OK_BUTTON_LABEL)
|
||||
target:self
|
||||
action:@selector(ok:)];
|
||||
[makeDefaultButton sizeToFit];
|
||||
|
||||
// Calculate proper dialog width that can include two buttons.
|
||||
const int preferredDialogWidth = NSWidth(maybeLaterButton.frame) +
|
||||
NSWidth(makeDefaultButton.frame) +
|
||||
2 * kButtonHorizontalMargin + kButtonSpacing;
|
||||
const int dialogWidth = std::max(kDialogMinWidth, preferredDialogWidth);
|
||||
const int contentsWidth = dialogWidth - (2 * kPadding);
|
||||
|
||||
// After calculating all controls' proper height based on |contentsWidth|,
|
||||
// window's height will be calculated.
|
||||
std::u16string headerString =
|
||||
l10n_util::GetStringUTF16(IDS_FIRSTRUN_DLG_HEADER_TEXT);
|
||||
base::i18n::AdjustStringForLocaleDirection(&headerString);
|
||||
NSTextField* headerLabel =
|
||||
[NSTextField labelWithString:base::SysUTF16ToNSString(headerString)];
|
||||
[headerLabel setFont:[NSFont systemFontOfSize:16.0
|
||||
weight:NSFontWeightSemibold]];
|
||||
[headerLabel sizeToFit];
|
||||
[headerLabel setLineBreakMode:NSLineBreakByWordWrapping];
|
||||
CGSize preferredSize =
|
||||
[headerLabel sizeThatFits:CGSizeMake(contentsWidth, 0)];
|
||||
[headerLabel
|
||||
setFrame:NSMakeRect(0, 0, preferredSize.width, preferredSize.height)];
|
||||
|
||||
std::u16string contentsString =
|
||||
l10n_util::GetStringUTF16(IDS_FIRSTRUN_DLG_CONTENTS_TEXT);
|
||||
base::i18n::AdjustStringForLocaleDirection(&contentsString);
|
||||
NSTextField* contentsLabel =
|
||||
[NSTextField labelWithString:base::SysUTF16ToNSString(contentsString)];
|
||||
[contentsLabel setFont:[NSFont systemFontOfSize:15.0
|
||||
weight:NSFontWeightRegular]];
|
||||
[contentsLabel sizeToFit];
|
||||
[contentsLabel setLineBreakMode:NSLineBreakByWordWrapping];
|
||||
preferredSize = [contentsLabel sizeThatFits:CGSizeMake(contentsWidth, 0)];
|
||||
[contentsLabel
|
||||
setFrame:NSMakeRect(0, 0, preferredSize.width, preferredSize.height)];
|
||||
|
||||
std::u16string dockCheckboxString =
|
||||
l10n_util::GetStringUTF16(IDS_FIRSTRUN_DLG_PIN_SHORTCUT_TEXT);
|
||||
base::i18n::AdjustStringForLocaleDirection(&dockCheckboxString);
|
||||
_dockCheckbox = [[NSButton alloc] init];
|
||||
[_dockCheckbox setButtonType:NSButtonTypeSwitch];
|
||||
[_dockCheckbox setTitle:base::SysUTF16ToNSString(dockCheckboxString)];
|
||||
[_dockCheckbox setFont:[NSFont systemFontOfSize:14.0
|
||||
weight:NSFontWeightRegular]];
|
||||
[_dockCheckbox sizeToFit];
|
||||
|
||||
// It's time to calculate window's height as we can get all controls' final
|
||||
// heights.
|
||||
const int windowHeight = kTopPadding + NSHeight(headerLabel.frame) +
|
||||
kLabelSpacing + NSHeight(contentsLabel.frame) +
|
||||
kCheckboxTopMargin + NSHeight(_dockCheckbox.frame) +
|
||||
kButtonTopMargin + NSHeight(maybeLaterButton.frame) +
|
||||
kButtonBottomMargin;
|
||||
|
||||
BOOL isDarkMode = NO;
|
||||
if (@available(macOS 10.14, *)) {
|
||||
NSAppearanceName appearance =
|
||||
[[NSApp effectiveAppearance] bestMatchFromAppearancesWithNames:@[
|
||||
NSAppearanceNameAqua, NSAppearanceNameDarkAqua
|
||||
]];
|
||||
isDarkMode = [appearance isEqual:NSAppearanceNameDarkAqua];
|
||||
}
|
||||
NSColor* backgroundColor = isDarkMode
|
||||
? [NSColor colorWithCalibratedRed:0x32 / 255.0
|
||||
green:0x36 / 255.0
|
||||
blue:0x39 / 255.0
|
||||
alpha:1.0]
|
||||
: [NSColor whiteColor];
|
||||
|
||||
NSView* content_view = [[NSView alloc]
|
||||
initWithFrame:NSMakeRect(0, 0, dialogWidth, windowHeight)];
|
||||
self.view = content_view;
|
||||
[self.view setValue:backgroundColor forKey:@"backgroundColor"];
|
||||
[self.view addSubview:headerLabel];
|
||||
[self.view addSubview:contentsLabel];
|
||||
[self.view addSubview:_dockCheckbox];
|
||||
[self.view addSubview:maybeLaterButton];
|
||||
[self.view addSubview:makeDefaultButton];
|
||||
|
||||
// Set each control's position
|
||||
NSRect frame = headerLabel.frame;
|
||||
frame.origin.x = kPadding;
|
||||
frame.origin.y = windowHeight - kTopPadding - NSHeight(frame);
|
||||
[headerLabel setFrame:frame];
|
||||
|
||||
frame = contentsLabel.frame;
|
||||
frame.origin.x = kPadding;
|
||||
frame.origin.y = NSMinY(headerLabel.frame) - kLabelSpacing - NSHeight(frame);
|
||||
[contentsLabel setFrame:frame];
|
||||
|
||||
frame = _dockCheckbox.frame;
|
||||
frame.origin.x = kPadding;
|
||||
frame.origin.y =
|
||||
NSMinY(contentsLabel.frame) - kCheckboxTopMargin - NSHeight(frame);
|
||||
[_dockCheckbox setFrame:frame];
|
||||
|
||||
frame = makeDefaultButton.frame;
|
||||
frame.origin.x = dialogWidth - kButtonHorizontalMargin - NSWidth(frame);
|
||||
if (base::i18n::IsRTL()) {
|
||||
frame.origin.x = kButtonHorizontalMargin;
|
||||
}
|
||||
frame.origin.y =
|
||||
NSMinY(_dockCheckbox.frame) - kButtonTopMargin - NSHeight(frame);
|
||||
[makeDefaultButton setFrame:frame];
|
||||
|
||||
frame = maybeLaterButton.frame;
|
||||
frame.origin.x =
|
||||
NSMinX(makeDefaultButton.frame) - kButtonSpacing - NSWidth(frame);
|
||||
if (base::i18n::IsRTL()) {
|
||||
frame.origin.x = NSMaxX(makeDefaultButton.frame) + kButtonSpacing;
|
||||
}
|
||||
frame.origin.y = NSMinY(makeDefaultButton.frame);
|
||||
[maybeLaterButton setFrame:frame];
|
||||
}
|
||||
|
||||
- (NSString*)windowTitle {
|
||||
return l10n_util::GetNSString(IDS_FIRST_RUN_DIALOG_WINDOW_TITLE);
|
||||
}
|
||||
|
||||
- (BOOL)isStatsReportingEnabled {
|
||||
// Give default value because we don't provide checkbox for this option.
|
||||
return GetDefaultPrefValueForMetricsReporting();
|
||||
}
|
||||
|
||||
- (BOOL)isMakeDefaultBrowserEnabled {
|
||||
return _setAsDefaultBrowser;
|
||||
}
|
||||
|
||||
- (void)ok:(id)sender {
|
||||
_setAsDefaultBrowser = YES;
|
||||
if ([_dockCheckbox state] == NSControlStateValueOn) {
|
||||
shell_integration::PinShortcut();
|
||||
}
|
||||
|
||||
[[[self view] window] close];
|
||||
[NSApp stopModal];
|
||||
}
|
||||
|
||||
- (void)cancel:(id)sender {
|
||||
[[[self view] window] close];
|
||||
[NSApp stopModal];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,14 +0,0 @@
|
||||
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "chrome/browser/ui/views/first_run_dialog.h"
|
||||
|
||||
// We use our own FirstRun dialog on Windows/Linux.
|
||||
// ShowFirstRunDialog() is re-defined at brave_first_run_dialog.cc.
|
||||
#define ShowFirstRunDialog ShowFirstRunDialog_UnUsed
|
||||
|
||||
#include <chrome/browser/ui/views/first_run_dialog.cc>
|
||||
|
||||
#undef ShowFirstRunDialog
|
||||
@@ -8,19 +8,20 @@
|
||||
|
||||
#include "ui/views/widget/widget_delegate.h"
|
||||
|
||||
#define ResetViewShownTimeStampForTesting \
|
||||
set_should_ignore_snapping(bool should_ignore_snapping) { \
|
||||
should_ignore_snapping_ = should_ignore_snapping; \
|
||||
} \
|
||||
bool should_ignore_snapping() const { return should_ignore_snapping_; } \
|
||||
\
|
||||
private: \
|
||||
bool should_ignore_snapping_ = false; \
|
||||
\
|
||||
public: \
|
||||
#define ResetViewShownTimeStampForTesting \
|
||||
set_should_ignore_snapping(bool should_ignore_snapping) { \
|
||||
should_ignore_snapping_ = should_ignore_snapping; \
|
||||
} \
|
||||
bool should_ignore_snapping() const { \
|
||||
return should_ignore_snapping_; \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
bool should_ignore_snapping_ = false; \
|
||||
\
|
||||
public: \
|
||||
void ResetViewShownTimeStampForTesting
|
||||
|
||||
class BraveFirstRunDialog;
|
||||
class CrashReportPermissionAskDialogView;
|
||||
class WindowClosingConfirmDialogView;
|
||||
class PlaylistActionDialog;
|
||||
@@ -34,7 +35,6 @@ class BraveVpnDnsSettingsNotificiationDialogView;
|
||||
|
||||
#define CreatePassKey \
|
||||
CreatePassKey_Unused(); \
|
||||
friend class ::BraveFirstRunDialog; \
|
||||
friend class ::CrashReportPermissionAskDialogView; \
|
||||
friend class ::WindowClosingConfirmDialogView; \
|
||||
friend class ::PlaylistActionDialog; \
|
||||
|
||||
@@ -177,7 +177,6 @@ test("brave_unit_tests") {
|
||||
"//brave/browser/decentralized_dns/test:unit_tests",
|
||||
"//brave/browser/email_aliases:unit_tests",
|
||||
"//brave/browser/ephemeral_storage:unit_tests",
|
||||
"//brave/browser/first_run:unit_tests",
|
||||
"//brave/browser/global_privacy_control:unit_tests",
|
||||
"//brave/browser/metrics:brave_metrics_unit_tests",
|
||||
"//brave/browser/misc_metrics:unit_tests",
|
||||
|
||||
Reference in New Issue
Block a user