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

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

Issue 1022673002: Enable PDF plugin for iframes within the print preview dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better comments Created 5 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/printing/print_preview_dialog_controller_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" 16 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
17 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
18 #include "chrome/browser/printing/print_view_manager.h" 17 #include "chrome/browser/printing/print_view_manager.h"
19 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_finder.h" 19 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/browser/ui/browser_navigator.h" 20 #include "chrome/browser/ui/browser_navigator.h"
22 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/browser/ui/host_desktop.h" 22 #include "chrome/browser/ui/host_desktop.h"
24 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" 23 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
25 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" 24 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
26 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" 25 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
27 #include "chrome/common/chrome_content_client.h"
28 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
29 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
30 #include "components/web_modal/web_contents_modal_dialog_host.h" 28 #include "components/web_modal/web_contents_modal_dialog_host.h"
31 #include "content/public/browser/host_zoom_map.h" 29 #include "content/public/browser/host_zoom_map.h"
32 #include "content/public/browser/navigation_controller.h" 30 #include "content/public/browser/navigation_controller.h"
33 #include "content/public/browser/navigation_details.h" 31 #include "content/public/browser/navigation_details.h"
34 #include "content/public/browser/navigation_entry.h" 32 #include "content/public/browser/navigation_entry.h"
35 #include "content/public/browser/notification_details.h" 33 #include "content/public/browser/notification_details.h"
36 #include "content/public/browser/notification_source.h" 34 #include "content/public/browser/notification_source.h"
37 #include "content/public/browser/plugin_service.h"
38 #include "content/public/browser/render_frame_host.h"
39 #include "content/public/browser/render_process_host.h"
40 #include "content/public/browser/render_view_host.h" 35 #include "content/public/browser/render_view_host.h"
41 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
42 #include "content/public/browser/web_contents_delegate.h" 37 #include "content/public/browser/web_contents_delegate.h"
43 #include "content/public/common/webplugininfo.h"
44 #include "extensions/browser/guest_view/guest_view_base.h" 38 #include "extensions/browser/guest_view/guest_view_base.h"
45 #include "ui/web_dialogs/web_dialog_delegate.h" 39 #include "ui/web_dialogs/web_dialog_delegate.h"
46 40
47 using content::NavigationController; 41 using content::NavigationController;
48 using content::WebContents; 42 using content::WebContents;
49 using content::WebUIMessageHandler; 43 using content::WebUIMessageHandler;
50 44
51 namespace { 45 namespace {
52 46
53 void EnableInternalPDFPluginForContents(WebContents* preview_dialog) {
54 // Always enable the internal PDF plugin for the print preview page.
55 base::FilePath pdf_plugin_path = base::FilePath::FromUTF8Unsafe(
56 ChromeContentClient::kPDFPluginPath);
57
58 content::WebPluginInfo pdf_plugin;
59 if (!content::PluginService::GetInstance()->GetPluginInfoByPath(
60 pdf_plugin_path, &pdf_plugin))
61 return;
62
63 ChromePluginServiceFilter::GetInstance()->OverridePluginForFrame(
64 preview_dialog->GetRenderProcessHost()->GetID(),
65 preview_dialog->GetMainFrame()->GetRoutingID(),
66 GURL(), pdf_plugin);
67 }
68
69 // A ui::WebDialogDelegate that specifies the print preview dialog appearance. 47 // A ui::WebDialogDelegate that specifies the print preview dialog appearance.
70 class PrintPreviewDialogDelegate : public ui::WebDialogDelegate { 48 class PrintPreviewDialogDelegate : public ui::WebDialogDelegate {
71 public: 49 public:
72 explicit PrintPreviewDialogDelegate(WebContents* initiator); 50 explicit PrintPreviewDialogDelegate(WebContents* initiator);
73 ~PrintPreviewDialogDelegate() override; 51 ~PrintPreviewDialogDelegate() override;
74 52
75 ui::ModalType GetDialogModalType() const override; 53 ui::ModalType GetDialogModalType() const override;
76 base::string16 GetDialogTitle() const override; 54 base::string16 GetDialogTitle() const override;
77 GURL GetDialogContentURL() const override; 55 GURL GetDialogContentURL() const override;
78 void GetWebUIMessageHandlers( 56 void GetWebUIMessageHandlers(
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 initiator); 362 initiator);
385 363
386 WebContents* preview_dialog = web_dialog_delegate->GetWebContents(); 364 WebContents* preview_dialog = web_dialog_delegate->GetWebContents();
387 365
388 // Clear the zoom level for the print preview dialog so it isn't affected by 366 // Clear the zoom level for the print preview dialog so it isn't affected by
389 // the default zoom level. This also controls the zoom level of the OOP PDF 367 // the default zoom level. This also controls the zoom level of the OOP PDF
390 // extension when iframed by the print preview dialog. 368 // extension when iframed by the print preview dialog.
391 GURL print_url(chrome::kChromeUIPrintURL); 369 GURL print_url(chrome::kChromeUIPrintURL);
392 content::HostZoomMap::Get(preview_dialog->GetSiteInstance()) 370 content::HostZoomMap::Get(preview_dialog->GetSiteInstance())
393 ->SetZoomLevelForHostAndScheme(print_url.scheme(), print_url.host(), 0); 371 ->SetZoomLevelForHostAndScheme(print_url.scheme(), print_url.host(), 0);
394 EnableInternalPDFPluginForContents(preview_dialog);
395 PrintViewManager::CreateForWebContents(preview_dialog); 372 PrintViewManager::CreateForWebContents(preview_dialog);
396 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( 373 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
397 preview_dialog); 374 preview_dialog);
398 375
399 // Add an entry to the map. 376 // Add an entry to the map.
400 preview_dialog_map_[preview_dialog] = initiator; 377 preview_dialog_map_[preview_dialog] = initiator;
401 waiting_for_new_preview_page_ = true; 378 waiting_for_new_preview_page_ = true;
402 379
403 AddObservers(initiator); 380 AddObservers(initiator);
404 AddObservers(preview_dialog); 381 AddObservers(preview_dialog);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 static_cast<PrintPreviewUI*>(web_ui->GetController()); 465 static_cast<PrintPreviewUI*>(web_ui->GetController());
489 if (print_preview_ui) 466 if (print_preview_ui)
490 print_preview_ui->OnPrintPreviewDialogDestroyed(); 467 print_preview_ui->OnPrintPreviewDialogDestroyed();
491 } 468 }
492 469
493 preview_dialog_map_.erase(preview_dialog); 470 preview_dialog_map_.erase(preview_dialog);
494 RemoveObservers(preview_dialog); 471 RemoveObservers(preview_dialog);
495 } 472 }
496 473
497 } // namespace printing 474 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/printing/print_preview_dialog_controller_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698