Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: chrome/browser/printing/print_preview_dialog_controller_browsertest.cc

Issue 2378573005: [HBD] Blanket BLOCK on all non-HTTP(s) and non-FILE URLs for Flash. (Closed)
Patch Set: fix one last test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 19 matching lines...) Expand all
30 #include "components/printing/common/print_messages.h" 30 #include "components/printing/common/print_messages.h"
31 #include "content/public/browser/browser_accessibility_state.h" 31 #include "content/public/browser/browser_accessibility_state.h"
32 #include "content/public/browser/plugin_service.h" 32 #include "content/public/browser/plugin_service.h"
33 #include "content/public/browser/render_frame_host.h" 33 #include "content/public/browser/render_frame_host.h"
34 #include "content/public/browser/render_process_host.h" 34 #include "content/public/browser/render_process_host.h"
35 #include "content/public/browser/web_contents_observer.h" 35 #include "content/public/browser/web_contents_observer.h"
36 #include "content/public/test/browser_test_utils.h" 36 #include "content/public/test/browser_test_utils.h"
37 #include "ipc/ipc_message_macros.h" 37 #include "ipc/ipc_message_macros.h"
38 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
39 #include "url/gurl.h" 39 #include "url/gurl.h"
40 #include "url/origin.h"
40 41
41 using content::WebContents; 42 using content::WebContents;
42 using content::WebContentsObserver; 43 using content::WebContentsObserver;
43 44
44 namespace { 45 namespace {
45 46
46 class RequestPrintPreviewObserver : public WebContentsObserver { 47 class RequestPrintPreviewObserver : public WebContentsObserver {
47 public: 48 public:
48 explicit RequestPrintPreviewObserver(WebContents* dialog) 49 explicit RequestPrintPreviewObserver(WebContents* dialog)
49 : WebContentsObserver(dialog) { 50 : WebContentsObserver(dialog) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 content::RenderFrameHost* frame) { 143 content::RenderFrameHost* frame) {
143 ++(*frame_count); 144 ++(*frame_count);
144 } 145 }
145 146
146 void CheckPdfPluginForRenderFrame(content::RenderFrameHost* frame) { 147 void CheckPdfPluginForRenderFrame(content::RenderFrameHost* frame) {
147 content::WebPluginInfo pdf_plugin_info; 148 content::WebPluginInfo pdf_plugin_info;
148 ASSERT_TRUE(GetPdfPluginInfo(&pdf_plugin_info)); 149 ASSERT_TRUE(GetPdfPluginInfo(&pdf_plugin_info));
149 150
150 ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance(); 151 ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance();
151 EXPECT_TRUE(filter->IsPluginAvailable( 152 EXPECT_TRUE(filter->IsPluginAvailable(
152 frame->GetProcess()->GetID(), 153 frame->GetProcess()->GetID(), frame->GetRoutingID(), nullptr,
153 frame->GetRoutingID(), 154 GURL(kDummyPrintUrl), url::Origin(), &pdf_plugin_info));
154 nullptr,
155 GURL(kDummyPrintUrl),
156 GURL(),
157 &pdf_plugin_info));
158 } 155 }
159 156
160 } // namespace 157 } // namespace
161 158
162 class PrintPreviewDialogControllerBrowserTest : public InProcessBrowserTest { 159 class PrintPreviewDialogControllerBrowserTest : public InProcessBrowserTest {
163 public: 160 public:
164 PrintPreviewDialogControllerBrowserTest() : initiator_(nullptr) {} 161 PrintPreviewDialogControllerBrowserTest() : initiator_(nullptr) {}
165 ~PrintPreviewDialogControllerBrowserTest() override {} 162 ~PrintPreviewDialogControllerBrowserTest() override {}
166 163
167 WebContents* initiator() { 164 WebContents* initiator() {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 base::Bind(&PluginEnabledCallback, run_loop.QuitClosure())); 297 base::Bind(&PluginEnabledCallback, run_loop.QuitClosure()));
301 run_loop.Run(); 298 run_loop.Run();
302 } 299 }
303 300
304 // Make sure it is actually disabled for webpages. 301 // Make sure it is actually disabled for webpages.
305 ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance(); 302 ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance();
306 content::WebPluginInfo dummy_pdf_plugin_info = pdf_plugin_info; 303 content::WebPluginInfo dummy_pdf_plugin_info = pdf_plugin_info;
307 EXPECT_FALSE(filter->IsPluginAvailable( 304 EXPECT_FALSE(filter->IsPluginAvailable(
308 initiator()->GetRenderProcessHost()->GetID(), 305 initiator()->GetRenderProcessHost()->GetID(),
309 initiator()->GetMainFrame()->GetRoutingID(), 306 initiator()->GetMainFrame()->GetRoutingID(),
310 browser()->profile()->GetResourceContext(), 307 browser()->profile()->GetResourceContext(), GURL(),
311 GURL("http://google.com"), 308 url::Origin(GURL("http://google.com")), &dummy_pdf_plugin_info));
312 GURL(),
313 &dummy_pdf_plugin_info));
314 309
315 PrintPreview(); 310 PrintPreview();
316 311
317 // Check a new print preview dialog got created. 312 // Check a new print preview dialog got created.
318 WebContents* preview_dialog = GetPrintPreviewDialog(); 313 WebContents* preview_dialog = GetPrintPreviewDialog();
319 ASSERT_TRUE(preview_dialog); 314 ASSERT_TRUE(preview_dialog);
320 ASSERT_NE(initiator(), preview_dialog); 315 ASSERT_NE(initiator(), preview_dialog);
321 316
322 // Wait until the <iframe> in the print preview renderer has loaded. 317 // Wait until the <iframe> in the print preview renderer has loaded.
323 // |frame_count| should be 2. The other frame is the main frame. 318 // |frame_count| should be 2. The other frame is the main frame.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility(); 394 content::BrowserAccessibilityState::GetInstance()->EnableAccessibility();
400 ui_test_utils::NavigateToURL(browser(), GURL("data:text/html,HelloWorld")); 395 ui_test_utils::NavigateToURL(browser(), GURL("data:text/html,HelloWorld"));
401 PrintPreview(); 396 PrintPreview();
402 WebContents* preview_dialog = GetPrintPreviewDialog(); 397 WebContents* preview_dialog = GetPrintPreviewDialog();
403 WaitForAccessibilityTreeToContainNodeWithName(preview_dialog, "HelloWorld"); 398 WaitForAccessibilityTreeToContainNodeWithName(preview_dialog, "HelloWorld");
404 } 399 }
405 400
406 } // namespace 401 } // namespace
407 402
408 #endif // defined(ENABLE_TASK_MANAGER) 403 #endif // defined(ENABLE_TASK_MANAGER)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698