0

Move printing defines to buildflag system.

Removes the build flags in //build/config/features.gni and puts them in a new
file //printing/features/features.gni. A "features" target in that directory
converts these to a BUILDFLAG header. Update users of define to use the new
include, and check BUILDFLAG(...) instead of defined(...).

One define about printing is removed from Blink. This function seems only to
be called by the embedder, and printing code is compiled into Blink either
way. The define seems to not be doing much. if the embedder doesn't want to
print, they should not call the print function.

There is a custom hack for the .rc file due to resource compiler preprocessor limitations.

R=dbeam@chromium.org, dcheng@chromium.org, thestig@chromium.org, thestig, dcheng (third_party/WebKit)
TBR=dbeam (webui), jschuh (ipc messages)

Review URL: https://codereview.chromium.org/2458833005 .

Cr-Commit-Position: refs/heads/master@{#429707}
This commit is contained in:
Brett Wilson
2016-11-03 15:06:12 -07:00
parent 6d9437bcdf
commit 65f951ca1d
116 changed files with 505 additions and 362 deletions
build/config
chrome
BUILD.gn
app
browser
common
renderer
service
test
utility
components
content
printing
skia
third_party/WebKit/Source/web
tools/grit

@ -71,25 +71,6 @@ config("feature_flags") {
if (enable_pdf) {
defines += [ "ENABLE_PDF=1" ]
}
if (enable_basic_printing || enable_print_preview) {
# Convenience define for ENABLE_BASIC_PRINTING || ENABLE_PRINT_PREVIEW.
defines += [ "ENABLE_PRINTING=1" ]
if (enable_basic_printing) {
# Enable basic printing support and UI.
defines += [ "ENABLE_BASIC_PRINTING=1" ]
}
if (enable_print_preview) {
# Enable printing with print preview.
# Can be defined without ENABLE_BASIC_PRINTING.
defines += [ "ENABLE_PRINT_PREVIEW=1" ]
}
if ((enable_basic_printing && is_win) || enable_print_preview) {
# Windows basic printing or print preview requires pdf enabled.
assert(enable_pdf,
"Windows basic printing or print preview needs pdf: " +
"set enable_pdf=true.")
}
}
if (enable_spellcheck) {
defines += [ "ENABLE_SPELLCHECK=1" ]
}

@ -61,8 +61,6 @@ declare_args() {
# Note: this setting is ignored if is_chrome_branded.
fieldtrial_testing_like_official_build = is_chrome_branded
use_cups = (is_desktop_linux || is_mac) && !is_chromecast
# Enables Wi-Fi Display functionality
# WARNING: This enables MPEG Transport Stream (MPEG-TS) encoding!
enable_wifi_display = false
@ -78,13 +76,6 @@ declare_args() {
use_gio = is_linux && !is_chromeos && !is_chromecast
# Enable basic printing support and UI.
enable_basic_printing = !is_chromecast && !is_ios
# Enable printing with print preview. It does not imply
# enable_basic_printing. It's possible to build Chrome with preview only.
enable_print_preview = !is_android && !is_chromecast && !is_ios
# Whether or not to use external popup menu.
use_external_popup_menu = is_android || is_mac

@ -125,6 +125,7 @@ if (!is_android && !is_mac) {
public_deps = []
deps = [
"//build/config/sanitizers:deps",
"//printing/features",
]
data = [

@ -4,6 +4,7 @@
import("//build/config/ui.gni")
import("//chrome/common/features.gni")
import("//printing/features/features.gni")
import("//services/service_manager/public/service_manifest.gni")
import("//tools/grit/grit_rule.gni")
@ -24,6 +25,15 @@ source_set("chrome_dll_resources") {
]
if (is_win) {
sources += [ "chrome_dll.rc" ]
if (enable_basic_printing) {
# The resource compiler can only handle macro functions up to 31 chars
# which the buildflag system produces for this. Make a define so we can
# toggle off of the enable-basic-printing flag in the .rc file.
defines = [ "ENABLE_BASIC_PRINTING_FOR_RC" ]
}
deps = [
"//printing/features",
]
}
}
@ -307,6 +317,7 @@ static_library("test_support") {
"//components/startup_metric_utils/browser:lib",
"//content/public/app:both",
"//content/public/common",
"//printing/features",
"//ui/base",
]

@ -33,9 +33,12 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// pick those up in the WM_APPCOMMAND message.
IDR_MAINFRAME ACCELERATORS
BEGIN
#if defined(ENABLE_BASIC_PRINTING)
// This really should be using the buildflag but the resource compiler fails on
// macro functions longer than 31 chars which this command produces. The BUILD
// sets this regular define for this target only for this line to consume.
#ifdef ENABLE_BASIC_PRINTING_FOR_RC // #if BUILDFLAG(ENABLE_BASIC_PRINTING)
"P", IDC_BASIC_PRINT, VIRTKEY, CONTROL, SHIFT
#endif // ENABLE_BASIC_PRINTING
#endif // ENABLE_BASIC_PRINTING_FOR_RC
VK_LEFT, IDC_BACK, VIRTKEY, ALT
VK_BACK, IDC_BACK, VIRTKEY
"D", IDC_BOOKMARK_PAGE, VIRTKEY, CONTROL

@ -51,6 +51,7 @@
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
#include "extensions/common/constants.h"
#include "printing/features/features.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h"
@ -910,7 +911,7 @@ int ChromeMainDelegate::RunProcess(
// doesn't support empty array. So we comment out the block for Android.
#if !defined(OS_ANDROID)
static const MainFunction kMainFunctions[] = {
#if defined(ENABLE_PRINT_PREVIEW) && !defined(CHROME_MULTIPLE_DLL_CHILD)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(CHROME_MULTIPLE_DLL_CHILD)
{ switches::kServiceProcess, ServiceProcessMain },
#endif

@ -12,6 +12,7 @@ import("//components/os_crypt/features.gni")
import("//media/media_options.gni")
import("//net/features.gni")
import("//ppapi/features/features.gni")
import("//printing/features/features.gni")
import("//third_party/protobuf/proto_library.gni")
# //build/config/android/rules.gni imports //tools/grit/grit_rule.gni, which
@ -1440,6 +1441,7 @@ split_static_library("browser") {
"//mojo/public/js",
"//net:extras",
"//net:net_with_v8",
"//printing/features",
"//services/service_manager/public/cpp",
"//skia",
"//sql",

@ -72,6 +72,7 @@
#include "media/audio/audio_features.h"
#include "media/base/media_switches.h"
#include "media/midi/midi_switches.h"
#include "printing/features/features.h"
#include "ui/base/ui_base_switches.h"
#include "ui/compositor/compositor_switches.h"
#include "ui/display/display_switches.h"
@ -2074,7 +2075,7 @@ const FeatureEntry kFeatureEntries[] = {
FEATURE_VALUE_TYPE(
features::kDisplayPersistenceToggleInPermissionPrompts)},
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
{"print-scaling", IDS_FLAGS_PRINT_SCALING_NAME,
IDS_FLAGS_PRINT_SCALING_DESCRIPTION, kOsDesktop,
FEATURE_VALUE_TYPE(features::kPrintScaling)},

@ -173,8 +173,9 @@
#include "components/url_formatter/android/component_jni_registrar.h"
#include "components/variations/android/component_jni_registrar.h"
#include "components/web_contents_delegate_android/component_jni_registrar.h"
#include "printing/features/features.h"
#if defined(ENABLE_PRINTING) && !defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINTING) && !BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "printing/printing_context_android.h"
#endif
@ -406,7 +407,7 @@ static base::android::RegistrationMethod kChromeRegisteredMethods[] = {
{"WebsitePreferenceBridge", RegisterWebsitePreferenceBridge},
{"WebsiteSettingsPopupAndroid",
WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid},
#if defined(ENABLE_PRINTING) && !defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINTING) && !BUILDFLAG(ENABLE_PRINT_PREVIEW)
{"PrintingContext",
printing::PrintingContextAndroid::RegisterPrintingContext},
#endif

@ -56,6 +56,7 @@
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/result_catcher.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "printing/features/features.h"
#include "ui/base/window_open_disposition.h"
#include "url/gurl.h"
@ -119,7 +120,7 @@ class TabsAddedNotificationObserver
DISALLOW_COPY_AND_ASSIGN(TabsAddedNotificationObserver);
};
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
class ScopedPreviewTestingDelegate : PrintPreviewUI::TestingDelegate {
public:
explicit ScopedPreviewTestingDelegate(bool auto_cancel)
@ -1139,7 +1140,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DISABLED_WebContentsHasFocus) {
->HasFocus());
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX)
#define MAYBE_WindowDotPrintShouldBringUpPrintPreview \

@ -119,6 +119,7 @@
#include "extensions/common/constants.h"
#include "net/socket/client_socket_pool_manager.h"
#include "net/url_request/url_request_context_getter.h"
#include "printing/features/features.h"
#include "ui/base/idle/idle.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/message_center/message_center.h"
@ -214,7 +215,7 @@ BrowserProcessImpl::BrowserProcessImpl(
g_browser_process = this;
platform_part_.reset(new BrowserProcessPlatformPart());
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
// Must be created after the NotificationService.
print_job_manager_.reset(new printing::PrintJobManager);
#endif
@ -677,7 +678,7 @@ printing::PrintJobManager* BrowserProcessImpl::print_job_manager() {
printing::PrintPreviewDialogController*
BrowserProcessImpl::print_preview_dialog_controller() {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
DCHECK(CalledOnValidThread());
if (!print_preview_dialog_controller_.get())
CreatePrintPreviewDialogController();
@ -690,7 +691,7 @@ printing::PrintPreviewDialogController*
printing::BackgroundPrintingManager*
BrowserProcessImpl::background_printing_manager() {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
DCHECK(CalledOnValidThread());
if (!background_printing_manager_.get())
CreateBackgroundPrintingManager();
@ -1158,7 +1159,7 @@ void BrowserProcessImpl::CreateStatusTray() {
}
void BrowserProcessImpl::CreatePrintPreviewDialogController() {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
DCHECK(!print_preview_dialog_controller_);
print_preview_dialog_controller_ =
new printing::PrintPreviewDialogController();
@ -1168,7 +1169,7 @@ void BrowserProcessImpl::CreatePrintPreviewDialogController() {
}
void BrowserProcessImpl::CreateBackgroundPrintingManager() {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
DCHECK(!background_printing_manager_);
background_printing_manager_.reset(new printing::BackgroundPrintingManager());
#else
@ -1312,7 +1313,7 @@ void BrowserProcessImpl::Unpin() {
release_last_reference_callstack_ = base::debug::StackTrace();
shutting_down_ = true;
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
// Wait for the pending print jobs to finish. Don't do this later, since
// this might cause a nested message loop to run, and we don't want pending
// tasks to run once teardown has started.

@ -25,6 +25,7 @@
#include "chrome/browser/lifetime/keep_alive_state_observer.h"
#include "chrome/common/features.h"
#include "components/prefs/pref_change_registrar.h"
#include "printing/features/features.h"
class ChromeChildProcessWatcher;
class ChromeDeviceClient;
@ -232,7 +233,7 @@ class BrowserProcessImpl : public BrowserProcess,
std::unique_ptr<DevToolsAutoOpener> devtools_auto_opener_;
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
scoped_refptr<printing::PrintPreviewDialogController>
print_preview_dialog_controller_;

@ -38,6 +38,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/tracing_controller.h"
#include "printing/features/features.h"
#if defined(OS_WIN)
#include "chrome/browser/first_run/upgrade_util_win.h"
@ -60,7 +61,7 @@
#include "chrome/browser/chromeos/boot_times_recorder.h"
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/service_process/service_process_control.h"
#endif
@ -154,7 +155,7 @@ bool ShutdownPreThreadsStop() {
chromeos::BootTimesRecorder::Get()->AddLogoutTimeMarker(
"BrowserShutdownStarted", false);
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Shutdown the IPC channel to the service processes.
ServiceProcessControl::GetInstance()->Disconnect();
#endif // ENABLE_PRINT_PREVIEW

@ -167,6 +167,7 @@
#include "net/http/http_network_layer.h"
#include "net/http/http_stream_factory.h"
#include "net/url_request/url_request.h"
#include "printing/features/features.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/layout.h"
#include "ui/base/material_design/material_design_controller.h"
@ -244,9 +245,9 @@
#include "extensions/components/javascript_dialog_extensions_client/javascript_dialog_extension_client_impl.h"
#endif // defined(ENABLE_EXTENSIONS)
#if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
#include "printing/printed_document.h"
#endif // defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
#if defined(ENABLE_RLZ)
#include "chrome/browser/rlz/chrome_rlz_tracker_delegate.h"
@ -1774,13 +1775,13 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// needs to read prefs that get set after that runs.
browser_process_->intranet_redirect_detector();
#if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
if (parsed_command_line().HasSwitch(switches::kDebugPrint)) {
base::FilePath path =
parsed_command_line().GetSwitchValuePath(switches::kDebugPrint);
printing::PrintedDocument::set_debug_dump_path(path);
}
#endif // defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
HandleTestParameters(parsed_command_line());
browser_process_->metrics_service()->RecordBreakpadHasDebugger(
@ -1807,7 +1808,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
browser_process_->metrics_service()->LogNeedForCleanShutdown();
#endif // !defined(OS_ANDROID)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Create the instance of the cloud print proxy service so that it can launch
// the service process if needed. This is needed because the service process
// might have shutdown because an update was available.
@ -1815,7 +1816,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext()
// instead?
CloudPrintProxyServiceFactory::GetForProfile(profile_);
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Start watching all browser threads for responsiveness.
metrics::MetricsService::SetExecutionPhase(

@ -182,6 +182,7 @@
#include "net/cookies/cookie_options.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "ppapi/host/ppapi_host.h"
#include "printing/features/features.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "services/service_manager/public/cpp/service.h"
#include "storage/browser/fileapi/external_mount_points.h"
@ -1026,7 +1027,7 @@ void ChromeContentBrowserClient::RenderProcessWillLaunch(
#if defined(ENABLE_EXTENSIONS)
host->AddFilter(new cast::CastTransportHostFilter);
#endif
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
host->AddFilter(new printing::PrintingMessageFilter(id, profile));
#endif
#if defined(ENABLE_SPELLCHECK)

@ -5,6 +5,7 @@
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//media/media_options.gni")
import("//printing/features/features.gni")
import("//third_party/protobuf/proto_library.gni")
assert(is_chromeos)

@ -888,6 +888,7 @@ static_library("extensions") {
"//extensions/common/api",
"//extensions/strings",
"//net",
"//printing/features",
"//skia",
"//sql",
"//storage/browser",

@ -32,19 +32,20 @@
#include "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_delegate.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
#include "printing/features/features.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.h"
#endif
#if defined(ENABLE_PRINTING)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_preview_message_handler.h"
#include "chrome/browser/printing/print_view_manager.h"
#else
#include "chrome/browser/printing/print_view_manager_basic.h"
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // defined(ENABLE_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINTING)
namespace extensions {
@ -70,14 +71,14 @@ void ChromeExtensionsAPIClient::AddAdditionalValueStoreCaches(
void ChromeExtensionsAPIClient::AttachWebContentsHelpers(
content::WebContents* web_contents) const {
favicon::CreateContentFaviconDriverForWebContents(web_contents);
#if defined(ENABLE_PRINTING)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
printing::PrintViewManager::CreateForWebContents(web_contents);
printing::PrintPreviewMessageHandler::CreateForWebContents(web_contents);
#else
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // defined(ENABLE_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINTING)
pdf::PDFWebContentsHelper::CreateForWebContentsWithClient(
web_contents, std::unique_ptr<pdf::PDFWebContentsHelperClient>(
new ChromePDFWebContentsHelperClient()));

@ -13,12 +13,13 @@
#include "chrome/common/extensions/api/cloud_print_private.h"
#include "google_apis/google_api_keys.h"
#include "net/base/network_interfaces.h"
#include "printing/features/features.h"
namespace extensions {
namespace {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
const char kErrorIncognito[] = "Cannot access in incognito mode";
#endif
@ -47,7 +48,7 @@ CloudPrintPrivateSetupConnectorFunction::
}
bool CloudPrintPrivateSetupConnectorFunction::RunAsync() {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
using api::cloud_print_private::SetupConnector::Params;
std::unique_ptr<Params> params(Params::Create(*args_));
if (CloudPrintTestsDelegate::Get()) {
@ -101,7 +102,7 @@ void CloudPrintPrivateGetPrintersFunction::SendResults(
}
bool CloudPrintPrivateGetPrintersFunction::RunAsync() {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (CloudPrintTestsDelegate::Get()) {
SendResults(CloudPrintTestsDelegate::Get()->GetPrinters());
} else {

@ -13,6 +13,7 @@
#include "chrome/common/features.h"
#include "chrome/grit/browser_resources.h"
#include "extensions/common/constants.h"
#include "printing/features/features.h"
#if BUILDFLAG(ENABLE_APP_LIST) && defined(OS_CHROMEOS)
#include "chrome/browser/ui/app_list/google_now_extension.h"
@ -75,7 +76,7 @@ bool IsComponentExtensionWhitelisted(int manifest_resource_id) {
#if BUILDFLAG(ENABLE_APP_LIST)
case IDR_CHROME_APP_MANIFEST:
#endif
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
case IDR_CLOUDPRINT_MANIFEST:
#endif
case IDR_CRYPTOTOKEN_MANIFEST:

@ -40,6 +40,7 @@
#include "extensions/common/extension_l10n_util.h"
#include "extensions/common/file_util.h"
#include "extensions/common/manifest_constants.h"
#include "printing/features/features.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@ -487,11 +488,11 @@ void ComponentLoader::AddDefaultComponentExtensions(
Add(IDR_BOOKMARKS_MANIFEST,
base::FilePath(FILE_PATH_LITERAL("bookmark_manager")));
}
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
// Cloud Print component app. Not required on Chrome OS.
Add(IDR_CLOUDPRINT_MANIFEST,
base::FilePath(FILE_PATH_LITERAL("cloud_print")));
#endif // defined(ENABLE_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINTING)
#endif // defined(OS_CHROMEOS)
if (!skip_session_components) {

@ -72,13 +72,14 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/histogram_fetcher.h"
#include "content/public/browser/notification_service.h"
#include "printing/features/features.h"
#if BUILDFLAG(ANDROID_JAVA_UI)
#include "chrome/browser/metrics/android_metrics_provider.h"
#include "chrome/browser/metrics/page_load_metrics_provider.h"
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/service_process/service_process_control.h"
#endif
@ -762,7 +763,7 @@ void ChromeMetricsServiceClient::OnMemoryDetailCollectionDone() {
DCHECK_EQ(num_async_histogram_fetches_in_progress_, 0);
#if !defined(ENABLE_PRINT_PREVIEW)
#if !BUILDFLAG(ENABLE_PRINT_PREVIEW)
num_async_histogram_fetches_in_progress_ = 2;
#else // !ENABLE_PRINT_PREVIEW
num_async_histogram_fetches_in_progress_ = 3;

@ -107,6 +107,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "net/http/http_server_properties_manager.h"
#include "printing/features/features.h"
#if BUILDFLAG(ENABLE_APP_LIST)
#include "chrome/browser/apps/drive/drive_app_mapping.h"
@ -537,7 +538,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
PluginsUI::RegisterProfilePrefs(registry);
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
printing::StickySettings::RegisterProfilePrefs(registry);
#endif

@ -24,9 +24,10 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/cloud_print/cloud_print_constants.h"
#include "net/base/url_util.h"
#include "printing/features/features.h"
#include "url/gurl.h"
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/pwg_raster_converter.h"
#include "components/cloud_devices/common/printer_description.h"
#include "printing/pdf_render_settings.h"
@ -44,7 +45,7 @@ const char kPrivetRegisterUserArgName[] = "user";
const int kPrivetCancelationTimeoutSeconds = 3;
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
const char kPrivetURLKeyUserName[] = "user_name";
const char kPrivetURLKeyClientName[] = "client_name";
const char kPrivetURLKeyJobname[] = "job_name";
@ -394,7 +395,7 @@ void PrivetJSONOperationImpl::OnNeedPrivetToken(
privet_client_->RefreshPrivetToken(callback);
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
PrivetLocalPrintOperationImpl::PrivetLocalPrintOperationImpl(
PrivetHTTPClient* privet_client,
PrivetLocalPrintOperation::Delegate* delegate)
@ -797,7 +798,7 @@ PrivetV1HTTPClientImpl::CreateCapabilitiesOperation(
std::unique_ptr<PrivetLocalPrintOperation>
PrivetV1HTTPClientImpl::CreateLocalPrintOperation(
PrivetLocalPrintOperation::Delegate* delegate) {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
return std::unique_ptr<PrivetLocalPrintOperation>(
new PrivetLocalPrintOperationImpl(info_client(), delegate));
#else

@ -16,6 +16,7 @@
#include "base/memory/weak_ptr.h"
#include "chrome/browser/printing/cloud_print/privet_http.h"
#include "components/cloud_devices/common/cloud_device_description.h"
#include "printing/features/features.h"
#include "ui/gfx/geometry/size.h"
namespace cloud_print {
@ -148,7 +149,7 @@ class PrivetJSONOperationImpl : public PrivetJSONOperation,
std::unique_ptr<PrivetURLFetcher> url_fetcher_;
};
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
class PrivetLocalPrintOperationImpl
: public PrivetLocalPrintOperation,
public PrivetURLFetcher::Delegate {

@ -20,10 +20,11 @@
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_request_test_util.h"
#include "printing/features/features.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/pwg_raster_converter.h"
#include "printing/pwg_raster_settings.h"
#endif // ENABLE_PRINT_PREVIEW
@ -138,7 +139,7 @@ const char kSampleCapabilitiesResponse[] = "{"
"}"
"}";
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
const char kSampleInfoResponseWithCreatejob[] = "{"
" \"version\": \"1.0\","
" \"name\": \"Common printer\","
@ -733,7 +734,7 @@ TEST_P(PrivetCapabilitiesTest, BadToken) {
kSampleCapabilitiesResponse));
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// A note on PWG raster conversion: The PWG raster converter used simply
// converts strings to file paths based on them by appending "test.pdf", since
// it's easier to test that way. Instead of using a mock, we simply check if the

@ -19,6 +19,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/webplugininfo.h"
#include "printing/features/features.h"
using content::BrowserThread;
@ -66,7 +67,7 @@ PrintViewManager::~PrintViewManager() {
DCHECK_EQ(NOT_PREVIEWING, print_preview_state_);
}
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
bool PrintViewManager::PrintForSystemDialogNow(
const base::Closure& dialog_shown_callback) {
DCHECK(!dialog_shown_callback.is_null());
@ -94,7 +95,7 @@ bool PrintViewManager::BasicPrint() {
print_preview_ui->OnShowSystemDialog();
return true;
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
bool PrintViewManager::PrintPreviewNow(bool selection_only) {
// Users can send print commands all they want and it is beyond

@ -8,6 +8,7 @@
#include "base/macros.h"
#include "chrome/browser/printing/print_view_manager_base.h"
#include "content/public/browser/web_contents_user_data.h"
#include "printing/features/features.h"
namespace content {
class RenderProcessHost;
@ -21,7 +22,7 @@ class PrintViewManager : public PrintViewManagerBase,
public:
~PrintViewManager() override;
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// Same as PrintNow(), but for the case where a user prints with the system
// dialog from print preview.
// |dialog_shown_callback| is called when the print dialog is shown.

@ -34,11 +34,12 @@
#include "content/public/browser/notification_source.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "printing/features/features.h"
#include "printing/pdf_metafile_skia.h"
#include "printing/printed_document.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_error_dialog.h"
#endif
@ -90,7 +91,7 @@ PrintViewManagerBase::~PrintViewManagerBase() {
DisconnectFromCurrentPrintJob();
}
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
bool PrintViewManagerBase::PrintNow() {
return PrintNowInternal(new PrintMsg_PrintPages(routing_id()));
}
@ -215,7 +216,7 @@ void PrintViewManagerBase::OnDidPrintPage(
void PrintViewManagerBase::OnPrintingFailed(int cookie) {
PrintManager::OnPrintingFailed(cookie);
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
chrome::ShowPrintErrorDialog();
#endif

@ -13,6 +13,7 @@
#include "components/printing/browser/print_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "printing/features/features.h"
#include "printing/printed_pages_source.h"
struct PrintHostMsg_DidPrintPage_Params;
@ -32,7 +33,7 @@ class PrintViewManagerBase : public content::NotificationObserver,
public:
~PrintViewManagerBase() override;
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// Prints the current document immediately. Since the rendering is
// asynchronous, the actual printing will not be completed on the return of
// this function. Returns false if printing is impossible at the moment.

@ -4,16 +4,18 @@
#include "chrome/browser/printing/print_view_manager_common.h"
#include "printing/features/features.h"
#if defined(ENABLE_EXTENSIONS)
#include "components/guest_view/browser/guest_view_manager.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
#endif // defined(ENABLE_EXTENSIONS)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_view_manager.h"
#else
#include "chrome/browser/printing/print_view_manager_basic.h"
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
namespace printing {
namespace {
@ -53,31 +55,31 @@ content::WebContents* GetWebContentsToUse(content::WebContents* contents) {
void StartPrint(content::WebContents* contents,
bool print_preview_disabled,
bool selection_only) {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
using PrintViewManagerImpl = PrintViewManager;
#else
using PrintViewManagerImpl = PrintViewManagerBasic;
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
auto* print_view_manager =
PrintViewManagerImpl::FromWebContents(GetWebContentsToUse(contents));
if (!print_view_manager)
return;
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (!print_preview_disabled) {
print_view_manager->PrintPreviewNow(selection_only);
return;
}
#endif // ENABLE_PRINT_PREVIEW
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
print_view_manager->PrintNow();
#endif // ENABLE_BASIC_PRINTING
}
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
void StartBasicPrint(content::WebContents* contents) {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
PrintViewManager* print_view_manager =
PrintViewManager::FromWebContents(GetWebContentsToUse(contents));
if (!print_view_manager)

@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_COMMON_H_
#define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_COMMON_H_
#include "printing/features/features.h"
namespace content {
class WebContents;
}
@ -16,7 +18,7 @@ void StartPrint(content::WebContents* web_contents,
bool print_preview_disabled,
bool selection_only);
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// Start printing using the system print dialog.
void StartBasicPrint(content::WebContents* contents);
#endif

@ -21,8 +21,9 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/child_process_host.h"
#include "printing/features/features.h"
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
#endif
@ -98,7 +99,7 @@ bool PrintingMessageFilter::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_ScriptedPrint, OnScriptedPrint)
IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_UpdatePrintSettings,
OnUpdatePrintSettings)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
IPC_MESSAGE_HANDLER(PrintHostMsg_CheckForCancel, OnCheckForCancel)
#endif
IPC_MESSAGE_UNHANDLED(handled = false)
@ -305,7 +306,7 @@ void PrintingMessageFilter::OnUpdatePrintSettingsReply(
}
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintingMessageFilter::OnCheckForCancel(int32_t preview_ui_id,
int preview_request_id,
bool* cancel) {

@ -15,6 +15,7 @@
#include "build/build_config.h"
#include "components/prefs/pref_member.h"
#include "content/public/browser/browser_message_filter.h"
#include "printing/features/features.h"
#if defined(OS_WIN)
#include "base/memory/shared_memory.h"
@ -99,7 +100,7 @@ class PrintingMessageFilter : public content::BrowserMessageFilter {
void OnUpdatePrintSettingsReply(scoped_refptr<PrinterQuery> printer_query,
IPC::Message* reply_msg);
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Check to see if print preview has been cancelled.
void OnCheckForCancel(int32_t preview_ui_id,
int preview_request_id,

@ -70,6 +70,7 @@
#include "chrome/browser/undo/bookmark_undo_service_factory.h"
#include "chrome/browser/web_data_service_factory.h"
#include "chrome/common/features.h"
#include "printing/features/features.h"
#if defined(ENABLE_EXTENSIONS)
#include "apps/browser_context_keyed_service_factories.h"
@ -203,7 +204,7 @@ EnsureBrowserContextKeyedServiceFactoriesBuilt() {
chrome::android::DataUseUITabModelFactory::GetInstance();
#endif
UINetworkQualityEstimatorServiceFactory::GetInstance();
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
CloudPrintProxyServiceFactory::GetInstance();
#endif
CookieSettingsFactory::GetInstance();

@ -114,6 +114,7 @@
#include "content/public/browser/user_metrics.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/page_zoom.h"
#include "printing/features/features.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_CHROMEOS)
@ -377,7 +378,7 @@ void ProfileImpl::RegisterProfilePrefs(
registry->RegisterStringPref(prefs::kHomePage,
std::string(),
home_page_flags);
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
registry->RegisterBooleanPref(prefs::kPrintingEnabled, true);
#endif
registry->RegisterBooleanPref(prefs::kPrintPreviewDisabled, false);

@ -105,6 +105,7 @@
#include "content/public/common/menu_item.h"
#include "content/public/common/url_utils.h"
#include "net/base/escape.h"
#include "printing/features/features.h"
#include "third_party/WebKit/public/public_features.h"
#include "third_party/WebKit/public/web/WebContextMenuData.h"
#include "third_party/WebKit/public/web/WebMediaPlayerAction.h"
@ -134,15 +135,15 @@
#include "extensions/common/extension.h"
#endif
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
#include "chrome/browser/printing/print_view_manager_common.h"
#include "components/printing/common/print_messages.h"
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_preview_context_menu_observer.h"
#include "chrome/browser/printing/print_preview_dialog_controller.h"
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // defined(ENABLE_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINTING)
#if defined(ENABLE_MEDIA_ROUTER)
#include "chrome/browser/media/router/media_router_dialog_controller.h"
@ -915,7 +916,7 @@ void RenderViewContextMenu::HandleAuthorizeAllPlugins() {
#endif
void RenderViewContextMenu::AppendPrintPreviewItems() {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (!print_preview_menu_observer_.get()) {
print_preview_menu_observer_.reset(
new PrintPreviewContextMenuObserver(source_web_contents_));
@ -2080,7 +2081,7 @@ bool RenderViewContextMenu::IsSaveAsEnabled() const {
bool can_save =
(params_.media_flags & WebContextMenuData::MediaCanSave) &&
url.is_valid() && ProfileIOData::IsHandledProtocol(url.scheme());
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Do not save the preview PDF on the print preview page.
can_save = can_save &&
!(printing::PrintPreviewDialogController::IsPrintPreviewURL(url));
@ -2403,7 +2404,7 @@ void RenderViewContextMenu::ExecRestartPackagedApp() {
}
void RenderViewContextMenu::ExecPrint() {
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
if (params_.media_type != WebContextMenuData::MediaTypeNone) {
RenderFrameHost* render_frame_host = GetRenderFrameHost();
if (render_frame_host) {
@ -2417,7 +2418,7 @@ void RenderViewContextMenu::ExecPrint() {
source_web_contents_,
GetPrefs(browser_context_)->GetBoolean(prefs::kPrintPreviewDisabled),
!params_.selection_text.empty());
#endif // defined(ENABLE_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINTING)
}
void RenderViewContextMenu::ExecRouteMedia() {

@ -20,6 +20,7 @@
#include "components/renderer_context_menu/render_view_context_menu_observer.h"
#include "components/renderer_context_menu/render_view_context_menu_proxy.h"
#include "content/public/common/context_menu_params.h"
#include "printing/features/features.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/window_open_disposition.h"
#include "ui/gfx/geometry/vector2d.h"
@ -235,7 +236,7 @@ class RenderViewContextMenu : public RenderViewContextMenuBase {
// An observer that handles "Open with <app>" items.
std::unique_ptr<RenderViewContextMenuObserver> open_with_menu_observer_;
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// An observer that disables menu items when print preview is active.
std::unique_ptr<PrintPreviewContextMenuObserver> print_preview_menu_observer_;
#endif

@ -15,6 +15,7 @@
#include "components/guest_view/browser/guest_view_base.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/view_type_utils.h"
#include "printing/features/features.h"
#if defined(ENABLE_EXTENSIONS)
#include "extensions/browser/process_manager.h"
@ -109,13 +110,13 @@ void WebContentsTags::CreateForTabContents(content::WebContents* web_contents) {
// static
void WebContentsTags::CreateForPrintingContents(
content::WebContents* web_contents) {
#if defined(ENABLE_TASK_MANAGER) && defined(ENABLE_PRINT_PREVIEW)
#if defined(ENABLE_TASK_MANAGER) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (!WebContentsTag::FromWebContents(web_contents)) {
TagWebContents(web_contents,
new PrintingTag(web_contents),
WebContentsTag::kTagKey);
}
#endif // defined(ENABLE_TASK_MANAGER) && defined(ENABLE_PRINT_PREVIEW)
#endif // defined(ENABLE_TASK_MANAGER) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
}
// static

@ -9,6 +9,7 @@ import("//build/config/ui.gni")
import("//build/split_static_library.gni")
import("//chrome/common/features.gni")
import("//media/media_options.gni")
import("//printing/features/features.gni")
config("ui_warnings") {
if (is_clang) {
@ -564,6 +565,7 @@ split_static_library("ui") {
"//device/usb",
"//media",
"//net:net_with_v8",
"//printing/features",
"//services/service_manager/runner/common",
"//skia",
"//storage/browser",

@ -38,19 +38,20 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "extensions/common/constants.h"
#include "printing/features/features.h"
#if defined(USE_ASH)
#include "ash/common/shelf/shelf_constants.h" // nogncheck
#endif
#if defined(ENABLE_PRINTING)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_preview_message_handler.h"
#include "chrome/browser/printing/print_view_manager.h"
#else
#include "chrome/browser/printing/print_view_manager_basic.h"
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // defined(ENABLE_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINTING)
namespace {
@ -185,14 +186,14 @@ void ChromeAppDelegate::InitWebContents(content::WebContents* web_contents) {
web_contents);
favicon::CreateContentFaviconDriverForWebContents(web_contents);
#if defined(ENABLE_PRINTING)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
printing::PrintViewManager::CreateForWebContents(web_contents);
printing::PrintPreviewMessageHandler::CreateForWebContents(web_contents);
#else
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // defined(ENABLE_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINTING)
extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
web_contents);

@ -57,6 +57,7 @@
#include "content/public/common/url_constants.h"
#include "extensions/browser/extension_system.h"
#include "mash/public/interfaces/launchable.mojom.h"
#include "printing/features/features.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/events/keycodes/keyboard_codes.h"
@ -443,7 +444,7 @@ void BrowserCommandController::ExecuteCommandWithDisposition(
Print(browser_);
break;
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
case IDC_BASIC_PRINT:
content::RecordAction(base::UserMetricsAction("Accel_Advanced_Print"));
BasicPrint(browser_);
@ -1096,7 +1097,7 @@ void BrowserCommandController::UpdateCommandsForFullscreenMode() {
void BrowserCommandController::UpdatePrintingState() {
bool print_enabled = CanPrint(browser_);
command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled);
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
command_updater_.UpdateCommandEnabled(IDC_BASIC_PRINT,
CanBasicPrint(browser_));
#endif // ENABLE_BASIC_PRINTING

@ -84,6 +84,7 @@
#include "content/public/common/url_utils.h"
#include "content/public/common/user_agent.h"
#include "net/base/escape.h"
#include "printing/features/features.h"
#include "ui/events/keycodes/keyboard_codes.h"
#if defined(ENABLE_EXTENSIONS)
@ -100,12 +101,12 @@
#include "extensions/common/extension_set.h"
#endif
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
#include "chrome/browser/printing/print_view_manager_common.h"
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_preview_dialog_controller.h"
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // defined(ENABLE_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINTING)
#if defined(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h" // nogncheck
@ -255,7 +256,7 @@ bool IsShowingWebContentsModalDialog(Browser* browser) {
#if BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG)
bool PrintPreviewShowing(const Browser* browser) {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
WebContents* contents = browser->tab_strip_model()->GetActiveWebContents();
printing::PrintPreviewDialogController* controller =
printing::PrintPreviewDialogController::GetInstance();
@ -873,12 +874,12 @@ void ShowWebsiteSettings(
}
void Print(Browser* browser) {
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
printing::StartPrint(
browser->tab_strip_model()->GetActiveWebContents(),
browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled),
false);
#endif // defined(ENABLE_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINTING)
}
bool CanPrint(Browser* browser) {
@ -896,7 +897,7 @@ bool CanPrint(Browser* browser) {
GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT);
}
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
void BasicPrint(Browser* browser) {
printing::StartBasicPrint(browser->tab_strip_model()->GetActiveWebContents());
}
@ -911,7 +912,7 @@ bool CanBasicPrint(Browser* browser) {
return false; // The print dialog is disabled.
#endif // BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG)
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
bool CanRouteMedia(Browser* browser) {
// Do not allow user to open Media Router dialog when there is already an

@ -12,6 +12,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
#include "components/security_state/security_state_model.h"
#include "content/public/common/page_zoom.h"
#include "printing/features/features.h"
#include "ui/base/window_open_disposition.h"
class Browser;
@ -109,7 +110,7 @@ void ShowWebsiteSettings(
const security_state::SecurityStateModel::SecurityInfo& security_info);
void Print(Browser* browser);
bool CanPrint(Browser* browser);
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
void BasicPrint(Browser* browser);
bool CanBasicPrint(Browser* browser);
#endif // ENABLE_BASIC_PRINTING

@ -13,6 +13,7 @@
#include "base/macros.h"
#include "base/memory/singleton.h"
#include "chrome/app/chrome_command_ids.h"
#include "printing/features/features.h"
#import "ui/base/accelerators/platform_accelerator_cocoa.h"
#import "ui/events/cocoa/cocoa_event_utils.h"
#import "ui/events/keycodes/keyboard_code_conversion_mac.h"
@ -72,7 +73,7 @@ const struct AcceleratorMapping {
{IDC_FOCUS_LOCATION, NSCommandKeyMask, ui::VKEY_L},
{IDC_CLOSE_WINDOW, NSCommandKeyMask, ui::VKEY_W},
{IDC_EMAIL_PAGE_LOCATION, NSCommandKeyMask | NSShiftKeyMask, ui::VKEY_I},
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
{IDC_BASIC_PRINT, NSCommandKeyMask | NSAlternateKeyMask, ui::VKEY_P},
#endif // ENABLE_BASIC_PRINTING
{IDC_CONTENT_CONTEXT_UNDO, NSCommandKeyMask, ui::VKEY_Z},

@ -6,6 +6,7 @@ assert(is_linux, "This file should only be referenced on Linux")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//printing/features/features.gni")
# gn orders flags on a target before flags from configs. The default config
# adds -Wall, and these flags have to be after -Wall -- so they need to come

@ -36,6 +36,7 @@
#include "chrome/browser/ui/libgtkui/x11_input_method_context_impl_gtk.h"
#include "chrome/grit/theme_resources.h"
#include "components/grit/components_scaled_resources.h"
#include "printing/features/features.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
@ -58,7 +59,7 @@
#include "ui/views/linux_ui/window_button_order_observer.h"
#include "ui/views/resources/grit/views_resources.h"
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
#include "printing/printing_context_linux.h"
#endif
#if defined(USE_GCONF)
@ -433,7 +434,7 @@ void Gtk2UI::Initialize() {
LoadCursorTheme();
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
printing::PrintingContextLinux::SetCreatePrintDialogFunction(
&PrintDialogGtk2::CreatePrintDialog);
printing::PrintingContextLinux::SetPdfPaperSizeFunction(

@ -77,6 +77,7 @@
#include "content/public/common/content_switches.h"
#include "extensions/common/switches.h"
#include "net/base/port_util.h"
#include "printing/features/features.h"
#if defined(USE_ASH)
#include "ash/shell.h" // nogncheck
@ -104,7 +105,7 @@
#include "chrome/browser/metrics/jumplist_metrics_win.h"
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h"
#include "chrome/browser/printing/print_dialog_cloud.h"
@ -577,7 +578,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
bool silent_launch = false;
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// If we are just displaying a print dialog we shouldn't open browser
// windows.
if (command_line.HasSwitch(switches::kCloudPrintFile) &&
@ -585,7 +586,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
command_line)) {
silent_launch = true;
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (command_line.HasSwitch(switches::kExplicitlyAllowedPorts)) {
std::string allowed_ports =

@ -59,6 +59,7 @@
#include "components/subresource_filter/content/browser/content_subresource_filter_driver_factory.h"
#include "components/tracing/common/tracing_switches.h"
#include "content/public/browser/web_contents.h"
#include "printing/features/features.h"
#if BUILDFLAG(ANDROID_JAVA_UI)
#include "chrome/browser/android/banners/app_banner_manager_android.h"
@ -101,14 +102,14 @@
#include "chrome/browser/supervised_user/supervised_user_navigation_observer.h"
#endif
#if defined(ENABLE_PRINTING)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_preview_message_handler.h"
#include "chrome/browser/printing/print_view_manager.h"
#else
#include "chrome/browser/printing/print_view_manager_basic.h"
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // defined(ENABLE_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINTING)
using content::WebContents;
@ -251,14 +252,14 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
SupervisedUserNavigationObserver::CreateForWebContents(web_contents);
#endif
#if defined(ENABLE_PRINTING) && !BUILDFLAG(ANDROID_JAVA_UI)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINTING) && !BUILDFLAG(ANDROID_JAVA_UI)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
printing::PrintViewManager::CreateForWebContents(web_contents);
printing::PrintPreviewMessageHandler::CreateForWebContents(web_contents);
#else
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // defined(ENABLE_PRINTING) && !BUILDFLAG(ANDROID_JAVA_UI)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINTING) && !BUILDFLAG(ANDROID_JAVA_UI)
bool enabled_distiller = base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableDomDistiller);

@ -27,6 +27,7 @@ component("views") {
deps = [
"//base",
"//chrome/app:command_ids",
"//printing/features",
"//skia",
"//ui/base",
"//ui/events",

@ -9,6 +9,7 @@
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h"
#include "printing/features/features.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/events/event_constants.h"
@ -61,7 +62,7 @@ const AcceleratorMapping kAcceleratorMap[] = {
IDC_DEV_TOOLS_INSPECT },
{ ui::VKEY_O, ui::EF_CONTROL_DOWN, IDC_OPEN_FILE },
{ ui::VKEY_P, ui::EF_CONTROL_DOWN, IDC_PRINT},
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
{ ui::VKEY_P, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, IDC_BASIC_PRINT},
#endif // ENABLE_BASIC_PRINTING
{ ui::VKEY_R, ui::EF_CONTROL_DOWN, IDC_RELOAD },

@ -79,6 +79,7 @@
#include "content/public/browser/web_ui.h"
#include "content/public/common/content_client.h"
#include "content/public/common/url_utils.h"
#include "printing/features/features.h"
#include "ui/gfx/favicon_size.h"
#include "ui/web_dialogs/web_dialog_ui.h"
#include "url/gurl.h"
@ -91,7 +92,7 @@
#include "chrome/browser/ui/webui/media/webrtc_logs_ui.h"
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
#endif
@ -600,7 +601,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
if (url.host() == chrome::kChromeUIPluginsHost)
return &NewWebUI<PluginsUI>;
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (url.host() == chrome::kChromeUIPrintHost &&
!profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled)) {
return &NewWebUI<PrintPreviewUI>;

@ -18,6 +18,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "printing/features/features.h"
namespace {
@ -99,7 +100,7 @@ content::WebUIDataSource* CreateLocalDiscoveryHTMLSource() {
source->AddLocalizedString("backButton", IDS_SETTINGS_TITLE);
// Cloud print connector-related strings.
#if defined(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS)
source->AddLocalizedString("cloudPrintConnectorEnablingButton",
IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLING_BUTTON);
source->AddLocalizedString("cloudPrintConnectorDisabledButton",

@ -34,9 +34,10 @@
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_ui.h"
#include "printing/features/features.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS)
#define CLOUD_PRINT_CONNECTOR_UI_AVAILABLE
#endif

@ -16,8 +16,9 @@
#include "chrome/browser/printing/cloud_print/privet_http.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "printing/features/features.h"
#if defined(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS)
#define CLOUD_PRINT_CONNECTOR_UI_AVAILABLE
#endif

@ -106,6 +106,7 @@
#include "extensions/browser/extension_registry.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "printing/features/features.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
@ -572,7 +573,7 @@ void BrowserOptionsHandler::GetLocalizedValues(base::DictionaryValue* values) {
IDS_OPTIONS_ENABLE_DO_NOT_TRACK_BUBBLE_TITLE);
RegisterTitle(values, "spellingConfirmOverlay",
IDS_CONTENT_CONTEXT_SPELLING_ASK_GOOGLE);
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
RegisterCloudPrintValues(values);
#endif
@ -758,7 +759,7 @@ void BrowserOptionsHandler::GetLocalizedValues(base::DictionaryValue* values) {
#endif
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void BrowserOptionsHandler::RegisterCloudPrintValues(
base::DictionaryValue* values) {
values->SetString("cloudPrintOptionLabel",
@ -766,7 +767,7 @@ void BrowserOptionsHandler::RegisterCloudPrintValues(
IDS_CLOUD_PRINT_CHROMEOS_OPTION_LABEL,
l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT)));
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
void BrowserOptionsHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(

@ -30,6 +30,7 @@
#include "content/public/browser/notification_observer.h"
#include "extensions/browser/extension_registry_observer.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "printing/features/features.h"
#include "ui/base/models/table_model_observer.h"
#include "ui/shell_dialogs/select_file_dialog.h"
@ -121,7 +122,7 @@ class BrowserOptionsHandler
const base::string16& old_profile_name) override;
void OnProfileAvatarChanged(const base::FilePath& profile_path) override;
#if defined(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS)
void OnCloudPrintPrefsChanged();
#endif
@ -284,7 +285,7 @@ class BrowserOptionsHandler
void ShowCloudPrintDevicesPage(const base::ListValue* args);
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Register localized values used by Cloud Print
void RegisterCloudPrintValues(base::DictionaryValue* values);
#endif

@ -78,6 +78,7 @@
#include "net/base/url_util.h"
#include "printing/backend/print_backend.h"
#include "printing/backend/print_backend_consts.h"
#include "printing/features/features.h"
#include "printing/pdf_render_settings.h"
#include "printing/print_settings.h"
#include "printing/printing_context.h"
@ -970,7 +971,7 @@ void PrintPreviewHandler::HandlePrint(const base::ListValue* args) {
ReportUserActionHistogram(PRINT_WITH_CLOUD_PRINT);
SendCloudPrintJob(data.get());
} else {
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
bool system_dialog = false;
settings->GetBoolean(printing::kSettingShowSystemDialog, &system_dialog);
if (system_dialog) {
@ -1023,7 +1024,7 @@ void PrintPreviewHandler::HandlePrint(const base::ListValue* args) {
}
#else
NOTREACHED();
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
}
}

@ -16,6 +16,7 @@
#include "chrome/common/features.h"
#include "components/signin/core/browser/gaia_cookie_manager_service.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "printing/features/features.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
@ -70,11 +71,11 @@ class PrintPreviewHandler
// Called when print preview failed.
void OnPrintPreviewFailed();
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// Called when the user press ctrl+shift+p to display the native system
// dialog.
void ShowSystemDialog();
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
// PrivetLocalPrinterLister::Delegate implementation.

@ -37,6 +37,7 @@
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_data_source.h"
#include "printing/features/features.h"
#include "printing/page_size_margins.h"
#include "printing/print_job_constants.h"
#include "ui/base/l10n/l10n_util.h"
@ -532,7 +533,7 @@ void PrintPreviewUI::OnPrintPreviewRequest(int request_id) {
g_print_preview_request_id_map.Get().Set(id_, request_id);
}
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
void PrintPreviewUI::OnShowSystemDialog() {
web_ui()->CallJavascriptFunctionUnsafe("onSystemDialogLinkClicked");
}

@ -15,6 +15,7 @@
#include "base/memory/ref_counted.h"
#include "base/time/time.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
#include "printing/features/features.h"
class PrintPreviewDataService;
class PrintPreviewHandler;
@ -87,7 +88,7 @@ class PrintPreviewUI : public ConstrainedWebDialogUI {
// Notifies the Web UI of a print preview request with |request_id|.
void OnPrintPreviewRequest(int request_id);
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// Notifies the Web UI to show the system dialog.
void OnShowSystemDialog();
#endif // ENABLE_BASIC_PRINTING

@ -21,6 +21,7 @@
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "printing/features/features.h"
#include "url/url_constants.h"
#if defined(OS_WIN)
@ -56,7 +57,7 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewTest, PrintCommands) {
ASSERT_TRUE(chrome::IsCommandEnabled(browser(), IDC_PRINT));
#if defined(ENABLE_BASIC_PRINTING) && !defined(OS_CHROMEOS)
#if BUILDFLAG(ENABLE_BASIC_PRINTING) && !defined(OS_CHROMEOS)
// This is analagous to ENABLE_BASIC_PRINT_DIALOG but helps to verify
// that it is defined as expected.
bool is_basic_print_expected = true;

@ -222,6 +222,7 @@ static_library("common") {
"//mojo/public/cpp/bindings",
"//net",
"//ppapi/features",
"//printing/features",
"//skia",
"//third_party/icu",
"//third_party/kasko:kasko_features",
@ -570,6 +571,7 @@ static_library("constants") {
public_deps = [
":features",
"//content/public/common:result_codes",
"//printing/features",
]
deps = [
":version_header",

@ -11,6 +11,7 @@
// chrome/tools/ipclist/ipclist.cc.
#include "build/build_config.h"
#include "printing/features/features.h"
#if !defined(OS_ANDROID)
#include "chrome/common/importer/profile_import_process_messages.h"
@ -18,7 +19,7 @@
#include "chrome/common/common_message_generator.h"
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
// TODO(dgn) remove from here when all the code using these messages is removed
// from /chrome. (crbug.com/311308, crbug.com/450822)
#include "components/printing/common/print_messages.h" // nogncheck

@ -133,7 +133,7 @@ const base::Feature kPreferHtmlOverPlugins{"PreferHtmlOverPlugins",
#endif
// Enables the Print Scaling feature in print preview.
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
const base::Feature kPrintScaling{"PrintScaling",
base::FEATURE_DISABLED_BY_DEFAULT};
#endif

@ -9,6 +9,7 @@
#define CHROME_COMMON_CHROME_FEATURES_H_
#include "base/feature_list.h"
#include "printing/features/features.h"
namespace features {
@ -79,7 +80,7 @@ extern const base::Feature kOverrideYouTubeFlashEmbed;
extern const base::Feature kPreferHtmlOverPlugins;
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
extern const base::Feature kPrintScaling;
#endif

@ -7,6 +7,7 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "build/build_config.h"
#include "printing/features/features.h"
namespace switches {
@ -1258,7 +1259,7 @@ const char kWindows10CustomTitlebar[] = "windows10-custom-titlebar";
const char kWindows8Search[] = "windows8-search";
#endif // defined(OS_WIN)
#if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
// Enables support to debug printing subsystem.
const char kDebugPrint[] = "debug-print";
#endif

@ -9,6 +9,7 @@
#define CHROME_COMMON_CHROME_SWITCHES_H_
#include "build/build_config.h"
#include "printing/features/features.h"
// Don't add more switch files here. This is linked into some places like the
// installer where dependencies should be limited. Instead, have files
@ -372,7 +373,7 @@ extern const char kWindows10CustomTitlebar[];
extern const char kWindows8Search[];
#endif // defined(OS_WIN)
#if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
extern const char kDebugPrint[];
#endif

@ -13,6 +13,7 @@
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_platform_file.h"
#include "printing/backend/print_backend.h"
#include "printing/features/features.h"
#include "printing/page_range.h"
#include "printing/pdf_render_settings.h"
#include "printing/pwg_raster_settings.h"
@ -24,7 +25,7 @@
#define IPC_MESSAGE_START ChromeUtilityPrintingMsgStart
// Preview and Cloud Print messages.
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterCapsAndDefaults)
IPC_STRUCT_TRAITS_MEMBER(printer_capabilities)
IPC_STRUCT_TRAITS_MEMBER(caps_mime_type)
@ -94,7 +95,7 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults,
// Windows uses messages for printing even without preview. crbug.com/170859
// Primary user of Windows without preview is CEF. crbug.com/417967
#if defined(ENABLE_PRINTING) && defined(OS_WIN)
#if BUILDFLAG(ENABLE_PRINTING) && defined(OS_WIN)
// Tell the utility process to start rendering the given PDF into a metafile.
// Utility process would be alive until
// ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop message.
@ -116,7 +117,7 @@ IPC_MESSAGE_CONTROL0(ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop)
// Utility process host messages:
// These are messages from the utility process to the browser.
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Reply when the utility process has succeeded in rendering the PDF to PWG.
IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Succeeded)
@ -148,7 +149,7 @@ IPC_MESSAGE_CONTROL1(
std::string /* printer name */)
#endif // ENABLE_PRINT_PREVIEW
#if defined(ENABLE_PRINTING) && defined(OS_WIN)
#if BUILDFLAG(ENABLE_PRINTING) && defined(OS_WIN)
// Reply when the utility process loaded PDF. |page_count| is 0, if loading
// failed.
IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount,

@ -15,6 +15,7 @@
#include "chrome/common/tts_messages.h"
#include "content/public/common/common_param_traits.h"
#include "content/public/common/common_param_traits_macros.h"
#include "printing/features/features.h"
#if defined(ENABLE_EXTENSIONS)
#include "chrome/common/cast_messages.h"
@ -22,11 +23,11 @@
#include "chrome/common/extensions/chrome_utility_extensions_messages.h"
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/common/service_messages.h"
#endif
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
#include "chrome/common/chrome_utility_printing_messages.h"
#endif

@ -7,6 +7,7 @@ import("//build/config/chromecast_build.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/features.gni")
import("//net/features.gni")
import("//printing/features/features.gni")
# Please keep features in alphabetical order.
declare_args() {
@ -74,12 +75,16 @@ declare_args() {
use_vulcanize = true
}
_enable_printing = enable_basic_printing || enable_print_preview
chrome_grit_defines = [
"enable_app_list=$enable_app_list",
"enable_background=$enable_background",
"enable_google_now=$enable_google_now",
"enable_hangout_services_extension=$enable_hangout_services_extension",
"enable_hotwording=$enable_hotwording",
"enable_print_preview=$enable_print_preview",
"enable_printing=$_enable_printing",
"enable_service_discovery=$enable_service_discovery",
"enable_vr_shell=$enable_vr_shell",
"enable_webvr=$enable_webvr",

@ -10,6 +10,7 @@
#include "build/build_config.h"
#include "chrome/common/features.h"
#include "content/public/common/url_constants.h"
#include "printing/features/features.h"
#include "url/url_util.h"
namespace chrome {
@ -264,7 +265,7 @@ const char kChromeUIWelcomeHost[] = "welcome";
const char kChromeUIWelcomeWin10Host[] = "welcome-win10";
const char kChromeUIWorkersHost[] = "workers";
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
const char kChromeUIPrintHost[] = "print";
#endif // ENABLE_PRINT_PREVIEW
@ -711,7 +712,7 @@ const char* const kChromeHostURLs[] = {
#if defined(ENABLE_EXTENSIONS)
kChromeUIExtensionsHost,
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
kChromeUIPrintHost,
#endif
#if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)

@ -15,6 +15,7 @@
#include "build/build_config.h"
#include "chrome/common/features.h"
#include "content/public/common/url_constants.h"
#include "printing/features/features.h"
namespace chrome {
@ -246,7 +247,7 @@ extern const char kChromeUIWelcomeHost[];
extern const char kChromeUIWelcomeWin10Host[];
extern const char kChromeUIWorkersHost[];
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
extern const char kChromeUIPrintHost[];
#endif // ENABLE_PRINT_PREVIEW

@ -119,6 +119,7 @@ static_library("renderer") {
"//media/capture",
"//net",
"//ppapi/features",
"//printing/features",
"//skia",
"//storage/common",
"//third_party/WebKit/public:blink",

@ -96,6 +96,7 @@
#include "net/base/net_errors.h"
#include "ppapi/c/private/ppb_pdf.h"
#include "ppapi/shared_impl/ppapi_switches.h"
#include "printing/features/features.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/WebKit/public/platform/URLConversion.h"
#include "third_party/WebKit/public/platform/WebCachePolicy.h"
@ -138,14 +139,14 @@
#include "chrome/renderer/plugins/power_saver_info.h"
#endif
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
#include "chrome/common/chrome_content_client.h"
#include "chrome/renderer/printing/chrome_print_web_view_helper_delegate.h"
#include "components/printing/renderer/print_web_view_helper.h"
#include "printing/print_settings.h"
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/renderer/pepper/chrome_pdf_print_client.h"
#endif
@ -306,7 +307,7 @@ ChromeContentRendererClient::ChromeContentRendererClient()
for (size_t i = 0; i < arraysize(kPredefinedAllowedCompositorOrigins); ++i)
allowed_compositor_origins_.insert(kPredefinedAllowedCompositorOrigins[i]);
#endif
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
printing::SetAgent(GetUserAgent());
#endif
}
@ -410,7 +411,7 @@ void ChromeContentRendererClient::RenderThreadStarted() {
// care of in extensions::Dispatcher.
WebSecurityPolicy::registerURLSchemeAsSecure(chrome_search_scheme);
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
pdf_print_client_.reset(new ChromePDFPrintClient());
pdf::PepperPDFHost::SetPrintClient(pdf_print_client_.get());
#endif
@ -519,7 +520,7 @@ void ChromeContentRendererClient::RenderViewCreated(
#if defined(ENABLE_EXTENSIONS)
ChromeExtensionsRendererClient::GetInstance()->RenderViewCreated(render_view);
#endif
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
new printing::PrintWebViewHelper(
render_view, std::unique_ptr<printing::PrintWebViewHelper::Delegate>(
new ChromePrintWebViewHelperDelegate()));

@ -19,6 +19,7 @@
#include "components/rappor/public/interfaces/rappor_recorder.mojom.h"
#include "content/public/renderer/content_renderer_client.h"
#include "ipc/ipc_channel_proxy.h"
#include "printing/features/features.h"
#include "v8/include/v8.h"
#if defined (OS_CHROMEOS)
@ -26,7 +27,7 @@
#endif
class ChromeRenderThreadObserver;
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
class ChromePDFPrintClient;
#endif
class PrescientNetworkingDispatcher;
@ -243,7 +244,7 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
#if defined(ENABLE_WEBRTC)
scoped_refptr<WebRtcLoggingMessageFilter> webrtc_logging_message_filter_;
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
std::unique_ptr<ChromePDFPrintClient> pdf_print_client_;
#endif
#if defined(ENABLE_PLUGINS)

@ -27,6 +27,7 @@
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h"
#include "extensions/common/constants.h"
#include "printing/features/features.h"
#include "skia/ext/image_operations.h"
#include "third_party/WebKit/public/platform/WebImage.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
@ -42,7 +43,7 @@
#include "ui/gfx/geometry/size_f.h"
#include "url/gurl.h"
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
#include "components/printing/common/print_messages.h"
#include "components/printing/renderer/print_web_view_helper.h"
#endif
@ -144,7 +145,7 @@ bool ChromeRenderFrameObserver::OnMessageReceived(const IPC::Message& message) {
OnRequestThumbnailForContextNode)
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection,
OnSetClientSidePhishingDetection)
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu,
OnPrintNodeUnderContextMenu)
#endif
@ -218,7 +219,7 @@ void ChromeRenderFrameObserver::OnRequestThumbnailForContextNode(
}
void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() {
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
printing::PrintWebViewHelper* helper =
printing::PrintWebViewHelper::Get(render_frame()->GetRenderView());
if (helper)

@ -3,6 +3,7 @@
# found in the LICENSE file.
import("//build/config/features.gni")
import("//printing/features/features.gni")
static_library("service") {
sources = [

@ -123,6 +123,7 @@ static_library("test_support") {
"//content/test:test_support",
"//net",
"//net:test_support",
"//printing/features",
"//skia",
"//sql",
"//sql:test_support",
@ -1227,6 +1228,7 @@ test("browser_tests") {
":test_support",
"//base",
"//components/sync:test_support_model",
"//printing/features",
"//third_party/WebKit/public:features",
]

@ -25,6 +25,7 @@
#include "components/subresource_filter/core/browser/ruleset_service.h"
#include "content/public/browser/notification_service.h"
#include "net/url_request/url_request_context_getter.h"
#include "printing/features/features.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/message_center/message_center.h"
@ -40,7 +41,7 @@
#include "components/storage_monitor/test_storage_monitor.h"
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/background_printing_manager.h"
#include "chrome/browser/printing/print_preview_dialog_controller.h"
#endif
@ -254,7 +255,7 @@ bool TestingBrowserProcess::IsShuttingDown() {
}
printing::PrintJobManager* TestingBrowserProcess::print_job_manager() {
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
if (!print_job_manager_.get())
print_job_manager_.reset(new printing::PrintJobManager());
return print_job_manager_.get();
@ -266,7 +267,7 @@ printing::PrintJobManager* TestingBrowserProcess::print_job_manager() {
printing::PrintPreviewDialogController*
TestingBrowserProcess::print_preview_dialog_controller() {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (!print_preview_dialog_controller_.get())
print_preview_dialog_controller_ =
new printing::PrintPreviewDialogController();
@ -279,7 +280,7 @@ TestingBrowserProcess::print_preview_dialog_controller() {
printing::BackgroundPrintingManager*
TestingBrowserProcess::background_printing_manager() {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (!background_printing_manager_.get()) {
background_printing_manager_.reset(
new printing::BackgroundPrintingManager());

@ -20,6 +20,7 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "printing/features/features.h"
class BackgroundModeManager;
class CRLSetFetcher;
@ -163,11 +164,11 @@ class TestingBrowserProcess : public BrowserProcess {
std::unique_ptr<NotificationUIManager> notification_ui_manager_;
std::unique_ptr<NotificationPlatformBridge> notification_platform_bridge_;
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
std::unique_ptr<printing::PrintJobManager> print_job_manager_;
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
std::unique_ptr<printing::BackgroundPrintingManager>
background_printing_manager_;
scoped_refptr<printing::PrintPreviewDialogController>

@ -36,9 +36,10 @@
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "net/base/filename_util.h"
#include "printing/features/features.h"
#include "ui/base/resource/resource_handle.h"
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_preview_dialog_controller.h"
#endif
@ -237,7 +238,7 @@ void WebUIBrowserTest::BrowsePreload(const GURL& browse_to) {
navigation_observer.Wait();
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// This custom ContentBrowserClient is used to get notified when a WebContents
// for the print preview dialog gets created.
@ -280,7 +281,7 @@ class PrintContentBrowserClient : public ChromeContentBrowserClient {
#endif
void WebUIBrowserTest::BrowsePrintPreload(const GURL& browse_to) {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
ui_test_utils::NavigateToURL(browser(), browse_to);
PrintContentBrowserClient new_client(

@ -5,6 +5,7 @@
import("//build/config/crypto.gni")
import("//build/config/features.gni")
import("//build/config/sysroot.gni")
import("//printing/features/features.gni")
static_library("utility") {
sources = [
@ -50,6 +51,7 @@ static_library("utility") {
"//courgette:courgette_lib",
"//media",
"//net:net_with_v8",
"//printing/features",
"//services/service_manager/public/cpp",
"//skia",
"//sql",

@ -26,6 +26,7 @@
#include "courgette/third_party/bsdiff/bsdiff.h"
#include "ipc/ipc_channel.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "printing/features/features.h"
#include "services/service_manager/public/cpp/interface_registry.h"
#include "third_party/zlib/google/zip.h"
#include "ui/gfx/geometry/size.h"
@ -48,8 +49,8 @@
#include "chrome/utility/image_writer/image_writer_handler.h"
#endif
#if defined(ENABLE_PRINT_PREVIEW) || \
(defined(ENABLE_BASIC_PRINTING) && defined(OS_WIN))
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \
(BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN))
#include "chrome/utility/printing_handler.h"
#endif
@ -118,8 +119,8 @@ ChromeContentUtilityClient::ChromeContentUtilityClient()
handlers_.push_back(new image_writer::ImageWriterHandler());
#endif
#if defined(ENABLE_PRINT_PREVIEW) || \
(defined(ENABLE_BASIC_PRINTING) && defined(OS_WIN))
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) || \
(BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN))
handlers_.push_back(new printing::PrintingHandler());
#endif

@ -15,6 +15,7 @@
#include "chrome/utility/cloud_print/pwg_encoder.h"
#include "content/public/utility/utility_thread.h"
#include "pdf/pdf.h"
#include "printing/features/features.h"
#include "printing/page_range.h"
#include "printing/pdf_render_settings.h"
@ -23,7 +24,7 @@
#include "ui/gfx/gdi_util.h"
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/common/crash_keys.h"
#include "printing/backend/print_backend.h"
#endif
@ -70,7 +71,7 @@ bool PrintingHandler::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop,
OnRenderPDFPagesToMetafileStop)
#endif // OS_WIN
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToPWGRaster,
OnRenderPDFPagesToPWGRaster)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
@ -113,7 +114,7 @@ void PrintingHandler::OnRenderPDFPagesToMetafileStop() {
#endif // OS_WIN
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintingHandler::OnRenderPDFPagesToPWGRaster(
IPC::PlatformFileForTransit pdf_transit,
const PdfRenderSettings& settings,
@ -196,7 +197,7 @@ bool PrintingHandler::RenderPdfPageToMetafile(int page_number,
#endif // OS_WIN
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
bool PrintingHandler::RenderPDFPagesToPWGRaster(
base::File pdf_file,
const PdfRenderSettings& settings,

@ -10,10 +10,11 @@
#include "build/build_config.h"
#include "chrome/utility/utility_message_handler.h"
#include "ipc/ipc_platform_file.h"
#include "printing/features/features.h"
#include "printing/pdf_render_settings.h"
#if !defined(ENABLE_PRINT_PREVIEW) && \
!(defined(ENABLE_BASIC_PRINTING) && defined(OS_WIN))
#if !BUILDFLAG(ENABLE_PRINT_PREVIEW) && \
!(BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN))
#error "Windows basic printing or print preview must be enabled"
#endif
@ -43,7 +44,7 @@ class PrintingHandler : public UtilityMessageHandler {
IPC::PlatformFileForTransit output_file);
void OnRenderPDFPagesToMetafileStop();
#endif // OS_WIN
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void OnRenderPDFPagesToPWGRaster(IPC::PlatformFileForTransit pdf_transit,
const PdfRenderSettings& settings,
const PwgRasterSettings& bitmap_settings,
@ -56,7 +57,7 @@ class PrintingHandler : public UtilityMessageHandler {
base::File output_file,
float* scale_factor);
#endif // OS_WIN
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
bool RenderPDFPagesToPWGRaster(base::File pdf_file,
const PdfRenderSettings& settings,
const PwgRasterSettings& bitmap_settings,

@ -4,6 +4,7 @@
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//printing/features/features.gni")
import("//testing/test.gni")
import("//tools/grit/repack.gni")
@ -413,6 +414,7 @@ if (!is_ios) {
"//device/geolocation",
"//ipc:test_support",
"//net:test_support",
"//printing/features",
"//services/service_manager/public/cpp",
"//testing/gmock",
"//testing/gtest",

@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/strings/string16.h"
#include "printing/features/features.h"
#include "ui/gfx/geometry/size.h"
#define IPC_MESSAGE_IMPL
@ -104,7 +105,7 @@ void PrintMsg_PrintPages_Params::Reset() {
pages = std::vector<int>();
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
PrintHostMsg_RequestPrintPreview_Params::
PrintHostMsg_RequestPrintPreview_Params()
: is_modifiable(false),
@ -126,4 +127,4 @@ PrintHostMsg_SetOptionsFromDocument_Params::
PrintHostMsg_SetOptionsFromDocument_Params::
~PrintHostMsg_SetOptionsFromDocument_Params() {
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)

@ -15,6 +15,7 @@
#include "build/build_config.h"
#include "components/printing/common/printing_param_traits_macros.h"
#include "ipc/ipc_message_macros.h"
#include "printing/features/features.h"
#include "printing/page_range.h"
#include "printing/page_size_margins.h"
#include "printing/print_job_constants.h"
@ -72,7 +73,7 @@ struct PrintMsg_PrintPages_Params {
std::vector<int> pages;
};
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
struct PrintHostMsg_RequestPrintPreview_Params {
PrintHostMsg_RequestPrintPreview_Params();
~PrintHostMsg_RequestPrintPreview_Params();
@ -91,7 +92,7 @@ struct PrintHostMsg_SetOptionsFromDocument_Params {
printing::DuplexMode duplex;
printing::PageRanges page_ranges;
};
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
@ -181,7 +182,7 @@ IPC_STRUCT_TRAITS_BEGIN(printing::PageRange)
IPC_STRUCT_TRAITS_MEMBER(to)
IPC_STRUCT_TRAITS_END()
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_RequestPrintPreview_Params)
IPC_STRUCT_TRAITS_MEMBER(is_modifiable)
IPC_STRUCT_TRAITS_MEMBER(webnode_only)
@ -202,7 +203,7 @@ IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_SetOptionsFromDocument_Params)
// Specifies page range to be printed.
IPC_STRUCT_TRAITS_MEMBER(page_ranges)
IPC_STRUCT_TRAITS_END()
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
IPC_STRUCT_TRAITS_BEGIN(printing::PageSizeMargins)
IPC_STRUCT_TRAITS_MEMBER(content_width)
@ -222,7 +223,7 @@ IPC_STRUCT_TRAITS_BEGIN(PrintMsg_PrintPages_Params)
IPC_STRUCT_TRAITS_MEMBER(pages)
IPC_STRUCT_TRAITS_END()
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Parameters to describe a rendered document.
IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params)
// A shared memory handle to metafile data.
@ -279,7 +280,7 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidGetPreviewPageCount_Params)
// Indicates whether the existing preview data needs to be cleared or not.
IPC_STRUCT_MEMBER(bool, clear_preview_data)
IPC_STRUCT_END()
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Parameters to describe a rendered page.
IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintPage_Params)
@ -318,31 +319,31 @@ IPC_STRUCT_END()
// Messages sent from the browser to the renderer.
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Tells the render view to initiate print preview for the entire document.
IPC_MESSAGE_ROUTED1(PrintMsg_InitiatePrintPreview, bool /* selection_only */)
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Tells the render frame to initiate printing or print preview for a particular
// node, depending on which mode the render frame is in.
IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu)
#if defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Tells the renderer to print the print preview tab's PDF plugin without
// showing the print dialog. (This is the final step in the print preview
// workflow.)
IPC_MESSAGE_ROUTED1(PrintMsg_PrintForPrintPreview,
base::DictionaryValue /* settings */)
#endif // defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// Tells the render view to switch the CSS to print media type, renders every
// requested pages and switch back the CSS to display media type.
IPC_MESSAGE_ROUTED0(PrintMsg_PrintPages)
// Like PrintMsg_PrintPages, but using the print preview document's frame/node.
IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog)
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
// Tells the render view that printing is done so it can clean up.
IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone,
@ -352,13 +353,13 @@ IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone,
IPC_MESSAGE_ROUTED1(PrintMsg_SetScriptedPrintingBlocked,
bool /* blocked */)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Tells the render view to switch the CSS to print media type, renders every
// requested pages for print preview using the given |settings|. This gets
// called multiple times as the user updates settings.
IPC_MESSAGE_ROUTED1(PrintMsg_PrintPreview,
base::DictionaryValue /* settings */)
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Messages sent from the renderer to the browser.
@ -418,7 +419,7 @@ IPC_MESSAGE_CONTROL2(PrintHostMsg_TempFileForPrintingWritten,
int /* fd in browser */) // Used only by Chrome OS.
#endif // defined(OS_ANDROID)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Asks the browser to do print preview.
IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview,
PrintHostMsg_RequestPrintPreview_Params /* params */)
@ -452,7 +453,7 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_CheckForCancel,
// The memory handle in this message is already valid in the browser process.
IPC_MESSAGE_ROUTED1(PrintHostMsg_MetafileReadyForPrinting,
PrintHostMsg_DidPreviewDocument_Params /* params */)
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// This is sent when there are invalid printer settings.
IPC_MESSAGE_ROUTED0(PrintHostMsg_ShowInvalidPrinterSettingsError)
@ -461,7 +462,7 @@ IPC_MESSAGE_ROUTED0(PrintHostMsg_ShowInvalidPrinterSettingsError)
IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintingFailed,
int /* document cookie */)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Tell the browser print preview failed.
IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewFailed,
int /* document cookie */)
@ -488,4 +489,4 @@ IPC_MESSAGE_ROUTED1(PrintHostMsg_ShowScriptedPrintPreview,
// Notify the browser to set print presets based on source PDF document.
IPC_MESSAGE_ROUTED1(PrintHostMsg_SetOptionsFromDocument,
PrintHostMsg_SetOptionsFromDocument_Params /* params */)
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)

@ -29,6 +29,7 @@
#include "content/public/renderer/render_view.h"
#include "grit/components_resources.h"
#include "net/base/escape.h"
#include "printing/features/features.h"
#include "printing/metafile_skia_wrapper.h"
#include "printing/pdf_metafile_skia.h"
#include "printing/units.h"
@ -84,7 +85,7 @@ const double kMinDpi = 1.0;
// Also set in third_party/WebKit/Source/core/page/PrintContext.cpp
const float kPrintingMinimumShrinkFactor = 1.333f;
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
bool g_is_preview_enabled = true;
const char kPageLoadScriptFormat[] =
@ -102,7 +103,7 @@ void ExecuteScript(blink::WebFrame* frame,
}
#else
bool g_is_preview_enabled = false;
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
int GetDPI(const PrintMsg_Print_Params* print_params) {
#if defined(OS_MACOSX)
@ -319,7 +320,7 @@ bool PrintingNodeOrPdfFrame(const blink::WebLocalFrame* frame,
return plugin && plugin->supportsPaginatedPrint();
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Returns true if the current destination printer is PRINT_TO_PDF.
bool IsPrintToPdfRequested(const base::DictionaryValue& job_settings) {
bool print_to_pdf = false;
@ -341,7 +342,7 @@ bool PrintingFrameHasPageSizeStyle(blink::WebLocalFrame* frame,
}
return frame_has_custom_page_size_style;
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Disable scaling when either:
// - The PDF specifies disabling scaling.
@ -386,7 +387,7 @@ bool PDFShouldDisableScaling(blink::WebLocalFrame* frame,
ignore_page_size);
}
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
MarginType GetMarginsForPdf(blink::WebLocalFrame* frame,
const blink::WebNode& node,
const PrintMsg_Print_Params& params) {
@ -395,7 +396,7 @@ MarginType GetMarginsForPdf(blink::WebLocalFrame* frame,
}
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
bool FitToPageEnabled(const base::DictionaryValue& job_settings) {
bool fit_to_paper_size = false;
if (!job_settings.GetBoolean(kSettingFitToPageEnabled, &fit_to_paper_size)) {
@ -438,7 +439,7 @@ blink::WebPrintScalingOption GetPrintScalingOption(
}
return blink::WebPrintScalingOptionFitToPrintableArea;
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Helper function to scale and round an integer value with a double valued
// scaling.
@ -557,7 +558,7 @@ blink::WebView* FrameReference::view() {
return view_;
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// static - Not anonymous so that platform implementations can use it.
void PrintWebViewHelper::PrintHeaderAndFooter(
blink::WebCanvas* canvas,
@ -615,7 +616,7 @@ void PrintWebViewHelper::PrintHeaderAndFooter(
web_view->close();
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// static - Not anonymous so that platform implementations can use it.
float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame,
@ -721,7 +722,7 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint(
ComputeWebKitPrintParamsInDesiredDpi(params, &web_print_params_);
frame->printBegin(web_print_params_, node_to_print_);
double scale_factor = 1.0f;
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (print_params.scale_factor >= PrintWebViewHelper::kEpsilon)
scale_factor = print_params.scale_factor;
#endif
@ -953,12 +954,12 @@ void PrintWebViewHelper::PrintPage(blink::WebLocalFrame* frame,
return;
if (g_is_preview_enabled) {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
print_preview_context_.InitWithFrame(frame);
RequestPrintPreview(PRINT_PREVIEW_SCRIPTED);
#endif
} else {
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
Print(frame, blink::WebNode(), true);
#endif
}
@ -976,18 +977,18 @@ bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message)
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages)
IPC_MESSAGE_HANDLER(PrintMsg_PrintForSystemDialog, OnPrintForSystemDialog)
#endif // defined(ENABLE_BASIC_PRINTING)
#if defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview)
#endif
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview)
IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview)
IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone)
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
IPC_MESSAGE_HANDLER(PrintMsg_SetScriptedPrintingBlocked,
SetScriptedPrintBlocked)
IPC_MESSAGE_UNHANDLED(handled = false)
@ -1017,7 +1018,7 @@ bool PrintWebViewHelper::GetPrintFrame(blink::WebLocalFrame** frame) {
return true;
}
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
void PrintWebViewHelper::OnPrintPages() {
if (ipc_nesting_level_> 1)
return;
@ -1040,9 +1041,9 @@ void PrintWebViewHelper::OnPrintForSystemDialog() {
}
Print(frame, print_preview_context_.source_node(), false);
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
#if defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintWebViewHelper::OnPrintForPrintPreview(
const base::DictionaryValue& job_settings) {
CHECK_LE(ipc_nesting_level_, 1);
@ -1107,7 +1108,7 @@ void PrintWebViewHelper::OnPrintForPrintPreview(
DidFinishPrinting(FAIL_PRINT);
}
}
#endif // defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintWebViewHelper::GetPageSizeAndContentAreaFromPageLayout(
const PageSizeMargins& page_layout_in_points,
@ -1132,7 +1133,7 @@ void PrintWebViewHelper::UpdateFrameMarginsCssInfo(
ignore_css_margins_ = (margins_type != DEFAULT_MARGINS);
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintWebViewHelper::OnPrintPreview(const base::DictionaryValue& settings) {
if (ipc_nesting_level_ > 1)
return;
@ -1317,7 +1318,7 @@ bool PrintWebViewHelper::CreatePreviewDocument() {
return true;
}
#if !defined(OS_MACOSX) && defined(ENABLE_PRINT_PREVIEW)
#if !defined(OS_MACOSX) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
bool PrintWebViewHelper::RenderPreviewPage(
int page_number,
const PrintMsg_Print_Params& print_params) {
@ -1347,7 +1348,7 @@ bool PrintWebViewHelper::RenderPreviewPage(
}
return PreviewPageRendered(page_number, draft_metafile.get());
}
#endif // !defined(OS_MACOSX) && defined(ENABLE_PRINT_PREVIEW)
#endif // !defined(OS_MACOSX) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
bool PrintWebViewHelper::FinalizePrintReadyDocument() {
DCHECK(!is_print_ready_metafile_sent_);
@ -1377,7 +1378,7 @@ bool PrintWebViewHelper::FinalizePrintReadyDocument() {
Send(new PrintHostMsg_MetafileReadyForPrinting(routing_id(), preview_params));
return true;
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintWebViewHelper::OnPrintingDone(bool success) {
if (ipc_nesting_level_ > 1)
@ -1392,7 +1393,7 @@ void PrintWebViewHelper::SetScriptedPrintBlocked(bool blocked) {
is_scripted_printing_blocked_ = blocked;
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) {
if (ipc_nesting_level_ > 1)
return;
@ -1438,12 +1439,12 @@ void PrintWebViewHelper::PrintNode(const blink::WebNode& node) {
// Make a copy of the node, in case RenderView::OnContextMenuClosed resets
// its |context_menu_node_|.
if (g_is_preview_enabled) {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
print_preview_context_.InitWithNode(node);
RequestPrintPreview(PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE);
#endif
} else {
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
blink::WebNode duplicate_node(node);
Print(duplicate_node.document().frame(), duplicate_node, false);
#endif
@ -1452,7 +1453,7 @@ void PrintWebViewHelper::PrintNode(const blink::WebNode& node) {
print_node_in_progress_ = false;
}
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
void PrintWebViewHelper::Print(blink::WebLocalFrame* frame,
const blink::WebNode& node,
bool is_scripted) {
@ -1489,7 +1490,7 @@ void PrintWebViewHelper::Print(blink::WebLocalFrame* frame,
}
scripting_throttler_.Reset();
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) {
switch (result) {
@ -1507,7 +1508,7 @@ void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) {
}
break;
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
case FAIL_PREVIEW:
int cookie =
print_pages_params_ ? print_pages_params_->params.document_cookie : 0;
@ -1519,14 +1520,14 @@ void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) {
}
print_preview_context_.Failed(notify_browser_of_print_failure_);
break;
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
}
prep_frame_view_.reset();
print_pages_params_.reset();
notify_browser_of_print_failure_ = true;
}
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
void PrintWebViewHelper::OnFramePreparedForPrintPages() {
PrintPages();
FinishFramePrinting();
@ -1570,7 +1571,7 @@ void PrintWebViewHelper::PrintPages() {
void PrintWebViewHelper::FinishFramePrinting() {
prep_frame_view_.reset();
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
// static - Not anonymous so that platform implementations can use it.
void PrintWebViewHelper::ComputePageLayoutInPointsForCss(
@ -1651,7 +1652,7 @@ bool PrintWebViewHelper::CalculateNumberOfPages(blink::WebLocalFrame* frame,
return true;
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
bool PrintWebViewHelper::SetOptionsFromPdfDocument(
PrintHostMsg_SetOptionsFromDocument_Params* options) {
blink::WebLocalFrame* source_frame = print_preview_context_.source_frame();
@ -1760,9 +1761,9 @@ bool PrintWebViewHelper::UpdatePrintSettings(
return true;
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
bool PrintWebViewHelper::GetPrintSettingsFromUser(blink::WebLocalFrame* frame,
const blink::WebNode& node,
int expected_pages_count,
@ -1816,7 +1817,7 @@ bool PrintWebViewHelper::RenderPagesForPrint(blink::WebLocalFrame* frame,
base::Unretained(this)));
return true;
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
#if !defined(OS_MACOSX)
void PrintWebViewHelper::PrintPageInternal(
@ -1828,7 +1829,7 @@ void PrintWebViewHelper::PrintPageInternal(
PageSizeMargins page_layout_in_points;
double css_scale_factor = 1.0f;
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (params.params.scale_factor >= kEpsilon)
css_scale_factor = params.params.scale_factor;
#endif
@ -1874,7 +1875,7 @@ void PrintWebViewHelper::PrintPageInternal(
MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (params.params.display_header_footer) {
// TODO(thestig): Figure out why Linux needs this. It is almost certainly
// |printingMinimumShrinkFactor| from Blink.
@ -1889,7 +1890,7 @@ void PrintWebViewHelper::PrintPageInternal(
scale_factor / fudge_factor, page_layout_in_points,
params.params);
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
float webkit_scale_factor =
RenderPageContent(frame, params.page_number, canvas_area, content_area,
@ -1925,7 +1926,7 @@ bool PrintWebViewHelper::CopyMetafileDataToSharedMem(
return true;
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintWebViewHelper::ShowScriptedPrintPreview() {
if (is_scripted_preview_delayed_) {
is_scripted_preview_delayed_ = false;
@ -2053,7 +2054,7 @@ bool PrintWebViewHelper::PreviewPageRendered(int page_number,
Send(new PrintHostMsg_DidPreviewPage(routing_id(), preview_page_params));
return true;
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
PrintWebViewHelper::PrintPreviewContext::PrintPreviewContext()
: total_page_count_(0),

@ -17,6 +17,7 @@
#include "build/build_config.h"
#include "content/public/renderer/render_view_observer.h"
#include "content/public/renderer/render_view_observer_tracker.h"
#include "printing/features/features.h"
#include "printing/pdf_metafile_skia.h"
#include "third_party/WebKit/public/platform/WebCanvas.h"
#include "third_party/WebKit/public/web/WebNode.h"
@ -143,7 +144,7 @@ class PrintWebViewHelper
OK,
FAIL_PRINT_INIT,
FAIL_PRINT,
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
FAIL_PREVIEW,
#endif
};
@ -175,15 +176,15 @@ class PrintWebViewHelper
void OnDestruct() override;
// Message handlers ---------------------------------------------------------
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
void OnPrintPages();
void OnPrintForSystemDialog();
void OnPrintForPrintPreview(const base::DictionaryValue& job_settings);
#endif // defined(ENABLE_BASIC_PRINTING)
#if defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void OnInitiatePrintPreview(bool selection_only);
void OnPrintPreview(const base::DictionaryValue& settings);
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
void OnPrintingDone(bool success);
// Get |page_size| and |content_area| information from
@ -196,7 +197,7 @@ class PrintWebViewHelper
// Update |ignore_css_margins_| based on settings.
void UpdateFrameMarginsCssInfo(const base::DictionaryValue& settings);
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Prepare frame for creating preview document.
void PrepareFrameForPreviewDocument();
@ -213,7 +214,7 @@ class PrintWebViewHelper
// Finalize the print ready preview document.
bool FinalizePrintReadyDocument();
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Enable/Disable window.print calls. If |blocked| is true window.print
// calls will silently fail. Call with |blocked| set to false to reenable.
@ -221,12 +222,12 @@ class PrintWebViewHelper
// Main printing code -------------------------------------------------------
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// |is_scripted| should be true when the call is coming from window.print()
void Print(blink::WebLocalFrame* frame,
const blink::WebNode& node,
bool is_scripted);
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
// Notification when printing is done - signal tear-down/free resources.
void DidFinishPrinting(PrintingResult result);
@ -242,7 +243,7 @@ class PrintWebViewHelper
const blink::WebNode& node,
int* number_of_pages);
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Set options for print preset from source PDF document.
bool SetOptionsFromPdfDocument(
PrintHostMsg_SetOptionsFromDocument_Params* options);
@ -253,7 +254,7 @@ class PrintWebViewHelper
bool UpdatePrintSettings(blink::WebLocalFrame* frame,
const blink::WebNode& node,
const base::DictionaryValue& passed_job_settings);
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Get final print settings from the user.
// Return false if the user cancels or on error.
@ -264,7 +265,7 @@ class PrintWebViewHelper
// Page Printing / Rendering ------------------------------------------------
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
void OnFramePreparedForPrintPages();
void PrintPages();
bool PrintPagesNative(blink::WebLocalFrame* frame, int page_count);
@ -272,7 +273,7 @@ class PrintWebViewHelper
// Render the frame for printing.
bool RenderPagesForPrint(blink::WebLocalFrame* frame,
const blink::WebNode& node);
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
// Prints the page listed in |params|.
#if defined(OS_MACOSX)
@ -328,7 +329,7 @@ class PrintWebViewHelper
const PrintMsg_PrintPages_Params& params,
int page_count);
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Given the |device| and |canvas| to draw on, prints the appropriate headers
// and footers using strings from |header_footer_info| on to the canvas.
static void PrintHeaderAndFooter(blink::WebCanvas* canvas,
@ -338,7 +339,7 @@ class PrintWebViewHelper
float webkit_scale_factor,
const PageSizeMargins& page_layout_in_points,
const PrintMsg_Print_Params& params);
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
bool GetPrintFrame(blink::WebLocalFrame** frame);
@ -350,7 +351,7 @@ class PrintWebViewHelper
bool IsScriptInitiatedPrintAllowed(blink::WebFrame* frame,
bool user_initiated);
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Shows scripted print preview when options from plugin are available.
void ShowScriptedPrintPreview();
@ -366,7 +367,7 @@ class PrintWebViewHelper
// |metafile| is the rendered page. Otherwise |metafile| is NULL.
// Returns true if print preview should continue, false on failure.
bool PreviewPageRendered(int page_number, PdfMetafileSkia* metafile);
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
void SetPrintPagesParams(const PrintMsg_PrintPages_Params& settings);

@ -9,6 +9,7 @@
#include "base/logging.h"
#include "build/build_config.h"
#include "components/printing/common/print_messages.h"
#include "printing/features/features.h"
#include "printing/metafile_skia_wrapper.h"
#if defined(OS_ANDROID)
@ -42,7 +43,7 @@ bool SaveToFD(const printing::Metafile& metafile,
namespace printing {
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
int page_count) {
PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE);
@ -100,6 +101,6 @@ bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
return true;
#endif // defined(OS_ANDROID)
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
} // namespace printing

@ -10,6 +10,7 @@
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/metrics/histogram.h"
#include "components/printing/common/print_messages.h"
#include "printing/features/features.h"
#include "printing/metafile_skia_wrapper.h"
#include "printing/page_size_margins.h"
#include "third_party/WebKit/public/platform/WebCanvas.h"
@ -18,7 +19,7 @@
namespace printing {
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
int page_count) {
const PrintMsg_PrintPages_Params& params = *print_pages_params_;
@ -36,7 +37,7 @@ bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
}
return true;
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
void PrintWebViewHelper::PrintPageInternal(
const PrintMsg_PrintPage_Params& params,
@ -68,7 +69,7 @@ void PrintWebViewHelper::PrintPageInternal(
Send(new PrintHostMsg_DidPrintPage(routing_id(), page_params));
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
bool PrintWebViewHelper::RenderPreviewPage(
int page_number,
const PrintMsg_Print_Params& print_params) {
@ -105,7 +106,7 @@ bool PrintWebViewHelper::RenderPreviewPage(
}
return PreviewPageRendered(page_number, draft_metafile.get());
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params,
int page_number,
@ -141,14 +142,14 @@ void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params,
MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
skia::SetIsPreviewMetafile(*canvas, is_preview);
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (params.display_header_footer) {
PrintHeaderAndFooter(static_cast<blink::WebCanvas*>(canvas),
page_number + 1,
print_preview_context_.total_page_count(), *frame,
scale_factor, page_layout_in_points, params);
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
RenderPageContent(frame, page_number, canvas_area, content_area,
scale_factor, static_cast<blink::WebCanvas*>(canvas));
}

@ -9,11 +9,12 @@
#include "base/logging.h"
#include "base/process/process_handle.h"
#include "components/printing/common/print_messages.h"
#include "printing/features/features.h"
#include "printing/metafile_skia_wrapper.h"
namespace printing {
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
int page_count) {
const PrintMsg_PrintPages_Params& params = *print_pages_params_;
@ -66,6 +67,6 @@ bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
}
return true;
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
} // namespace printing

@ -12,16 +12,17 @@
#include "build/build_config.h"
#include "components/printing/test/mock_printer.h"
#include "ipc/ipc_sync_message.h"
#include "printing/features/features.h"
#include "printing/page_range.h"
#include "printing/print_job_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
#include "components/printing/common/print_messages.h"
#endif
PrintMockRenderThread::PrintMockRenderThread()
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
: printer_(new MockPrinter),
print_dialog_user_response_(true),
print_preview_cancel_page_number_(-1),
@ -50,7 +51,7 @@ bool PrintMockRenderThread::OnMessageReceived(const IPC::Message& msg) {
// Some messages we do special handling.
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PrintMockRenderThread, msg)
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
IPC_MESSAGE_HANDLER(PrintHostMsg_GetDefaultPrintSettings,
OnGetDefaultPrintSettings)
IPC_MESSAGE_HANDLER(PrintHostMsg_ScriptedPrint, OnScriptedPrint)
@ -58,19 +59,19 @@ bool PrintMockRenderThread::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount,
OnDidGetPrintedPagesCount)
IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintPage, OnDidPrintPage)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPreviewPageCount,
OnDidGetPreviewPageCount)
IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, OnDidPreviewPage)
IPC_MESSAGE_HANDLER(PrintHostMsg_CheckForCancel, OnCheckForCancel)
#endif
#endif // defined(ENABLE_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINTING)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
void PrintMockRenderThread::OnGetDefaultPrintSettings(
PrintMsg_Print_Params* params) {
@ -96,7 +97,7 @@ void PrintMockRenderThread::OnDidPrintPage(
printer_->PrintPage(params);
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintMockRenderThread::OnDidGetPreviewPageCount(
const PrintHostMsg_DidGetPreviewPageCount_Params& params) {
print_preview_pages_remaining_ = params.page_count;
@ -114,7 +115,7 @@ void PrintMockRenderThread::OnCheckForCancel(int32_t preview_ui_id,
*cancel =
(print_preview_pages_remaining_ == print_preview_cancel_page_number_);
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintMockRenderThread::OnUpdatePrintSettings(
int document_cookie,
@ -185,4 +186,4 @@ void PrintMockRenderThread::set_print_preview_cancel_page_number(int page) {
int PrintMockRenderThread::print_preview_pages_remaining() const {
return print_preview_pages_remaining_;
}
#endif // defined(ENABLE_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINTING)

@ -15,6 +15,7 @@
#include "base/single_thread_task_runner.h"
#include "build/build_config.h"
#include "content/public/test/mock_render_thread.h"
#include "printing/features/features.h"
namespace base {
class DictionaryValue;
@ -43,7 +44,7 @@ class PrintMockRenderThread : public content::MockRenderThread {
void set_io_task_runner(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
// Returns the pseudo-printer instance.
MockPrinter* printer();
@ -62,7 +63,7 @@ class PrintMockRenderThread : public content::MockRenderThread {
// Overrides base class implementation to add custom handling for print
bool OnMessageReceived(const IPC::Message& msg) override;
#if defined(ENABLE_PRINTING)
#if BUILDFLAG(ENABLE_PRINTING)
#if defined(OS_CHROMEOS) || defined(OS_ANDROID)
void OnAllocateTempFileForPrinting(int render_view_id,
base::FileDescriptor* renderer_fd,
@ -79,7 +80,7 @@ class PrintMockRenderThread : public content::MockRenderThread {
void OnDidGetPrintedPagesCount(int cookie, int number_pages);
void OnDidPrintPage(const PrintHostMsg_DidPrintPage_Params& params);
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void OnDidGetPreviewPageCount(
const PrintHostMsg_DidGetPreviewPageCount_Params& params);
void OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params& params);

@ -6,6 +6,7 @@
#include "base/memory/ptr_util.h"
#include "components/printing/renderer/print_web_view_helper.h"
#include "printing/features/features.h"
#include "third_party/WebKit/public/web/WebElement.h"
namespace printing {
@ -23,7 +24,7 @@ class PrintWebViewHelperDelegate : public PrintWebViewHelper::Delegate {
return blink::WebElement();
}
bool IsPrintPreviewEnabled() override {
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
return true;
#else
return false;

@ -21,6 +21,7 @@
#include "content/public/renderer/render_view.h"
#include "content/public/test/render_view_test.h"
#include "ipc/ipc_listener.h"
#include "printing/features/features.h"
#include "printing/print_job_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/platform/WebString.h"
@ -51,7 +52,7 @@ const char kPrintOnUserAction[] =
" <button id=\"print\" onclick=\"window.print();\">Hello World!</button>"
"</body>";
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// HTML with 3 pages.
const char kMultipageHTML[] =
"<html><head><style>"
@ -113,10 +114,10 @@ void CreatePrintSettingsDictionary(base::DictionaryValue* dict) {
dict->SetBoolean(kSettingShouldPrintBackgrounds, false);
dict->SetBoolean(kSettingShouldPrintSelectionOnly, false);
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // !defined(OS_CHROMEOS)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
class DidPreviewPageListener : public IPC::Listener {
public:
explicit DidPreviewPageListener(base::RunLoop* run_loop)
@ -134,7 +135,7 @@ class DidPreviewPageListener : public IPC::Listener {
base::RunLoop* const run_loop_;
DISALLOW_COPY_AND_ASSIGN(DidPreviewPageListener);
};
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
} // namespace
@ -191,7 +192,7 @@ class PrintWebViewHelperTestBase : public content::RenderViewTest {
#endif // defined(OS_CHROMEOS)
}
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// The renderer should be done calculating the number of rendered pages
// according to the specified settings defined in the mock render thread.
// Verify the page count is correct.
@ -205,7 +206,7 @@ class PrintWebViewHelperTestBase : public content::RenderViewTest {
&post_page_count_param);
EXPECT_EQ(count, std::get<0>(post_page_count_param).page_count);
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Verifies whether the pages printed or not.
void VerifyPagesPrinted(bool printed) {
@ -221,14 +222,14 @@ class PrintWebViewHelperTestBase : public content::RenderViewTest {
}
}
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
void OnPrintPages() {
PrintWebViewHelper::Get(view_)->OnPrintPages();
ProcessPendingMessages();
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void VerifyPreviewRequest(bool requested) {
const IPC::Message* print_msg =
render_thread_->sink().GetUniqueMessageMatching(
@ -247,14 +248,14 @@ class PrintWebViewHelperTestBase : public content::RenderViewTest {
run_loop.Run();
render_thread_->sink().RemoveFilter(&filter);
}
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
void OnPrintForPrintPreview(const base::DictionaryValue& dict) {
PrintWebViewHelper::Get(view_)->OnPrintForPrintPreview(dict);
ProcessPendingMessages();
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
// Naked pointer as ownership is with content::RenderViewTest::render_thread_.
PrintMockRenderThread* print_render_thread_;
@ -283,7 +284,7 @@ class MAYBE_PrintWebViewHelperTest : public PrintWebViewHelperTestBase {
};
// This tests only for platforms without print preview.
#if !defined(ENABLE_PRINT_PREVIEW)
#if !BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Tests that the renderer blocks window.print() calls if they occur too
// frequently.
TEST_F(MAYBE_PrintWebViewHelperTest, BlockScriptInitiatedPrinting) {
@ -354,9 +355,9 @@ TEST_F(MAYBE_PrintWebViewHelperTest, PrintWithJavascript) {
VerifyPageCount(1);
VerifyPagesPrinted(true);
}
#endif // !defined(ENABLE_PRINT_PREVIEW)
#endif // !BUILDFLAG(ENABLE_PRINT_PREVIEW)
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// Tests that printing pages work and sending and receiving messages through
// that channel all works.
TEST_F(MAYBE_PrintWebViewHelperTest, OnPrintPages) {
@ -366,9 +367,9 @@ TEST_F(MAYBE_PrintWebViewHelperTest, OnPrintPages) {
VerifyPageCount(1);
VerifyPagesPrinted(true);
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
#if defined(OS_MACOSX) && defined(ENABLE_BASIC_PRINTING)
#if defined(OS_MACOSX) && BUILDFLAG(ENABLE_BASIC_PRINTING)
// TODO(estade): I don't think this test is worth porting to Linux. We will have
// to rip out and replace most of the IPC code if we ever plan to improve
// printing, and the comment below by sverrir suggests that it doesn't do much
@ -426,7 +427,7 @@ struct TestPageData {
const wchar_t* file;
};
#if defined(OS_MACOSX) && defined(ENABLE_BASIC_PRINTING)
#if defined(OS_MACOSX) && BUILDFLAG(ENABLE_BASIC_PRINTING)
const TestPageData kTestPages[] = {
{
"<html>"
@ -446,14 +447,14 @@ const TestPageData kTestPages[] = {
600, 780, nullptr, nullptr,
},
};
#endif // defined(OS_MACOSX) && defined(ENABLE_BASIC_PRINTING)
#endif // defined(OS_MACOSX) && BUILDFLAG(ENABLE_BASIC_PRINTING)
} // namespace
// TODO(estade): need to port MockPrinter to get this on Linux. This involves
// hooking up Cairo to read a pdf stream, or accessing the cairo surface in the
// metafile directly.
// Same for printing via PDF on Windows.
#if defined(OS_MACOSX) && defined(ENABLE_BASIC_PRINTING)
#if defined(OS_MACOSX) && BUILDFLAG(ENABLE_BASIC_PRINTING)
TEST_F(MAYBE_PrintWebViewHelperTest, PrintLayoutTest) {
bool baseline = false;
@ -520,7 +521,7 @@ TEST_F(MAYBE_PrintWebViewHelperTest, PrintLayoutTest) {
#define MAYBE_PrintWebViewHelperPreviewTest PrintWebViewHelperPreviewTest
#endif // defined(OS_ANDROID)
#if defined(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
class MAYBE_PrintWebViewHelperPreviewTest : public PrintWebViewHelperTestBase {
public:
MAYBE_PrintWebViewHelperPreviewTest() {}
@ -947,7 +948,7 @@ TEST_F(MAYBE_PrintWebViewHelperPreviewTest, OnPrintPreviewCancel) {
VerifyPagesPrinted(false);
}
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// Tests that printing from print preview works and sending and receiving
// messages through that channel all works.
TEST_F(MAYBE_PrintWebViewHelperPreviewTest, OnPrintForPrintPreview) {
@ -973,7 +974,7 @@ TEST_F(MAYBE_PrintWebViewHelperPreviewTest, OnPrintForPrintPreviewFail) {
VerifyPagesPrinted(false);
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
// Tests that when default printer has invalid printer settings, print preview
// receives error message.
@ -1038,7 +1039,7 @@ TEST_F(MAYBE_PrintWebViewHelperPreviewTest,
VerifyPrintPreviewGenerated(false);
}
#if defined(ENABLE_BASIC_PRINTING)
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
TEST_F(MAYBE_PrintWebViewHelperPreviewTest,
OnPrintForPrintPreviewUsingInvalidPrinterSettings) {
LoadHTML(kPrintPreviewHTML);
@ -1054,8 +1055,8 @@ TEST_F(MAYBE_PrintWebViewHelperPreviewTest,
VerifyPrintFailed(true);
VerifyPagesPrinted(false);
}
#endif // defined(ENABLE_BASIC_PRINTING)
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // !defined(OS_CHROMEOS)

@ -22,6 +22,7 @@ static_library("renderer_context_menu") {
"//components/search_engines",
"//content/public/browser",
"//content/public/common",
"//printing/features",
"//third_party/WebKit/public:blink_headers",
"//ui/base",
]

@ -1,6 +1,7 @@
include_rules = [
"+content/public/browser",
"+content/public/common",
"+printing/features",
"+ui/base",
"+ui/gfx",
"+ui/views",

Some files were not shown because too many files have changed in this diff Show More