-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
117 additions
and
0 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
39 changes: 39 additions & 0 deletions
39
chromium_src/chrome/browser/first_run/first_run_internal_posix.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,39 @@ | ||
/* 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/first_run/first_run_internal.h" | ||
|
||
#include "base/files/file_path.h" | ||
#include "base/files/file_util.h" | ||
#include "base/no_destructor.h" | ||
#include "base/path_service.h" | ||
#include "build/branding_buildflags.h" | ||
#include "build/build_config.h" | ||
#include "chrome/browser/browser_process.h" | ||
#include "chrome/browser/first_run/first_run.h" | ||
#include "chrome/browser/first_run/first_run_dialog.h" | ||
#include "chrome/browser/metrics/metrics_reporting_state.h" | ||
#include "chrome/common/chrome_constants.h" | ||
#include "chrome/common/chrome_paths.h" | ||
#include "chrome/common/chrome_switches.h" | ||
#include "chrome/installer/util/google_update_settings.h" | ||
#include "chrome/installer/util/initial_preferences.h" | ||
#include "components/metrics/metrics_pref_names.h" | ||
#include "components/metrics/metrics_reporting_default_state.h" | ||
#include "components/prefs/pref_service.h" | ||
#include "components/startup_metric_utils/browser/startup_metric_utils.h" | ||
|
||
// All above headers copied from original first_run_internal_posix.cc are | ||
// included to prevent below GOOGLE_CHROEM_BUILD affect them. | ||
|
||
// First run dialog is only enabled for google chrome by default. | ||
#if defined(OFFICIAL_BUILD) && defined(OS_MAC) | ||
#undef BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING | ||
#define BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING() (1) | ||
#endif | ||
#include "../../../../../chrome/browser/first_run/first_run_internal_posix.cc" | ||
#if defined(OFFICIAL_BUILD) && defined(OS_MAC) | ||
#undef BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING | ||
#endif |
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,55 @@ | ||
/* 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 "brave/components/p3a/buildflags.h" | ||
#include "chrome/browser/browser_process.h" | ||
#include "components/prefs/pref_service.h" | ||
|
||
#if BUILDFLAG(BRAVE_P3A_ENABLED) | ||
#include "brave/components/p3a/pref_names.h" | ||
#endif | ||
|
||
#define ShowFirstRunDialog ShowFirstRunDialog_UnUsed | ||
#include "../../../../../../chrome/browser/ui/cocoa/first_run_dialog.mm" | ||
#undef ShowFirstRunDialog | ||
|
||
namespace { | ||
|
||
// Copied ShowFirstRunModal from upstream and p3a prefs part added. | ||
void ShowFirstRunModalBrave(Profile* profile) { | ||
base::scoped_nsobject<FirstRunDialogController> dialog( | ||
[[FirstRunDialogController alloc] init]); | ||
|
||
[dialog.get() showWindow:nil]; | ||
|
||
// If the dialog asked the user to opt-in for stats and crash reporting, | ||
// record the decision and enable the crash reporter if appropriate. | ||
bool consent_given = [dialog.get() isStatsReportingEnabled]; | ||
ChangeMetricsReportingState(consent_given); | ||
|
||
#if BUILDFLAG(BRAVE_P3A_ENABLED) | ||
PrefService* local_state = g_browser_process->local_state(); | ||
local_state->SetBoolean(brave::kP3AEnabled, consent_given); | ||
#endif | ||
|
||
// If selected, set as default browser. Skip in automated tests so that an OS | ||
// dialog confirming the default browser choice isn't left on screen. | ||
BOOL make_default_browser = | ||
[dialog.get() isMakeDefaultBrowserEnabled] && | ||
!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType); | ||
if (make_default_browser) { | ||
bool success = shell_integration::SetAsDefaultBrowser(); | ||
DCHECK(success); | ||
} | ||
} | ||
} // namespace | ||
|
||
namespace first_run { | ||
|
||
void ShowFirstRunDialog(Profile* profile) { | ||
ShowFirstRunModalBrave(profile); | ||
} | ||
|
||
} // namespace first_run |
17 changes: 17 additions & 0 deletions
17
chromium_src/chrome/browser/ui/cocoa/first_run_dialog_controller.mm
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,17 @@ | ||
/* 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 "brave/grit/brave_generated_resources.h" | ||
#include "chrome/grit/generated_resources.h" | ||
|
||
// Replaced string here instead of by running 'npm run chromium_rebase_l10n' | ||
// because string replacement failed with string that include place holder like | ||
// <ph name="PRODUCT_NAME">$1<ex>Brave</ex></ph>. I assume this include some | ||
// special charactors. | ||
#undef IDS_FIRSTRUN_DLG_MAC_OPTIONS_SEND_USAGE_STATS_LABEL | ||
#define IDS_FIRSTRUN_DLG_MAC_OPTIONS_SEND_USAGE_STATS_LABEL \ | ||
IDS_FIRSTRUN_DLG_MAC_OPTIONS_SEND_USAGE_STATS_LABEL_BRAVE | ||
#include "../../../../../../chrome/browser/ui/cocoa/first_run_dialog_controller.mm" | ||
#undef IDS_FIRSTRUN_DLG_MAC_OPTIONS_SEND_USAGE_STATS_LABEL |