331 lines
13 KiB
Diff
331 lines
13 KiB
Diff
diff --git chrome/browser/download/download_prefs.cc chrome/browser/download/download_prefs.cc
|
|
index 323534a720c1..72b232f0ed85 100644
|
|
--- chrome/browser/download/download_prefs.cc
|
|
+++ chrome/browser/download/download_prefs.cc
|
|
@@ -22,6 +22,7 @@
|
|
#include "base/strings/sys_string_conversions.h"
|
|
#include "base/strings/utf_string_conversions.h"
|
|
#include "build/build_config.h"
|
|
+#include "cef/libcef/features/features.h"
|
|
#include "chrome/browser/download/chrome_download_manager_delegate.h"
|
|
#include "chrome/browser/download/download_core_service_factory.h"
|
|
#include "chrome/browser/download/download_core_service_impl.h"
|
|
@@ -52,6 +53,10 @@
|
|
#include "chrome/browser/ui/pdf/adobe_reader_info_win.h"
|
|
#endif
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+#include "cef/libcef/browser/browser_context.h"
|
|
+#endif
|
|
+
|
|
using content::BrowserContext;
|
|
using content::BrowserThread;
|
|
using content::DownloadManager;
|
|
@@ -303,7 +308,11 @@ DownloadPrefs* DownloadPrefs::FromDownloadManager(
|
|
// static
|
|
DownloadPrefs* DownloadPrefs::FromBrowserContext(
|
|
content::BrowserContext* context) {
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
return FromDownloadManager(BrowserContext::GetDownloadManager(context));
|
|
+#else
|
|
+ return CefBrowserContext::GetForContext(context)->GetDownloadPrefs();
|
|
+#endif
|
|
}
|
|
|
|
bool DownloadPrefs::IsFromTrustedSource(const download::DownloadItem& item) {
|
|
diff --git chrome/browser/printing/print_preview_dialog_controller.cc chrome/browser/printing/print_preview_dialog_controller.cc
|
|
index c26ddaa9aa12..ad181fdc7478 100644
|
|
--- chrome/browser/printing/print_preview_dialog_controller.cc
|
|
+++ chrome/browser/printing/print_preview_dialog_controller.cc
|
|
@@ -16,6 +16,7 @@
|
|
#include "base/path_service.h"
|
|
#include "base/strings/utf_string_conversions.h"
|
|
#include "build/build_config.h"
|
|
+#include "cef/libcef/features/features.h"
|
|
#include "chrome/browser/browser_process.h"
|
|
#include "chrome/browser/chrome_notification_types.h"
|
|
#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
|
|
@@ -420,8 +421,11 @@ WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog(
|
|
content::HostZoomMap::Get(preview_dialog->GetSiteInstance())
|
|
->SetZoomLevelForHostAndScheme(print_url.scheme(), print_url.host(), 0);
|
|
PrintViewManager::CreateForWebContents(preview_dialog);
|
|
+
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
|
|
preview_dialog);
|
|
+#endif
|
|
|
|
// Add an entry to the map.
|
|
preview_dialog_map_[preview_dialog] = initiator;
|
|
diff --git chrome/browser/resources/print_preview/ui/destination_dialog.html chrome/browser/resources/print_preview/ui/destination_dialog.html
|
|
index 624b32bd370e..69b6134bcc41 100644
|
|
--- chrome/browser/resources/print_preview/ui/destination_dialog.html
|
|
+++ chrome/browser/resources/print_preview/ui/destination_dialog.html
|
|
@@ -180,9 +180,7 @@
|
|
</print-preview-provisional-destination-resolver>
|
|
</div>
|
|
<div slot="button-container">
|
|
- <paper-button on-click="onOpenSettingsPrintPage_">
|
|
- $i18n{manage}
|
|
- </paper-button>
|
|
+ <div></div>
|
|
<paper-button class="cancel-button" on-click="onCancelButtonClick_">
|
|
$i18n{cancel}
|
|
</paper-button>
|
|
diff --git chrome/browser/resources/print_preview/ui/destination_select.html chrome/browser/resources/print_preview/ui/destination_select.html
|
|
index d8369b509661..a0791e34b570 100644
|
|
--- chrome/browser/resources/print_preview/ui/destination_select.html
|
|
+++ chrome/browser/resources/print_preview/ui/destination_select.html
|
|
@@ -47,10 +47,6 @@
|
|
<option value="[[getPdfDestinationKey_()]]" hidden$="[[appKioskMode]]">
|
|
$i18n{printToPDF}
|
|
</option>
|
|
- <option value="[[getGoogleDriveDestinationKey_(activeUser)]]"
|
|
- hidden$="[[!activeUser]]">
|
|
- $i18n{printToGoogleDrive}
|
|
- </option>
|
|
<if expr="chromeos">
|
|
<option value="noDestinations"
|
|
hidden$="[[!noDestinations]]" selected$="[[noDestinations]]">
|
|
diff --git chrome/browser/ui/webui/constrained_web_dialog_ui.cc chrome/browser/ui/webui/constrained_web_dialog_ui.cc
|
|
index 12f77178ea92..470b13bd7879 100644
|
|
--- chrome/browser/ui/webui/constrained_web_dialog_ui.cc
|
|
+++ chrome/browser/ui/webui/constrained_web_dialog_ui.cc
|
|
@@ -27,6 +27,8 @@
|
|
#include "chrome/browser/extensions/tab_helper.h"
|
|
#endif
|
|
|
|
+#include "cef/libcef/features/features.h"
|
|
+
|
|
using content::RenderFrameHost;
|
|
using content::RenderViewHost;
|
|
using content::WebContents;
|
|
@@ -57,8 +59,10 @@ class ConstrainedWebDialogDelegateUserData
|
|
ConstrainedWebDialogUI::ConstrainedWebDialogUI(content::WebUI* web_ui)
|
|
: WebUIController(web_ui) {
|
|
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents());
|
|
#endif
|
|
+#endif
|
|
}
|
|
|
|
ConstrainedWebDialogUI::~ConstrainedWebDialogUI() {
|
|
diff --git chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc
|
|
index e0d6a9034332..250cbeedd842 100644
|
|
--- chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc
|
|
+++ chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc
|
|
@@ -144,8 +144,10 @@ PdfPrinterHandler::PdfPrinterHandler(Profile* profile,
|
|
weak_ptr_factory_(this) {}
|
|
|
|
PdfPrinterHandler::~PdfPrinterHandler() {
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
if (select_file_dialog_.get())
|
|
select_file_dialog_->ListenerDestroyed();
|
|
+#endif
|
|
}
|
|
|
|
void PdfPrinterHandler::Reset() {
|
|
@@ -180,12 +182,14 @@ void PdfPrinterHandler::StartPrint(
|
|
return;
|
|
}
|
|
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
if (select_file_dialog_ &&
|
|
select_file_dialog_->IsRunning(
|
|
platform_util::GetTopLevel(preview_web_contents_->GetNativeView()))) {
|
|
// Dialog is already showing.
|
|
return;
|
|
}
|
|
+#endif
|
|
|
|
DCHECK(!print_callback_);
|
|
print_callback_ = std::move(callback);
|
|
@@ -324,7 +328,11 @@ void PdfPrinterHandler::SelectFile(const base::FilePath& default_filename,
|
|
// If the directory is empty there is no reason to create it or use the
|
|
// default location.
|
|
if (path.empty()) {
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
OnDirectorySelected(default_filename, path);
|
|
+#else
|
|
+ ShowCefSaveAsDialog(initiator, default_filename, path);
|
|
+#endif
|
|
return;
|
|
}
|
|
|
|
@@ -334,8 +342,14 @@ void PdfPrinterHandler::SelectFile(const base::FilePath& default_filename,
|
|
base::PostTaskWithTraitsAndReplyWithResult(
|
|
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
|
|
base::BindOnce(&SelectSaveDirectory, path, default_path),
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
base::BindOnce(&PdfPrinterHandler::OnDirectorySelected,
|
|
weak_ptr_factory_.GetWeakPtr(), default_filename));
|
|
+#else
|
|
+ base::BindOnce(&PdfPrinterHandler::ShowCefSaveAsDialog,
|
|
+ weak_ptr_factory_.GetWeakPtr(), initiator,
|
|
+ default_filename));
|
|
+#endif
|
|
}
|
|
|
|
void PdfPrinterHandler::PostPrintToPdfTask() {
|
|
@@ -351,6 +365,7 @@ void PdfPrinterHandler::OnGotUniqueFileName(const base::FilePath& path) {
|
|
FileSelected(path, 0, nullptr);
|
|
}
|
|
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
void PdfPrinterHandler::OnDirectorySelected(const base::FilePath& filename,
|
|
const base::FilePath& directory) {
|
|
base::FilePath path = directory.Append(filename);
|
|
@@ -375,5 +390,36 @@ void PdfPrinterHandler::OnDirectorySelected(const base::FilePath& filename,
|
|
&file_type_info, 0, base::FilePath::StringType(),
|
|
platform_util::GetTopLevel(preview_web_contents_->GetNativeView()), NULL);
|
|
}
|
|
+#else
|
|
+void PdfPrinterHandler::ShowCefSaveAsDialog(content::WebContents* initiator,
|
|
+ const base::FilePath& filename,
|
|
+ const base::FilePath& directory) {
|
|
+ CefRefPtr<CefBrowserHostImpl> cef_browser =
|
|
+ CefBrowserHostImpl::GetBrowserForContents(initiator);
|
|
+ if (!cef_browser)
|
|
+ return;
|
|
+
|
|
+ base::FilePath path = directory.Append(filename);
|
|
+
|
|
+ CefFileDialogRunner::FileChooserParams params;
|
|
+ params.mode = blink::mojom::FileChooserParams::Mode::kSave;
|
|
+ params.default_file_name = path;
|
|
+ params.accept_types.push_back(CefString(path.Extension()));
|
|
+
|
|
+ cef_browser->RunFileChooser(
|
|
+ params, base::Bind(&PdfPrinterHandler::SaveAsDialogDismissed,
|
|
+ weak_ptr_factory_.GetWeakPtr()));
|
|
+}
|
|
+
|
|
+void PdfPrinterHandler::SaveAsDialogDismissed(
|
|
+ int selected_accept_filter,
|
|
+ const std::vector<base::FilePath>& file_paths) {
|
|
+ if (file_paths.size() == 1) {
|
|
+ FileSelected(file_paths[0], 0, nullptr);
|
|
+ } else {
|
|
+ FileSelectionCanceled(nullptr);
|
|
+ }
|
|
+}
|
|
+#endif
|
|
|
|
} // namespace printing
|
|
diff --git chrome/browser/ui/webui/print_preview/pdf_printer_handler.h chrome/browser/ui/webui/print_preview/pdf_printer_handler.h
|
|
index eae9098f2136..1a4c4419e736 100644
|
|
--- chrome/browser/ui/webui/print_preview/pdf_printer_handler.h
|
|
+++ chrome/browser/ui/webui/print_preview/pdf_printer_handler.h
|
|
@@ -11,9 +11,14 @@
|
|
#include "base/memory/ref_counted.h"
|
|
#include "base/memory/weak_ptr.h"
|
|
#include "base/strings/string16.h"
|
|
+#include "cef/libcef/features/features.h"
|
|
#include "chrome/browser/ui/webui/print_preview/printer_handler.h"
|
|
#include "ui/shell_dialogs/select_file_dialog.h"
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+#include "cef/libcef/browser/browser_host_impl.h"
|
|
+#endif
|
|
+
|
|
namespace base {
|
|
class FilePath;
|
|
class RefCountedMemory;
|
|
@@ -78,17 +83,28 @@ class PdfPrinterHandler : public PrinterHandler,
|
|
// The print preview web contents. Protected so unit tests can access it.
|
|
content::WebContents* const preview_web_contents_;
|
|
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
// The underlying dialog object. Protected so unit tests can access it.
|
|
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
|
|
+#endif
|
|
|
|
private:
|
|
void PostPrintToPdfTask();
|
|
void OnGotUniqueFileName(const base::FilePath& path);
|
|
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
// Prompts the user to save the file. The dialog will default to saving
|
|
// the file with name |filename| in |directory|.
|
|
void OnDirectorySelected(const base::FilePath& filename,
|
|
const base::FilePath& directory);
|
|
+#else
|
|
+ void ShowCefSaveAsDialog(content::WebContents* initiator,
|
|
+ const base::FilePath& filename,
|
|
+ const base::FilePath& directory);
|
|
+
|
|
+ void SaveAsDialogDismissed(int selected_accept_filter,
|
|
+ const std::vector<base::FilePath>& file_paths);
|
|
+#endif
|
|
|
|
Profile* const profile_;
|
|
StickySettings* const sticky_settings_;
|
|
diff --git chrome/browser/ui/webui/print_preview/print_preview_handler.cc chrome/browser/ui/webui/print_preview/print_preview_handler.cc
|
|
index 47528eaccd78..2ecd9e3d5c03 100644
|
|
--- chrome/browser/ui/webui/print_preview/print_preview_handler.cc
|
|
+++ chrome/browser/ui/webui/print_preview/print_preview_handler.cc
|
|
@@ -26,6 +26,7 @@
|
|
#include "base/metrics/histogram_macros.h"
|
|
#include "base/values.h"
|
|
#include "build/build_config.h"
|
|
+#include "cef/libcef/features/features.h"
|
|
#include "chrome/browser/app_mode/app_mode_utils.h"
|
|
#include "chrome/browser/bad_message.h"
|
|
#include "chrome/browser/browser_process.h"
|
|
@@ -1243,6 +1244,9 @@ PrinterHandler* PrintPreviewHandler::GetPrinterHandler(
|
|
}
|
|
return privet_printer_handler_.get();
|
|
}
|
|
+#else // !BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
|
|
+ if (printer_type == PrinterType::kPrivetPrinter)
|
|
+ return nullptr;
|
|
#endif
|
|
if (printer_type == PrinterType::kPdfPrinter) {
|
|
if (!pdf_printer_handler_) {
|
|
@@ -1325,6 +1329,7 @@ void PrintPreviewHandler::OnPrintResult(const std::string& callback_id,
|
|
}
|
|
|
|
void PrintPreviewHandler::RegisterForGaiaCookieChanges() {
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
DCHECK(!identity_manager_);
|
|
cloud_print_enabled_ =
|
|
GetPrefs()->GetBoolean(prefs::kCloudPrintSubmitEnabled);
|
|
@@ -1340,6 +1345,7 @@ void PrintPreviewHandler::RegisterForGaiaCookieChanges() {
|
|
|
|
identity_manager_ = IdentityManagerFactory::GetForProfile(profile);
|
|
identity_manager_->AddObserver(this);
|
|
+#endif
|
|
}
|
|
|
|
void PrintPreviewHandler::UnregisterForGaiaCookieChanges() {
|
|
diff --git chrome/browser/ui/webui/print_preview/print_preview_ui.cc chrome/browser/ui/webui/print_preview/print_preview_ui.cc
|
|
index f90198efcf2a..d866bf90c13a 100644
|
|
--- chrome/browser/ui/webui/print_preview/print_preview_ui.cc
|
|
+++ chrome/browser/ui/webui/print_preview/print_preview_ui.cc
|
|
@@ -25,6 +25,7 @@
|
|
#include "base/synchronization/lock.h"
|
|
#include "base/values.h"
|
|
#include "build/build_config.h"
|
|
+#include "cef/libcef/features/features.h"
|
|
#include "chrome/browser/browser_process.h"
|
|
#include "chrome/browser/printing/background_printing_manager.h"
|
|
#include "chrome/browser/printing/print_preview_data_service.h"
|
|
@@ -73,12 +74,16 @@ namespace printing {
|
|
|
|
namespace {
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+const char kBasicPrintShortcut[] = "";
|
|
+#else
|
|
#if defined(OS_MACOSX)
|
|
// U+0028 U+21E7 U+2318 U+0050 U+0029 in UTF8
|
|
const char kBasicPrintShortcut[] = "\x28\xE2\x8c\xA5\xE2\x8C\x98\x50\x29";
|
|
#elif !defined(OS_CHROMEOS)
|
|
const char kBasicPrintShortcut[] = "(Ctrl+Shift+P)";
|
|
#endif
|
|
+#endif
|
|
|
|
PrintPreviewUI::TestDelegate* g_test_delegate = nullptr;
|
|
|