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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "chrome/common/chrome_content_client.h" | 27 #include "chrome/common/chrome_content_client.h" |
28 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
30 #include "components/web_modal/web_contents_modal_dialog_host.h" | 30 #include "components/web_modal/web_contents_modal_dialog_host.h" |
31 #include "content/public/browser/navigation_controller.h" | 31 #include "content/public/browser/navigation_controller.h" |
32 #include "content/public/browser/navigation_details.h" | 32 #include "content/public/browser/navigation_details.h" |
33 #include "content/public/browser/navigation_entry.h" | 33 #include "content/public/browser/navigation_entry.h" |
34 #include "content/public/browser/notification_details.h" | 34 #include "content/public/browser/notification_details.h" |
35 #include "content/public/browser/notification_source.h" | 35 #include "content/public/browser/notification_source.h" |
36 #include "content/public/browser/plugin_service.h" | 36 #include "content/public/browser/plugin_service.h" |
| 37 #include "content/public/browser/render_frame_host.h" |
37 #include "content/public/browser/render_process_host.h" | 38 #include "content/public/browser/render_process_host.h" |
38 #include "content/public/browser/render_view_host.h" | 39 #include "content/public/browser/render_view_host.h" |
39 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
40 #include "content/public/browser/web_contents_delegate.h" | 41 #include "content/public/browser/web_contents_delegate.h" |
41 #include "content/public/browser/web_contents_view.h" | 42 #include "content/public/browser/web_contents_view.h" |
42 #include "content/public/common/webplugininfo.h" | 43 #include "content/public/common/webplugininfo.h" |
43 #include "ui/web_dialogs/web_dialog_delegate.h" | 44 #include "ui/web_dialogs/web_dialog_delegate.h" |
44 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" | 45 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" |
45 | 46 |
46 using content::NativeWebKeyboardEvent; | 47 using content::NativeWebKeyboardEvent; |
47 using content::NavigationController; | 48 using content::NavigationController; |
48 using content::WebContents; | 49 using content::WebContents; |
49 using content::WebUIMessageHandler; | 50 using content::WebUIMessageHandler; |
50 using ui::WebDialogDelegate; | 51 using ui::WebDialogDelegate; |
51 using ui::WebDialogWebContentsDelegate; | 52 using ui::WebDialogWebContentsDelegate; |
52 | 53 |
53 namespace { | 54 namespace { |
54 | 55 |
55 void EnableInternalPDFPluginForContents(WebContents* preview_dialog) { | 56 void EnableInternalPDFPluginForContents(WebContents* preview_dialog) { |
56 // Always enable the internal PDF plugin for the print preview page. | 57 // Always enable the internal PDF plugin for the print preview page. |
57 base::FilePath pdf_plugin_path; | 58 base::FilePath pdf_plugin_path; |
58 if (!PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_plugin_path)) | 59 if (!PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_plugin_path)) |
59 return; | 60 return; |
60 | 61 |
61 content::WebPluginInfo pdf_plugin; | 62 content::WebPluginInfo pdf_plugin; |
62 if (!content::PluginService::GetInstance()->GetPluginInfoByPath( | 63 if (!content::PluginService::GetInstance()->GetPluginInfoByPath( |
63 pdf_plugin_path, &pdf_plugin)) | 64 pdf_plugin_path, &pdf_plugin)) |
64 return; | 65 return; |
65 | 66 |
66 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( | 67 ChromePluginServiceFilter::GetInstance()->OverridePluginForFrame( |
67 preview_dialog->GetRenderProcessHost()->GetID(), | 68 preview_dialog->GetRenderProcessHost()->GetID(), |
68 preview_dialog->GetRenderViewHost()->GetRoutingID(), | 69 preview_dialog->GetMainFrame()->GetRoutingID(), |
69 GURL(), pdf_plugin); | 70 GURL(), pdf_plugin); |
70 } | 71 } |
71 | 72 |
72 // WebDialogDelegate that specifies what the print preview dialog | 73 // WebDialogDelegate that specifies what the print preview dialog |
73 // will look like. | 74 // will look like. |
74 class PrintPreviewDialogDelegate : public WebDialogDelegate { | 75 class PrintPreviewDialogDelegate : public WebDialogDelegate { |
75 public: | 76 public: |
76 explicit PrintPreviewDialogDelegate(WebContents* initiator); | 77 explicit PrintPreviewDialogDelegate(WebContents* initiator); |
77 virtual ~PrintPreviewDialogDelegate(); | 78 virtual ~PrintPreviewDialogDelegate(); |
78 | 79 |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 PrintPreviewUI* print_preview_ui = | 508 PrintPreviewUI* print_preview_ui = |
508 static_cast<PrintPreviewUI*>(preview_dialog->GetWebUI()->GetController()); | 509 static_cast<PrintPreviewUI*>(preview_dialog->GetWebUI()->GetController()); |
509 if (print_preview_ui) | 510 if (print_preview_ui) |
510 print_preview_ui->OnPrintPreviewDialogDestroyed(); | 511 print_preview_ui->OnPrintPreviewDialogDestroyed(); |
511 | 512 |
512 preview_dialog_map_.erase(preview_dialog); | 513 preview_dialog_map_.erase(preview_dialog); |
513 RemoveObservers(preview_dialog); | 514 RemoveObservers(preview_dialog); |
514 } | 515 } |
515 | 516 |
516 } // namespace printing | 517 } // namespace printing |
OLD | NEW |