-
Notifications
You must be signed in to change notification settings - Fork 879
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3420 from brave/webcompatreporter
Add webcompat issue reporting dialog
- Loading branch information
Showing
71 changed files
with
1,419 additions
and
29 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
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
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,75 @@ | ||
/* Copyright (c) 2019 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/webui/webcompat_reporter_ui.h" | ||
|
||
#include <memory> | ||
|
||
#include "brave/browser/ui/webui/basic_ui.h" | ||
#include "brave/common/webui_url_constants.h" | ||
#include "brave/components/webcompat_reporter/resources/grit/webcompat_reporter_generated_map.h" | ||
#include "chrome/browser/browser_process.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "components/grit/brave_components_resources.h" | ||
#include "content/public/browser/web_ui_data_source.h" | ||
#include "content/public/browser/web_ui_message_handler.h" | ||
|
||
#include "brave/components/webcompat_reporter/browser/webcompat_report_uploader.h" | ||
|
||
namespace { | ||
|
||
class WebcompatReporterDOMHandler : public content::WebUIMessageHandler { | ||
public: | ||
WebcompatReporterDOMHandler(); | ||
~WebcompatReporterDOMHandler() override; | ||
|
||
// WebUIMessageHandler implementation. | ||
void RegisterMessages() override; | ||
|
||
private: | ||
void HandleSubmitReport(const base::ListValue* args); | ||
std::unique_ptr<brave::WebcompatReportUploader> uploader_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(WebcompatReporterDOMHandler); | ||
}; | ||
|
||
WebcompatReporterDOMHandler::WebcompatReporterDOMHandler() | ||
: uploader_(std::make_unique<brave::WebcompatReportUploader>( | ||
g_browser_process->shared_url_loader_factory())) {} | ||
|
||
WebcompatReporterDOMHandler::~WebcompatReporterDOMHandler() {} | ||
|
||
void WebcompatReporterDOMHandler::RegisterMessages() { | ||
web_ui()->RegisterMessageCallback( | ||
"webcompat_reporter.submitReport", | ||
base::BindRepeating(&WebcompatReporterDOMHandler::HandleSubmitReport, | ||
base::Unretained(this))); | ||
} | ||
|
||
void WebcompatReporterDOMHandler::HandleSubmitReport( | ||
const base::ListValue* args) { | ||
DCHECK_EQ(args->GetSize(), 1U); | ||
std::string site_url; | ||
if (!args->GetString(0, &site_url)) | ||
return; | ||
|
||
uploader_->SubmitReport(site_url); | ||
} | ||
|
||
} // namespace | ||
|
||
WebcompatReporterUI::WebcompatReporterUI(content::WebUI* web_ui, | ||
const std::string& name) | ||
: ConstrainedWebDialogUI(web_ui) { | ||
Profile* profile = Profile::FromWebUI(web_ui); | ||
content::WebUIDataSource* data_source = CreateBasicUIHTMLSource( | ||
profile, name, kWebcompatReporterGenerated, | ||
kWebcompatReporterGeneratedSize, IDR_WEBCOMPAT_REPORTER_HTML); | ||
content::WebUIDataSource::Add(profile, data_source); | ||
|
||
web_ui->AddMessageHandler(std::make_unique<WebcompatReporterDOMHandler>()); | ||
} | ||
|
||
WebcompatReporterUI::~WebcompatReporterUI() {} |
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) 2019 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_WEBUI_WEBCOMPAT_REPORTER_UI_H_ | ||
#define BRAVE_BROWSER_UI_WEBUI_WEBCOMPAT_REPORTER_UI_H_ | ||
|
||
#include <string> | ||
|
||
#include "base/macros.h" | ||
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | ||
|
||
namespace content { | ||
class WebUI; | ||
} | ||
|
||
class WebcompatReporterUI : public ConstrainedWebDialogUI { | ||
public: | ||
WebcompatReporterUI(content::WebUI* web_ui, const std::string& host); | ||
~WebcompatReporterUI() override; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(WebcompatReporterUI); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_UI_WEBUI_WEBCOMPAT_REPORTER_UI_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import("//build/config/features.gni") | ||
|
||
source_set("webcompat_reporter") { | ||
sources = [ | ||
"webcompat_reporter_dialog.cc", | ||
"webcompat_reporter_dialog.h", | ||
] | ||
|
||
deps = [ | ||
"//base", | ||
"//brave/common", | ||
"//content/public/browser", | ||
"//ui/web_dialogs", | ||
] | ||
} |
Oops, something went wrong.