Enabled system print dialog on Windows Aura.

Temprarily workaround that needs to be replaced by ui::BaseShellDialog.

BUG=180997

Review URL: https://chromiumcodereview.appspot.com/15817004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202696 0039d316-1c4b-4281-b951-d872f2087c98
parent 42bf7b4b
......@@ -2,6 +2,7 @@ include_rules = [
"+skia/ext",
"+third_party/icu",
"+third_party/skia",
"+ui/aura",
"+ui/base/text",
"+ui/gfx",
"+win8/util",
......
......@@ -97,6 +97,11 @@
['exclude', '.'],
],
}],
['use_aura==1', {
'dependencies': [
'<(DEPTH)/ui/aura/aura.gyp:aura',
],
}],
['toolkit_uses_gtk == 0',{
'sources/': [['exclude', '_cairo\\.cc$']]
}],
......@@ -132,10 +137,9 @@
'../win8/win8.gyp:win8_util',
],
'conditions': [
['use_aura==0', {
'sources': [
'printing_context_win.cc',
'printing_context_win.h',
['use_aura==1', {
'dependencies': [
'<(DEPTH)/ui/aura/aura.gyp:aura',
],
}]],
'defines': [
......@@ -147,12 +151,14 @@
'backend/win_helper.cc',
'backend/win_helper.h',
'backend/print_backend_win.cc',
'printing_context_win.cc',
'printing_context_win.h',
],
'sources!': [
'print_destination_none.cc',
],
}],
['chromeos==1 or use_aura==1',{
['chromeos==1 or (use_aura==1 and OS!="win")',{
'sources': [
'printing_context_no_system_dialog.cc',
'printing_context_no_system_dialog.h',
......
......@@ -26,6 +26,12 @@
#include "skia/ext/platform_device.h"
#include "win8/util/win8_util.h"
#if defined(USE_AURA)
#include "ui/aura/remote_root_window_host_win.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#endif
using base::Time;
namespace {
......@@ -45,6 +51,23 @@ const int kPDFA4Height = 11.69 * kPDFDpi;
const int kPDFA3Width = 11.69 * kPDFDpi;
const int kPDFA3Height = 16.54 * kPDFDpi;
HWND GetRootWindow(gfx::NativeView view) {
HWND window = NULL;
#if defined(USE_AURA)
if (view)
window = view->GetRootWindow()->GetAcceleratedWidget();
#else
if (view && IsWindow(view)) {
window = GetAncestor(view, GA_ROOTOWNER);
}
#endif
if (!window) {
// TODO(maruel): bug 1214347 Get the right browser window instead.
return GetDesktopWindow();
}
return window;
}
} // anonymous namespace
namespace printing {
......@@ -166,12 +189,11 @@ PrintingContextWin::~PrintingContextWin() {
ReleaseContext();
}
// TODO(vitalybuka): Implement as ui::BaseShellDialog crbug.com/180997.
void PrintingContextWin::AskUserForSettings(
gfx::NativeView view, int max_pages, bool has_selection,
const PrintSettingsCallback& callback) {
#if !defined(USE_AURA)
DCHECK(!in_print_job_);
if (win8::IsSingleWindowMetroMode()) {
// The system dialog can not be opened while running in Metro.
// But we can programatically launch the Metro print device charm though.
......@@ -192,13 +214,7 @@ void PrintingContextWin::AskUserForSettings(
}
dialog_box_dismissed_ = false;
HWND window;
if (!view || !IsWindow(view)) {
// TODO(maruel): bug 1214347 Get the right browser window instead.
window = GetDesktopWindow();
} else {
window = GetAncestor(view, GA_ROOTOWNER);
}
HWND window = GetRootWindow(view);
DCHECK(window);
// Show the OS-dependent dialog box.
......@@ -236,14 +252,14 @@ void PrintingContextWin::AskUserForSettings(
dialog_options.Flags |= PD_NOPAGENUMS;
}
if ((*print_dialog_func_)(&dialog_options) != S_OK) {
HRESULT hr = (*print_dialog_func_)(&dialog_options);
if (hr != S_OK) {
ResetSettings();
callback.Run(FAILED);
}
// TODO(maruel): Support PD_PRINTTOFILE.
callback.Run(ParseDialogResultEx(dialog_options));
#endif
}
PrintingContext::Result PrintingContextWin::UseDefaultSettings() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment