| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind_helpers.h" | 5 #include "base/bind_helpers.h" |
| 6 #include "base/location.h" |
| 6 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/thread_task_runner_handle.h" |
| 9 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 12 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 10 #include "chrome/browser/plugins/plugin_prefs.h" | 13 #include "chrome/browser/plugins/plugin_prefs.h" |
| 11 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 14 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 12 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "chrome/common/chrome_content_client.h" | 18 #include "chrome/common/chrome_content_client.h" |
| 16 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 17 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
| 18 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 47 IPC_BEGIN_MESSAGE_MAP(RequestPrintPreviewObserver, message) | 50 IPC_BEGIN_MESSAGE_MAP(RequestPrintPreviewObserver, message) |
| 48 IPC_MESSAGE_HANDLER(PrintHostMsg_RequestPrintPreview, | 51 IPC_MESSAGE_HANDLER(PrintHostMsg_RequestPrintPreview, |
| 49 OnRequestPrintPreview) | 52 OnRequestPrintPreview) |
| 50 IPC_MESSAGE_UNHANDLED(break;) | 53 IPC_MESSAGE_UNHANDLED(break;) |
| 51 IPC_END_MESSAGE_MAP(); | 54 IPC_END_MESSAGE_MAP(); |
| 52 return false; // Report not handled so the real handler receives it. | 55 return false; // Report not handled so the real handler receives it. |
| 53 } | 56 } |
| 54 | 57 |
| 55 void OnRequestPrintPreview( | 58 void OnRequestPrintPreview( |
| 56 const PrintHostMsg_RequestPrintPreview_Params& /* params */) { | 59 const PrintHostMsg_RequestPrintPreview_Params& /* params */) { |
| 57 base::MessageLoop::current()->PostTask(FROM_HERE, quit_closure_); | 60 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_); |
| 58 } | 61 } |
| 59 | 62 |
| 60 base::Closure quit_closure_; | 63 base::Closure quit_closure_; |
| 61 | 64 |
| 62 DISALLOW_COPY_AND_ASSIGN(RequestPrintPreviewObserver); | 65 DISALLOW_COPY_AND_ASSIGN(RequestPrintPreviewObserver); |
| 63 }; | 66 }; |
| 64 | 67 |
| 65 class PrintPreviewDialogClonedObserver : public WebContentsObserver { | 68 class PrintPreviewDialogClonedObserver : public WebContentsObserver { |
| 66 public: | 69 public: |
| 67 explicit PrintPreviewDialogClonedObserver(WebContents* dialog) | 70 explicit PrintPreviewDialogClonedObserver(WebContents* dialog) |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 WebContents* preview_dialog = GetPrintPreviewDialog(); | 310 WebContents* preview_dialog = GetPrintPreviewDialog(); |
| 308 ASSERT_TRUE(preview_dialog); | 311 ASSERT_TRUE(preview_dialog); |
| 309 ASSERT_NE(initiator(), preview_dialog); | 312 ASSERT_NE(initiator(), preview_dialog); |
| 310 | 313 |
| 311 // Wait until the <iframe> in the print preview renderer has loaded. | 314 // Wait until the <iframe> in the print preview renderer has loaded. |
| 312 // |frame_count| should be 2. The other frame is the main frame. | 315 // |frame_count| should be 2. The other frame is the main frame. |
| 313 const int kExpectedFrameCount = 2; | 316 const int kExpectedFrameCount = 2; |
| 314 int frame_count; | 317 int frame_count; |
| 315 do { | 318 do { |
| 316 base::RunLoop run_loop; | 319 base::RunLoop run_loop; |
| 317 base::MessageLoop::current()->PostDelayedTask( | 320 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 318 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(1)); | 321 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(1)); |
| 319 run_loop.Run(); | 322 run_loop.Run(); |
| 320 | 323 |
| 321 frame_count = 0; | 324 frame_count = 0; |
| 322 preview_dialog->ForEachFrame( | 325 preview_dialog->ForEachFrame( |
| 323 base::Bind(&CountFrames, base::Unretained(&frame_count))); | 326 base::Bind(&CountFrames, base::Unretained(&frame_count))); |
| 324 } while (frame_count < kExpectedFrameCount); | 327 } while (frame_count < kExpectedFrameCount); |
| 325 ASSERT_EQ(kExpectedFrameCount, frame_count); | 328 ASSERT_EQ(kExpectedFrameCount, frame_count); |
| 326 | 329 |
| 327 // Make sure all the frames in the dialog has access to the PDF plugin. | 330 // Make sure all the frames in the dialog has access to the PDF plugin. |
| 328 preview_dialog->ForEachFrame(base::Bind(&CheckPdfPluginForRenderFrame)); | 331 preview_dialog->ForEachFrame(base::Bind(&CheckPdfPluginForRenderFrame)); |
| 329 } | 332 } |
| OLD | NEW |