-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement crash reporting permission ask dialog
fix brave/brave-browser#1841 Launch crash reporting permission ask dialog on startup after crash. Launch tab restore dialog after permission ask dialog is closed. By overriding, ShowIfNotOffTheRecordProfileBrave() is called instead of ShowIfNotOffTheRecordProfile(). ShowIfNotOffTheRecordProfileBrave() will launch crash reporting permission ask dialog and then tab restore dialog is launched after permission ask dialog is closed.
- Loading branch information
Showing
21 changed files
with
551 additions
and
10 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
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
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,50 @@ | ||
// 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/. | ||
|
||
CANVAS_DIMENSIONS, 24, | ||
MOVE_TO, 22, 23, | ||
H_LINE_TO, 2, | ||
R_CUBIC_TO, -1.1f, 0, -2, -0.9f, -2, -2, | ||
V_LINE_TO, 3, | ||
R_CUBIC_TO, 0, -1.1f, 0.9f, -2, 2, -2, | ||
R_H_LINE_TO, 20, | ||
R_CUBIC_TO, 1.1f, 0, 2, 0.9f, 2, 2, | ||
R_V_LINE_TO, 18, | ||
R_CUBIC_TO, 0, 1.1f, -0.9f, 2, -2, 2, | ||
CLOSE, | ||
R_MOVE_TO, 0, -2, | ||
R_LINE_TO, 0, -14, | ||
H_LINE_TO, 2, | ||
R_V_LINE_TO, 14, | ||
R_H_LINE_TO, 20, | ||
CLOSE, | ||
MOVE_TO, 2, 3, | ||
R_V_LINE_TO, 2, | ||
R_H_LINE_TO, 20, | ||
V_LINE_TO, 3, | ||
H_LINE_TO, 2, | ||
CLOSE, | ||
R_MOVE_TO, 6.64f, 14.66f, | ||
R_ARC_TO, 0.99f, 0.99f, 0, 0, 1, -1.41f, -0.13f, | ||
R_ARC_TO, 1.03f, 1.03f, 0, 0, 1, 0.13f, -1.43f, | ||
R_CUBIC_TO, 1.5f, -1.27f, 3.05f, -1.92f, 4.64f, -1.92f, | ||
R_CUBIC_TO, 1.59f, 0, 3.14f, 0.66f, 4.64f, 1.93f, | ||
R_CUBIC_TO, 0.42f, 0.36f, 0.48f, 1, 0.13f, 1.43f, | ||
R_ARC_TO, 0.99f, 0.99f, 0, 0, 1, -1.41f, 0.13f, | ||
CUBIC_TO, 14.2f, 16.67f, 13.08f, 16.2f, 12, 16.2f, | ||
R_CUBIC_TO, -1.08f, 0, -2.2f, 0.47f, -3.36f, 1.46f, | ||
CLOSE, | ||
MOVE_TO, 9, 12.14f, | ||
R_CUBIC_TO, 0.55f, 0, 1, -0.45f, 1, -1.01f, | ||
R_CUBIC_TO, 0, -0.56f, -0.45f, -1.01f, -1, -1.01f, | ||
R_CUBIC_TO, -0.55f, 0, -1, 0.45f, -1, 1.01f, | ||
R_CUBIC_TO, 0, 0.56f, 0.45f, 1.02f, 1, 1.02f, | ||
CLOSE, | ||
R_MOVE_TO, 6, 0, | ||
R_CUBIC_TO, 0.55f, 0, 1, -0.45f, 1, -1.01f, | ||
R_CUBIC_TO, 0, -0.56f, -0.45f, -1.01f, -1, -1.01f, | ||
R_CUBIC_TO, -0.55f, 0, -1, 0.45f, -1, 1.01f, | ||
R_CUBIC_TO, 0, 0.56f, 0.45f, 1.02f, 1, 1.02f, | ||
CLOSE |
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
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,11 @@ | ||
/* 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 "brave/browser/metrics/brave_metrics_service_accessor.h" | ||
#include "chrome/browser/browser_process.h" | ||
|
||
bool BraveMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled() { | ||
return IsMetricsReportingEnabled(g_browser_process->local_state()); | ||
} |
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,21 @@ | ||
/* 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/. */ | ||
|
||
#ifndef BRAVE_BROWSER_METRICS_BRAVE_METRICS_SERVICE_ACCESSOR_H_ | ||
#define BRAVE_BROWSER_METRICS_BRAVE_METRICS_SERVICE_ACCESSOR_H_ | ||
|
||
#include "components/metrics/metrics_service_accessor.h" | ||
|
||
// This class limits and documents access to metrics service helper methods. | ||
// Since these methods are private, each user has to be explicitly declared | ||
// as a 'friend' below. | ||
class BraveMetricsServiceAccessor : public metrics::MetricsServiceAccessor { | ||
private: | ||
friend bool ShouldShowCrashReportPermissionAskDialog(); | ||
|
||
static bool IsMetricsAndCrashReportingEnabled(); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_METRICS_BRAVE_METRICS_SERVICE_ACCESSOR_H_ |
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
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
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,27 @@ | ||
/* 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 <memory> | ||
|
||
#include "brave/browser/metrics/metrics_reporting_util.h" | ||
#include "chrome/test/base/scoped_testing_local_state.h" | ||
#include "chrome/test/base/testing_browser_process.h" | ||
#include "components/metrics/metrics_pref_names.h" | ||
#include "components/prefs/pref_service.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
TEST(MetricsUtilTest, CrashReportPermissionAskDialogTest) { | ||
std::unique_ptr<ScopedTestingLocalState> local_state = | ||
std::make_unique<ScopedTestingLocalState>( | ||
TestingBrowserProcess::GetGlobal()); | ||
|
||
g_browser_process->local_state()->SetBoolean( | ||
metrics::prefs::kMetricsReportingEnabled, false); | ||
EXPECT_TRUE(ShouldShowCrashReportPermissionAskDialog()); | ||
|
||
g_browser_process->local_state()->SetBoolean( | ||
metrics::prefs::kMetricsReportingEnabled, true); | ||
EXPECT_FALSE(ShouldShowCrashReportPermissionAskDialog()); | ||
} |
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
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
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
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
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
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,20 @@ | ||
/* 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 "brave/browser/metrics/metrics_reporting_util.h" | ||
#include "brave/browser/ui/browser_dialogs.h" | ||
#include "chrome/browser/ui/session_crashed_bubble.h" | ||
|
||
// static | ||
void SessionCrashedBubble::ShowIfNotOffTheRecordProfileBrave(Browser* browser) { | ||
// If crash report permission ask dialog is launched, tab restore bubble will | ||
// be shown after closing aks dialog. | ||
if (ShouldShowCrashReportPermissionAskDialog()) { | ||
brave::ShowCrashReportPermissionAskDialog(browser); | ||
return; | ||
} | ||
|
||
ShowIfNotOffTheRecordProfile(browser); | ||
} |
36 changes: 36 additions & 0 deletions
36
browser/ui/views/crash_report_permission_ask_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* 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 "brave/browser/metrics/metrics_reporting_util.h" | ||
#include "brave/browser/ui/brave_browser.h" | ||
#include "chrome/browser/browser_process.h" | ||
#include "chrome/browser/ui/session_crashed_bubble.h" | ||
#include "chrome/browser/ui/test/test_browser_dialog.h" | ||
#include "components/metrics/metrics_pref_names.h" | ||
#include "components/prefs/pref_service.h" | ||
#include "content/public/test/browser_test.h" | ||
|
||
class CrashReportPermissionAskDialogTest : public DialogBrowserTest { | ||
public: | ||
CrashReportPermissionAskDialogTest() = default; | ||
~CrashReportPermissionAskDialogTest() override = default; | ||
|
||
// TestBrowserUi: | ||
void ShowUi(const std::string& name) override { | ||
SessionCrashedBubble::ShowIfNotOffTheRecordProfileBrave(browser()); | ||
} | ||
}; | ||
|
||
IN_PROC_BROWSER_TEST_F(CrashReportPermissionAskDialogTest, InvokeUi_Dialog) { | ||
// When reporting is disabled, crash report permission ask dialog is launched. | ||
g_browser_process->local_state()->SetBoolean( | ||
metrics::prefs::kMetricsReportingEnabled, false); | ||
ShowAndVerifyUi(); | ||
|
||
// When reporting is enabled, tab restore dialog is launched. | ||
g_browser_process->local_state()->SetBoolean( | ||
metrics::prefs::kMetricsReportingEnabled, true); | ||
ShowAndVerifyUi(); | ||
} |
Oops, something went wrong.