mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	Known issues: - Windows ARM64 builds are currently failing due to https://crbug.com/1242884#c31
		
			
				
	
	
		
			146 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			146 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| diff --git chrome/browser/ui/BUILD.gn chrome/browser/ui/BUILD.gn
 | |
| index e5811d45bd4b6..4f532d65e963f 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")
 | |
| @@ -347,6 +348,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
 | |
| @@ -369,6 +374,7 @@ static_library("ui") {
 | |
|      "//build:branding_buildflags",
 | |
|      "//build:chromeos_buildflags",
 | |
|      "//cc/paint",
 | |
| +    "//cef/libcef/features",
 | |
|      "//chrome:extra_resources",
 | |
|      "//chrome:resources",
 | |
|      "//chrome:strings",
 | |
| @@ -4984,6 +4990,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 096f4ca97179d..d2c731625b9d6 100644
 | |
| --- chrome/browser/ui/webui/net_export_ui.cc
 | |
| +++ chrome/browser/ui/webui/net_export_ui.cc
 | |
| @@ -22,6 +22,7 @@
 | |
|  #include "base/strings/utf_string_conversions.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 "chrome/browser/android/intent_helper.h"
 | |
|  #endif
 | |
| @@ -138,6 +143,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.
 | |
|    net_log::NetExportFileWriter* file_writer_;
 | |
|  
 | |
| @@ -233,6 +245,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() :
 | |
| @@ -249,6 +268,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));
 | |
| @@ -258,6 +278,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));
 | |
|  }
 | |
| @@ -374,6 +395,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) {
 |