| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 // |EndLoop| when an attempt to save the PDF has been made. | 200 // |EndLoop| when an attempt to save the PDF has been made. |
| 201 base::Closure end_loop_closure = | 201 base::Closure end_loop_closure = |
| 202 base::Bind(&PrintPreviewObserver::EndLoop, base::Unretained(this)); | 202 base::Bind(&PrintPreviewObserver::EndLoop, base::Unretained(this)); |
| 203 GetUI()->SetPdfSavedClosureForTesting(end_loop_closure); | 203 GetUI()->SetPdfSavedClosureForTesting(end_loop_closure); |
| 204 ASSERT_FALSE(pdf_file_save_path_.empty()); | 204 ASSERT_FALSE(pdf_file_save_path_.empty()); |
| 205 GetUI()->SetSelectedFileForTesting(pdf_file_save_path_); | 205 GetUI()->SetSelectedFileForTesting(pdf_file_save_path_); |
| 206 return; | 206 return; |
| 207 } | 207 } |
| 208 | 208 |
| 209 ASSERT_FALSE(script_argument.empty()); | 209 ASSERT_FALSE(script_argument.empty()); |
| 210 GetUI()->web_ui()->CallJavascriptFunction( | 210 GetUI()->web_ui()->CallJavascriptFunctionUnsafe( |
| 211 "onManipulateSettingsForTest", script_argument); | 211 "onManipulateSettingsForTest", script_argument); |
| 212 } | 212 } |
| 213 | 213 |
| 214 // Saves the print preview settings to be sent to the print preview dialog. | 214 // Saves the print preview settings to be sent to the print preview dialog. |
| 215 void SetPrintPreviewSettings(const PrintPreviewSettings& settings) { | 215 void SetPrintPreviewSettings(const PrintPreviewSettings& settings) { |
| 216 settings_.reset(new PrintPreviewSettings(settings)); | 216 settings_.reset(new PrintPreviewSettings(settings)); |
| 217 } | 217 } |
| 218 | 218 |
| 219 // Returns the setting that could not be set in the preview dialog. | 219 // Returns the setting that could not be set in the preview dialog. |
| 220 const std::string& GetFailedSetting() const { | 220 const std::string& GetFailedSetting() const { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 WebContents* web_contents = GetDialog(); | 274 WebContents* web_contents = GetDialog(); |
| 275 ASSERT_TRUE(web_contents); | 275 ASSERT_TRUE(web_contents); |
| 276 Observe(web_contents); | 276 Observe(web_contents); |
| 277 | 277 |
| 278 PrintPreviewUI* ui = GetUI(); | 278 PrintPreviewUI* ui = GetUI(); |
| 279 ASSERT_TRUE(ui); | 279 ASSERT_TRUE(ui); |
| 280 ASSERT_TRUE(ui->web_ui()); | 280 ASSERT_TRUE(ui->web_ui()); |
| 281 | 281 |
| 282 // The |ui->web_ui()| owns the message handler. | 282 // The |ui->web_ui()| owns the message handler. |
| 283 ui->web_ui()->AddMessageHandler(new UIDoneLoadingMessageHandler(this)); | 283 ui->web_ui()->AddMessageHandler(new UIDoneLoadingMessageHandler(this)); |
| 284 ui->web_ui()->CallJavascriptFunction("onEnableManipulateSettingsForTest"); | 284 ui->web_ui()->CallJavascriptFunctionUnsafe( |
| 285 "onEnableManipulateSettingsForTest"); |
| 285 } | 286 } |
| 286 | 287 |
| 287 void DidCloneToNewWebContents(WebContents* old_web_contents, | 288 void DidCloneToNewWebContents(WebContents* old_web_contents, |
| 288 WebContents* new_web_contents) override { | 289 WebContents* new_web_contents) override { |
| 289 Observe(new_web_contents); | 290 Observe(new_web_contents); |
| 290 } | 291 } |
| 291 | 292 |
| 292 Browser* browser_; | 293 Browser* browser_; |
| 293 base::Closure quit_closure_; | 294 base::Closure quit_closure_; |
| 294 std::unique_ptr<PrintPreviewSettings> settings_; | 295 std::unique_ptr<PrintPreviewSettings> settings_; |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 // waiting for this message and start waiting for the image data. | 639 // waiting for this message and start waiting for the image data. |
| 639 std::cout << "#EOF\n"; | 640 std::cout << "#EOF\n"; |
| 640 std::cout.flush(); | 641 std::cout.flush(); |
| 641 | 642 |
| 642 SendPng(); | 643 SendPng(); |
| 643 Reset(); | 644 Reset(); |
| 644 } | 645 } |
| 645 } | 646 } |
| 646 | 647 |
| 647 } // namespace printing | 648 } // namespace printing |
| OLD | NEW |