| 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 "chrome/browser/printing/print_preview_dialog_controller.h" | 5 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "components/printing/common/print_messages.h" | 31 #include "components/printing/common/print_messages.h" |
| 32 #include "content/public/browser/browser_accessibility_state.h" | 32 #include "content/public/browser/browser_accessibility_state.h" |
| 33 #include "content/public/browser/plugin_service.h" | 33 #include "content/public/browser/plugin_service.h" |
| 34 #include "content/public/browser/render_frame_host.h" | 34 #include "content/public/browser/render_frame_host.h" |
| 35 #include "content/public/browser/render_process_host.h" | 35 #include "content/public/browser/render_process_host.h" |
| 36 #include "content/public/browser/web_contents_observer.h" | 36 #include "content/public/browser/web_contents_observer.h" |
| 37 #include "content/public/test/browser_test_utils.h" | 37 #include "content/public/test/browser_test_utils.h" |
| 38 #include "ipc/ipc_message_macros.h" | 38 #include "ipc/ipc_message_macros.h" |
| 39 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
| 40 #include "url/gurl.h" | 40 #include "url/gurl.h" |
| 41 #include "url/origin.h" |
| 41 | 42 |
| 42 using content::WebContents; | 43 using content::WebContents; |
| 43 using content::WebContentsObserver; | 44 using content::WebContentsObserver; |
| 44 | 45 |
| 45 namespace { | 46 namespace { |
| 46 | 47 |
| 47 class RequestPrintPreviewObserver : public WebContentsObserver { | 48 class RequestPrintPreviewObserver : public WebContentsObserver { |
| 48 public: | 49 public: |
| 49 explicit RequestPrintPreviewObserver(WebContents* dialog) | 50 explicit RequestPrintPreviewObserver(WebContents* dialog) |
| 50 : WebContentsObserver(dialog) { | 51 : WebContentsObserver(dialog) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 content::RenderFrameHost* frame) { | 144 content::RenderFrameHost* frame) { |
| 144 ++(*frame_count); | 145 ++(*frame_count); |
| 145 } | 146 } |
| 146 | 147 |
| 147 void CheckPdfPluginForRenderFrame(content::RenderFrameHost* frame) { | 148 void CheckPdfPluginForRenderFrame(content::RenderFrameHost* frame) { |
| 148 content::WebPluginInfo pdf_plugin_info; | 149 content::WebPluginInfo pdf_plugin_info; |
| 149 ASSERT_TRUE(GetPdfPluginInfo(&pdf_plugin_info)); | 150 ASSERT_TRUE(GetPdfPluginInfo(&pdf_plugin_info)); |
| 150 | 151 |
| 151 ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance(); | 152 ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance(); |
| 152 EXPECT_TRUE(filter->IsPluginAvailable( | 153 EXPECT_TRUE(filter->IsPluginAvailable( |
| 153 frame->GetProcess()->GetID(), | 154 frame->GetProcess()->GetID(), frame->GetRoutingID(), nullptr, |
| 154 frame->GetRoutingID(), | 155 GURL(kDummyPrintUrl), url::Origin(), &pdf_plugin_info)); |
| 155 nullptr, | |
| 156 GURL(kDummyPrintUrl), | |
| 157 GURL(), | |
| 158 &pdf_plugin_info)); | |
| 159 } | 156 } |
| 160 | 157 |
| 161 } // namespace | 158 } // namespace |
| 162 | 159 |
| 163 class PrintPreviewDialogControllerBrowserTest : public InProcessBrowserTest { | 160 class PrintPreviewDialogControllerBrowserTest : public InProcessBrowserTest { |
| 164 public: | 161 public: |
| 165 PrintPreviewDialogControllerBrowserTest() : initiator_(nullptr) {} | 162 PrintPreviewDialogControllerBrowserTest() : initiator_(nullptr) {} |
| 166 ~PrintPreviewDialogControllerBrowserTest() override {} | 163 ~PrintPreviewDialogControllerBrowserTest() override {} |
| 167 | 164 |
| 168 WebContents* initiator() { | 165 WebContents* initiator() { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 base::Bind(&PluginEnabledCallback, run_loop.QuitClosure())); | 299 base::Bind(&PluginEnabledCallback, run_loop.QuitClosure())); |
| 303 run_loop.Run(); | 300 run_loop.Run(); |
| 304 } | 301 } |
| 305 | 302 |
| 306 // Make sure it is actually disabled for webpages. | 303 // Make sure it is actually disabled for webpages. |
| 307 ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance(); | 304 ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance(); |
| 308 content::WebPluginInfo dummy_pdf_plugin_info = pdf_plugin_info; | 305 content::WebPluginInfo dummy_pdf_plugin_info = pdf_plugin_info; |
| 309 EXPECT_FALSE(filter->IsPluginAvailable( | 306 EXPECT_FALSE(filter->IsPluginAvailable( |
| 310 initiator()->GetRenderProcessHost()->GetID(), | 307 initiator()->GetRenderProcessHost()->GetID(), |
| 311 initiator()->GetMainFrame()->GetRoutingID(), | 308 initiator()->GetMainFrame()->GetRoutingID(), |
| 312 browser()->profile()->GetResourceContext(), | 309 browser()->profile()->GetResourceContext(), GURL(), |
| 313 GURL("http://google.com"), | 310 url::Origin(GURL("http://google.com")), &dummy_pdf_plugin_info)); |
| 314 GURL(), | |
| 315 &dummy_pdf_plugin_info)); | |
| 316 | 311 |
| 317 PrintPreview(); | 312 PrintPreview(); |
| 318 | 313 |
| 319 // Check a new print preview dialog got created. | 314 // Check a new print preview dialog got created. |
| 320 WebContents* preview_dialog = GetPrintPreviewDialog(); | 315 WebContents* preview_dialog = GetPrintPreviewDialog(); |
| 321 ASSERT_TRUE(preview_dialog); | 316 ASSERT_TRUE(preview_dialog); |
| 322 ASSERT_NE(initiator(), preview_dialog); | 317 ASSERT_NE(initiator(), preview_dialog); |
| 323 | 318 |
| 324 // Wait until the <iframe> in the print preview renderer has loaded. | 319 // Wait until the <iframe> in the print preview renderer has loaded. |
| 325 // |frame_count| should be 2. The other frame is the main frame. | 320 // |frame_count| should be 2. The other frame is the main frame. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility(); | 396 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility(); |
| 402 ui_test_utils::NavigateToURL(browser(), GURL("data:text/html,HelloWorld")); | 397 ui_test_utils::NavigateToURL(browser(), GURL("data:text/html,HelloWorld")); |
| 403 PrintPreview(); | 398 PrintPreview(); |
| 404 WebContents* preview_dialog = GetPrintPreviewDialog(); | 399 WebContents* preview_dialog = GetPrintPreviewDialog(); |
| 405 WaitForAccessibilityTreeToContainNodeWithName(preview_dialog, "HelloWorld"); | 400 WaitForAccessibilityTreeToContainNodeWithName(preview_dialog, "HelloWorld"); |
| 406 } | 401 } |
| 407 | 402 |
| 408 } // namespace | 403 } // namespace |
| 409 | 404 |
| 410 #endif // defined(ENABLE_TASK_MANAGER) | 405 #endif // defined(ENABLE_TASK_MANAGER) |
| OLD | NEW |