| 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_tab_controller.h" | 5 #include "chrome/browser/printing/print_preview_tab_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/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chrome_plugin_service_filter.h" | 15 #include "chrome/browser/chrome_plugin_service_filter.h" |
| 16 #include "chrome/browser/printing/print_view_manager.h" | 16 #include "chrome/browser/printing/print_view_manager.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
| 20 #include "chrome/browser/ui/browser_navigator.h" | 20 #include "chrome/browser/ui/browser_navigator.h" |
| 21 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
| 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 24 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | |
| 25 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" | 24 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" |
| 26 #include "chrome/browser/ui/webui/web_dialog_delegate.h" | |
| 27 #include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" | 25 #include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" |
| 28 #include "chrome/common/chrome_content_client.h" | 26 #include "chrome/common/chrome_content_client.h" |
| 29 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 30 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.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/render_process_host.h" | 35 #include "content/public/browser/render_process_host.h" |
| 38 #include "content/public/browser/render_view_host.h" | 36 #include "content/public/browser/render_view_host.h" |
| 39 #include "content/public/browser/web_contents.h" | 37 #include "content/public/browser/web_contents.h" |
| 40 #include "content/public/browser/web_contents_delegate.h" | 38 #include "content/public/browser/web_contents_delegate.h" |
| 39 #include "ui/web_dialogs/constrained_web_dialog_ui.h" |
| 40 #include "ui/web_dialogs/web_dialog_delegate.h" |
| 41 #include "webkit/plugins/webplugininfo.h" | 41 #include "webkit/plugins/webplugininfo.h" |
| 42 | 42 |
| 43 using content::NativeWebKeyboardEvent; | 43 using content::NativeWebKeyboardEvent; |
| 44 using content::NavigationController; | 44 using content::NavigationController; |
| 45 using content::WebContents; | 45 using content::WebContents; |
| 46 using content::WebUIMessageHandler; | 46 using content::WebUIMessageHandler; |
| 47 using ui::ConstrainedWebDialogDelegate; |
| 48 using ui::WebDialogDelegate; |
| 47 | 49 |
| 48 namespace { | 50 namespace { |
| 49 | 51 |
| 50 void EnableInternalPDFPluginForTab(TabContentsWrapper* preview_tab) { | 52 void EnableInternalPDFPluginForTab(TabContentsWrapper* preview_tab) { |
| 51 // Always enable the internal PDF plugin for the print preview page. | 53 // Always enable the internal PDF plugin for the print preview page. |
| 52 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( | 54 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( |
| 53 preview_tab->web_contents()->GetRenderProcessHost()->GetID(), | 55 preview_tab->web_contents()->GetRenderProcessHost()->GetID(), |
| 54 preview_tab->web_contents()->GetRenderViewHost()->GetRoutingID(), | 56 preview_tab->web_contents()->GetRenderViewHost()->GetRoutingID(), |
| 55 GURL(), | 57 GURL(), |
| 56 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); | 58 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 429 |
| 428 // |web_dialog_ui_delegate| deletes itself in | 430 // |web_dialog_ui_delegate| deletes itself in |
| 429 // PrintPreviewTabDelegate::OnDialogClosed(). | 431 // PrintPreviewTabDelegate::OnDialogClosed(). |
| 430 WebDialogDelegate* web_dialog_delegate = | 432 WebDialogDelegate* web_dialog_delegate = |
| 431 new PrintPreviewTabDelegate(initiator_tab); | 433 new PrintPreviewTabDelegate(initiator_tab); |
| 432 // |web_tab_content_delegate|'s owner is |constrained_web_ui_delegate|. | 434 // |web_tab_content_delegate|'s owner is |constrained_web_ui_delegate|. |
| 433 PrintPreviewWebContentDelegate* pp_wcd = | 435 PrintPreviewWebContentDelegate* pp_wcd = |
| 434 new PrintPreviewWebContentDelegate(current_browser->profile(), | 436 new PrintPreviewWebContentDelegate(current_browser->profile(), |
| 435 initiator_tab); | 437 initiator_tab); |
| 436 ConstrainedWebDialogDelegate* constrained_delegate = | 438 ConstrainedWebDialogDelegate* constrained_delegate = |
| 437 ConstrainedWebDialogUI::CreateConstrainedWebDialog( | 439 ui::CreateConstrainedWebDialog( |
| 438 current_browser->profile(), | 440 current_browser->profile(), |
| 439 web_dialog_delegate, | 441 web_dialog_delegate, |
| 440 pp_wcd, | 442 pp_wcd, |
| 441 initiator_tab); | 443 initiator_tab); |
| 442 TabContentsWrapper* preview_tab = constrained_delegate->tab(); | 444 TabContentsWrapper* preview_tab = constrained_delegate->tab(); |
| 443 EnableInternalPDFPluginForTab(preview_tab); | 445 EnableInternalPDFPluginForTab(preview_tab); |
| 444 | 446 |
| 445 // Add an entry to the map. | 447 // Add an entry to the map. |
| 446 preview_tab_map_[preview_tab] = initiator_tab; | 448 preview_tab_map_[preview_tab] = initiator_tab; |
| 447 waiting_for_new_preview_page_ = true; | 449 waiting_for_new_preview_page_ = true; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( | 542 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( |
| 541 preview_tab->web_contents()->GetWebUI()->GetController()); | 543 preview_tab->web_contents()->GetWebUI()->GetController()); |
| 542 if (print_preview_ui) | 544 if (print_preview_ui) |
| 543 print_preview_ui->OnTabDestroyed(); | 545 print_preview_ui->OnTabDestroyed(); |
| 544 | 546 |
| 545 preview_tab_map_.erase(preview_tab); | 547 preview_tab_map_.erase(preview_tab); |
| 546 RemoveObservers(preview_tab); | 548 RemoveObservers(preview_tab); |
| 547 } | 549 } |
| 548 | 550 |
| 549 } // namespace printing | 551 } // namespace printing |
| OLD | NEW |