mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2024-12-12 17:46:04 +01:00
146 lines
5.2 KiB
Diff
146 lines
5.2 KiB
Diff
diff --git chrome/browser/ui/BUILD.gn chrome/browser/ui/BUILD.gn
|
|
index 0cde2e77cdb18..94d4e8b6d234f 100644
|
|
--- chrome/browser/ui/BUILD.gn
|
|
+++ chrome/browser/ui/BUILD.gn
|
|
@@ -11,6 +11,7 @@ import("//build/config/features.gni")
|
|
import("//build/config/linux/gtk/gtk.gni")
|
|
import("//build/config/ozone.gni")
|
|
import("//build/config/ui.gni")
|
|
+import("//cef/libcef/features/features.gni")
|
|
import("//chrome/browser/buildflags.gni")
|
|
import("//chrome/common/features.gni")
|
|
import("//chromeos/assistant/assistant.gni")
|
|
@@ -369,6 +370,10 @@ static_library("ui") {
|
|
"//build/config/compiler:wexit_time_destructors",
|
|
]
|
|
|
|
+ if (enable_cef) {
|
|
+ configs += [ "//cef/libcef/features:config" ]
|
|
+ }
|
|
+
|
|
# Since browser and browser_ui actually depend on each other,
|
|
# we must omit the dependency from browser_ui to browser.
|
|
# However, this means browser_ui and browser should more or less
|
|
@@ -391,6 +396,7 @@ static_library("ui") {
|
|
"//build:branding_buildflags",
|
|
"//build:chromeos_buildflags",
|
|
"//cc/paint",
|
|
+ "//cef/libcef/features",
|
|
"//chrome:extra_resources",
|
|
"//chrome:resources",
|
|
"//chrome:strings",
|
|
@@ -5182,6 +5188,7 @@ static_library("ui") {
|
|
if (enable_basic_printing) {
|
|
deps += [
|
|
"//components/printing/browser",
|
|
+ "//components/printing/common:mojo_interfaces",
|
|
"//printing",
|
|
]
|
|
}
|
|
diff --git chrome/browser/ui/webui/net_export_ui.cc chrome/browser/ui/webui/net_export_ui.cc
|
|
index ec205a3f05457..2af432bc6908a 100644
|
|
--- chrome/browser/ui/webui/net_export_ui.cc
|
|
+++ chrome/browser/ui/webui/net_export_ui.cc
|
|
@@ -22,6 +22,7 @@
|
|
#include "base/task/single_thread_task_runner.h"
|
|
#include "base/values.h"
|
|
#include "build/build_config.h"
|
|
+#include "cef/libcef/features/runtime.h"
|
|
#include "chrome/browser/browser_process.h"
|
|
#include "chrome/browser/download/download_prefs.h"
|
|
#include "chrome/browser/net/net_export_helper.h"
|
|
@@ -45,6 +46,10 @@
|
|
#include "net/log/net_log_capture_mode.h"
|
|
#include "ui/shell_dialogs/select_file_dialog.h"
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+#include "cef/libcef/browser/alloy/alloy_dialog_util.h"
|
|
+#endif
|
|
+
|
|
#if defined(OS_ANDROID)
|
|
#include "components/browser_ui/share/android/intent_helper.h"
|
|
#endif
|
|
@@ -142,6 +147,13 @@ class NetExportMessageHandler
|
|
// NetLog file.
|
|
void ShowSelectFileDialog(const base::FilePath& default_path);
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+ void ShowCefSaveAsDialog(content::WebContents* web_contents);
|
|
+ void SaveAsDialogDismissed(
|
|
+ int selected_accept_filter,
|
|
+ const std::vector<base::FilePath>& file_paths);
|
|
+#endif
|
|
+
|
|
// Cached pointer to SystemNetworkContextManager's NetExportFileWriter.
|
|
raw_ptr<net_log::NetExportFileWriter> file_writer_;
|
|
|
|
@@ -235,6 +247,13 @@ void NetExportMessageHandler::OnStartNetLog(const base::ListValue* list) {
|
|
if (UsingMobileUI()) {
|
|
StartNetLog(base::FilePath());
|
|
} else {
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+ if (cef::IsAlloyRuntimeEnabled()) {
|
|
+ ShowCefSaveAsDialog(web_ui()->GetWebContents());
|
|
+ return;
|
|
+ }
|
|
+#endif
|
|
+
|
|
base::FilePath initial_dir = last_save_dir.Pointer()->empty() ?
|
|
DownloadPrefs::FromBrowserContext(
|
|
web_ui()->GetWebContents()->GetBrowserContext())->DownloadPath() :
|
|
@@ -251,6 +270,7 @@ void NetExportMessageHandler::OnStopNetLog(const base::ListValue* list) {
|
|
std::unique_ptr<base::DictionaryValue> ui_thread_polled_data(
|
|
new base::DictionaryValue());
|
|
|
|
+ if (!cef::IsAlloyRuntimeEnabled()) {
|
|
Profile* profile = Profile::FromWebUI(web_ui());
|
|
SetIfNotNull(ui_thread_polled_data.get(), "prerenderInfo",
|
|
chrome_browser_net::GetPrerenderInfo(profile));
|
|
@@ -260,6 +280,7 @@ void NetExportMessageHandler::OnStopNetLog(const base::ListValue* list) {
|
|
SetIfNotNull(ui_thread_polled_data.get(), "serviceProviders",
|
|
chrome_browser_net::GetWindowsServiceProviders());
|
|
#endif
|
|
+ }
|
|
|
|
file_writer_->StopNetLog(std::move(ui_thread_polled_data));
|
|
}
|
|
@@ -375,6 +396,38 @@ void NetExportMessageHandler::ShowSelectFileDialog(
|
|
&file_type_info, 0, base::FilePath::StringType(), owning_window, nullptr);
|
|
}
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+
|
|
+void NetExportMessageHandler::ShowCefSaveAsDialog(
|
|
+ content::WebContents* web_contents) {
|
|
+ base::FilePath initial_dir;
|
|
+ if (!last_save_dir.Pointer()->empty())
|
|
+ initial_dir = *last_save_dir.Pointer();
|
|
+ base::FilePath initial_path =
|
|
+ initial_dir.Append(FILE_PATH_LITERAL("chrome-net-export-log.json"));
|
|
+
|
|
+ blink::mojom::FileChooserParams params;
|
|
+ params.mode = blink::mojom::FileChooserParams::Mode::kSave;
|
|
+ params.default_file_name = initial_path;
|
|
+ params.accept_types.push_back(
|
|
+ alloy::FilePathTypeToString16(initial_path.Extension()));
|
|
+
|
|
+ alloy::RunFileChooser(web_contents, params,
|
|
+ base::BindOnce(&NetExportMessageHandler::SaveAsDialogDismissed,
|
|
+ weak_ptr_factory_.GetWeakPtr()));
|
|
+}
|
|
+
|
|
+void NetExportMessageHandler::SaveAsDialogDismissed(
|
|
+ int selected_accept_filter,
|
|
+ const std::vector<base::FilePath>& file_paths) {
|
|
+ if (file_paths.size() == 1) {
|
|
+ *last_save_dir.Pointer() = file_paths[0].DirName();
|
|
+ StartNetLog(file_paths[0]);
|
|
+ }
|
|
+}
|
|
+
|
|
+#endif // BUILDFLAG(ENABLE_CEF)
|
|
+
|
|
} // namespace
|
|
|
|
NetExportUI::NetExportUI(content::WebUI* web_ui) : WebUIController(web_ui) {
|