| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <fstream> | 8 #include <fstream> |
| 9 #include <iostream> | 9 #include <iostream> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 // |EndLoop| when an attempt to save the PDF has been made. | 202 // |EndLoop| when an attempt to save the PDF has been made. |
| 203 base::Closure end_loop_closure = | 203 base::Closure end_loop_closure = |
| 204 base::Bind(&PrintPreviewObserver::EndLoop, base::Unretained(this)); | 204 base::Bind(&PrintPreviewObserver::EndLoop, base::Unretained(this)); |
| 205 GetUI()->SetPdfSavedClosureForTesting(end_loop_closure); | 205 GetUI()->SetPdfSavedClosureForTesting(end_loop_closure); |
| 206 ASSERT_FALSE(pdf_file_save_path_.empty()); | 206 ASSERT_FALSE(pdf_file_save_path_.empty()); |
| 207 GetUI()->SetSelectedFileForTesting(pdf_file_save_path_); | 207 GetUI()->SetSelectedFileForTesting(pdf_file_save_path_); |
| 208 return; | 208 return; |
| 209 } | 209 } |
| 210 | 210 |
| 211 ASSERT_FALSE(script_argument.empty()); | 211 ASSERT_FALSE(script_argument.empty()); |
| 212 GetUI()->web_ui()->CallJavascriptFunctionUnsafe( | 212 GetUI()->SendManipulateSettingsForTest(script_argument); |
| 213 "onManipulateSettingsForTest", script_argument); | |
| 214 } | 213 } |
| 215 | 214 |
| 216 // Saves the print preview settings to be sent to the print preview dialog. | 215 // Saves the print preview settings to be sent to the print preview dialog. |
| 217 void SetPrintPreviewSettings(const PrintPreviewSettings& settings) { | 216 void SetPrintPreviewSettings(const PrintPreviewSettings& settings) { |
| 218 settings_ = base::MakeUnique<PrintPreviewSettings>(settings); | 217 settings_ = base::MakeUnique<PrintPreviewSettings>(settings); |
| 219 } | 218 } |
| 220 | 219 |
| 221 // Returns the setting that could not be set in the preview dialog. | 220 // Returns the setting that could not be set in the preview dialog. |
| 222 const std::string& GetFailedSetting() const { | 221 const std::string& GetFailedSetting() const { |
| 223 return failed_setting_; | 222 return failed_setting_; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 WebContents* web_contents = GetDialog(); | 275 WebContents* web_contents = GetDialog(); |
| 277 ASSERT_TRUE(web_contents); | 276 ASSERT_TRUE(web_contents); |
| 278 Observe(web_contents); | 277 Observe(web_contents); |
| 279 | 278 |
| 280 PrintPreviewUI* ui = GetUI(); | 279 PrintPreviewUI* ui = GetUI(); |
| 281 ASSERT_TRUE(ui); | 280 ASSERT_TRUE(ui); |
| 282 ASSERT_TRUE(ui->web_ui()); | 281 ASSERT_TRUE(ui->web_ui()); |
| 283 | 282 |
| 284 ui->web_ui()->AddMessageHandler( | 283 ui->web_ui()->AddMessageHandler( |
| 285 base::MakeUnique<UIDoneLoadingMessageHandler>(this)); | 284 base::MakeUnique<UIDoneLoadingMessageHandler>(this)); |
| 286 ui->web_ui()->CallJavascriptFunctionUnsafe( | 285 ui->SendEnableManipulateSettingsForTest(); |
| 287 "onEnableManipulateSettingsForTest"); | |
| 288 } | 286 } |
| 289 | 287 |
| 290 void DidCloneToNewWebContents(WebContents* old_web_contents, | 288 void DidCloneToNewWebContents(WebContents* old_web_contents, |
| 291 WebContents* new_web_contents) override { | 289 WebContents* new_web_contents) override { |
| 292 Observe(new_web_contents); | 290 Observe(new_web_contents); |
| 293 } | 291 } |
| 294 | 292 |
| 295 Browser* browser_; | 293 Browser* browser_; |
| 296 base::Closure quit_closure_; | 294 base::Closure quit_closure_; |
| 297 std::unique_ptr<PrintPreviewSettings> settings_; | 295 std::unique_ptr<PrintPreviewSettings> settings_; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 // waiting for this message and start waiting for the image data. | 630 // waiting for this message and start waiting for the image data. |
| 633 std::cout << "#EOF\n"; | 631 std::cout << "#EOF\n"; |
| 634 std::cout.flush(); | 632 std::cout.flush(); |
| 635 | 633 |
| 636 SendPng(); | 634 SendPng(); |
| 637 Reset(); | 635 Reset(); |
| 638 } | 636 } |
| 639 } | 637 } |
| 640 | 638 |
| 641 } // namespace printing | 639 } // namespace printing |
| OLD | NEW |