| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/test/test_file_util.h" | 12 #include "base/test/test_file_util.h" |
| 13 #include "base/threading/simple_thread.h" | 13 #include "base/threading/simple_thread.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/printing/print_job.h" | 15 #include "chrome/browser/printing/print_job.h" |
| 16 #include "chrome/browser/printing/print_view_manager.h" | 16 #include "chrome/browser/printing/print_view_manager.h" |
| 17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_commands.h" | 18 #include "chrome/browser/ui/browser_commands.h" |
| 19 #include "chrome/browser/ui/browser_tabstrip.h" | 19 #include "chrome/browser/ui/browser_tabstrip.h" |
| 20 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
| 21 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 24 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
| 25 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 26 #include "content/public/browser/notification_observer.h" | 25 #include "content/public/browser/notification_observer.h" |
| 27 #include "content/public/browser/notification_registrar.h" | 26 #include "content/public/browser/notification_registrar.h" |
| 28 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 29 #include "net/test/test_server.h" | 28 #include "net/test/test_server.h" |
| 30 #include "printing/image.h" | 29 #include "printing/image.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 58 | 57 |
| 59 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 58 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 60 command_line->AppendSwitchPath(switches::kDebugPrint, emf_path_); | 59 command_line->AppendSwitchPath(switches::kDebugPrint, emf_path_); |
| 61 } | 60 } |
| 62 | 61 |
| 63 protected: | 62 protected: |
| 64 void PrintNowTab() { | 63 void PrintNowTab() { |
| 65 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, | 64 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, |
| 66 content::NotificationService::AllSources()); | 65 content::NotificationService::AllSources()); |
| 67 | 66 |
| 68 TabContents* tab = chrome::GetActiveTabContents(browser()); | 67 content::WebContents* web_contents = |
| 69 tab->print_view_manager()->PrintNow(); | 68 chrome::GetActiveWebContents(browser()); |
| 69 printing::PrintViewManager::FromWebContents(web_contents)->PrintNow(); |
| 70 content::RunMessageLoop(); | 70 content::RunMessageLoop(); |
| 71 registrar_.RemoveAll(); | 71 registrar_.RemoveAll(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual void Observe(int type, | 74 virtual void Observe(int type, |
| 75 const content::NotificationSource& source, | 75 const content::NotificationSource& source, |
| 76 const content::NotificationDetails& details) { | 76 const content::NotificationDetails& details) { |
| 77 DCHECK(type == chrome::NOTIFICATION_PRINT_JOB_EVENT); | 77 DCHECK(type == chrome::NOTIFICATION_PRINT_JOB_EVENT); |
| 78 switch (content::Details<printing::JobEventDetails>(details)->type()) { | 78 switch (content::Details<printing::JobEventDetails>(details)->type()) { |
| 79 case printing::JobEventDetails::JOB_DONE: { | 79 case printing::JobEventDetails::JOB_DONE: { |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 | 455 |
| 456 // Force a navigation elsewhere to verify that it's fine with it. | 456 // Force a navigation elsewhere to verify that it's fine with it. |
| 457 url = test_server()->GetURL("files/printing/test1.html"); | 457 url = test_server()->GetURL("files/printing/test1.html"); |
| 458 ui_test_utils::NavigateToURL(browser(), url); | 458 ui_test_utils::NavigateToURL(browser(), url); |
| 459 } | 459 } |
| 460 chrome::CloseWindow(browser()); | 460 chrome::CloseWindow(browser()); |
| 461 content::RunAllPendingInMessageLoop(); | 461 content::RunAllPendingInMessageLoop(); |
| 462 | 462 |
| 463 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; | 463 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; |
| 464 } | 464 } |
| OLD | NEW |