OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "printing/printing_context.h" | 5 #include "printing/printing_context.h" |
6 | 6 |
7 #include <winspool.h> | 7 #include <winspool.h> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/i18n/file_util_icu.h" | 10 #include "base/i18n/file_util_icu.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 dialog_box_dismissed_(false), | 145 dialog_box_dismissed_(false), |
146 in_print_job_(false), | 146 in_print_job_(false), |
147 abort_printing_(false) { | 147 abort_printing_(false) { |
148 } | 148 } |
149 | 149 |
150 PrintingContext::~PrintingContext() { | 150 PrintingContext::~PrintingContext() { |
151 ResetSettings(); | 151 ResetSettings(); |
152 } | 152 } |
153 | 153 |
154 PrintingContext::Result PrintingContext::AskUserForSettings( | 154 PrintingContext::Result PrintingContext::AskUserForSettings( |
155 HWND window, | 155 HWND view, |
156 int max_pages, | 156 int max_pages, |
157 bool has_selection) { | 157 bool has_selection) { |
158 DCHECK(window); | |
159 DCHECK(!in_print_job_); | 158 DCHECK(!in_print_job_); |
160 dialog_box_dismissed_ = false; | 159 dialog_box_dismissed_ = false; |
| 160 |
| 161 HWND window; |
| 162 if (!view || !IsWindow(view)) { |
| 163 // TODO(maruel): bug 1214347 Get the right browser window instead. |
| 164 window = GetDesktopWindow(); |
| 165 } else { |
| 166 window = GetAncestor(view, GA_ROOTOWNER); |
| 167 } |
| 168 DCHECK(window); |
| 169 |
161 // Show the OS-dependent dialog box. | 170 // Show the OS-dependent dialog box. |
162 // If the user press | 171 // If the user press |
163 // - OK, the settings are reset and reinitialized with the new settings. OK is | 172 // - OK, the settings are reset and reinitialized with the new settings. OK is |
164 // returned. | 173 // returned. |
165 // - Apply then Cancel, the settings are reset and reinitialized with the new | 174 // - Apply then Cancel, the settings are reset and reinitialized with the new |
166 // settings. CANCEL is returned. | 175 // settings. CANCEL is returned. |
167 // - Cancel, the settings are not changed, the previous setting, if it was | 176 // - Cancel, the settings are not changed, the previous setting, if it was |
168 // initialized before, are kept. CANCEL is returned. | 177 // initialized before, are kept. CANCEL is returned. |
169 // On failure, the settings are reset and FAILED is returned. | 178 // On failure, the settings are reset and FAILED is returned. |
170 PRINTDLGEX dialog_options = { sizeof(PRINTDLGEX) }; | 179 PRINTDLGEX dialog_options = { sizeof(PRINTDLGEX) }; |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 | 610 |
602 if (dialog_options.hDevMode != NULL) | 611 if (dialog_options.hDevMode != NULL) |
603 GlobalFree(dialog_options.hDevMode); | 612 GlobalFree(dialog_options.hDevMode); |
604 if (dialog_options.hDevNames != NULL) | 613 if (dialog_options.hDevNames != NULL) |
605 GlobalFree(dialog_options.hDevNames); | 614 GlobalFree(dialog_options.hDevNames); |
606 | 615 |
607 return context_ ? OK : FAILED; | 616 return context_ ? OK : FAILED; |
608 } | 617 } |
609 | 618 |
610 } // namespace printing | 619 } // namespace printing |
OLD | NEW |