Chromium Code Reviews| Index: chrome/browser/ui/browser.cc |
| diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc |
| index b92d4094b1ed9162f45703387239297573ed48db..98e2619d25efc74bc381fcba9a15f254eb51fb5e 100644 |
| --- a/chrome/browser/ui/browser.cc |
| +++ b/chrome/browser/ui/browser.cc |
| @@ -26,6 +26,7 @@ |
| #include "base/threading/thread_restrictions.h" |
| #include "base/time.h" |
| #include "base/utf_string_conversions.h" |
| +#include "base/win/metro.h" |
|
Albert Bodenhamer
2012/06/15 18:41:24
Safe to include this here?
MAD
2012/06/19 14:24:10
Right, I need to wrap it within #if defined (OS_WI
MAD
2012/06/28 15:48:14
Done.
|
| #include "chrome/app/chrome_command_ids.h" |
| #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| #include "chrome/browser/background/background_contents_service.h" |
| @@ -179,6 +180,7 @@ |
| #include "net/base/registry_controlled_domain.h" |
| #include "net/cookies/cookie_monster.h" |
| #include "net/url_request/url_request_context.h" |
| +#include "printing/printed_document.h" |
| #include "ui/base/animation/animation.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/gfx/point.h" |
| @@ -1616,6 +1618,47 @@ void Browser::AdvancedPrint() { |
| GetActiveTabContents()->print_view_manager()->AdvancedPrintNow(); |
| } |
| +void Browser::PrintToDelegate() { |
|
Albert Bodenhamer
2012/06/15 18:41:24
Does this need to live in browser? If you pull Me
MAD
2012/06/19 14:24:10
Good point, will move it to a more sensible place.
MAD
2012/06/28 15:48:14
Actually, I would look the interface pointer to co
|
| + scoped_refptr<printing::PrintedDocument::Delegate> printed_document_delegate; |
| +#if defined(OS_WIN) |
| + class MetroPrintingDelegate : public printing::PrintedDocument::Delegate { |
|
Albert Bodenhamer
2012/06/15 18:41:24
Pull this into its own .cc/.h
MAD
2012/06/19 14:24:10
Yep, will do...
MAD
2012/06/28 15:48:14
Done.
|
| + public: |
| + MetroPrintingDelegate() |
| + : metro_set_print_page_count_(NULL), |
| + metro_set_print_page_content_(NULL) { |
| + HMODULE metro_module = base::win::GetMetroModule(); |
| + if (metro_module != NULL) { |
| + metro_set_print_page_count_ = |
| + reinterpret_cast<MetroSetPrintPageCount>( |
| + ::GetProcAddress(metro_module, "MetroSetPrintPageCount")); |
| + metro_set_print_page_content_ = |
| + reinterpret_cast<MetroSetPrintPageContent>( |
| + ::GetProcAddress(metro_module, "MetroSetPrintPageContent")); |
| + } |
| + } |
| + virtual void SetPageCount(int page_count) { |
| + if (metro_set_print_page_count_) |
| + metro_set_print_page_count_(page_count); |
| + } |
| + |
| + virtual void SetPageContent(int page_number, |
| + void* content, |
| + size_t content_size) { |
| + if (metro_set_print_page_content_) |
| + metro_set_print_page_content_(page_number - 1, content, content_size); |
| + } |
| + private: |
| + typedef void (*MetroSetPrintPageCount)(INT); |
| + typedef void (*MetroSetPrintPageContent)(INT, VOID*, UINT32); |
| + MetroSetPrintPageCount metro_set_print_page_count_; |
| + MetroSetPrintPageContent metro_set_print_page_content_; |
| + }; |
| + printed_document_delegate = new MetroPrintingDelegate(); |
| +#endif // defined(OS_WIN) |
| + GetActiveTabContents()->print_view_manager()->PrintToDelegate( |
| + printed_document_delegate.get()); |
| +} |
| + |
| void Browser::EmailPageLocation() { |
| content::RecordAction(UserMetricsAction("EmailPageLocation")); |
| WebContents* wc = GetActiveWebContents(); |
| @@ -2516,6 +2559,7 @@ void Browser::ExecuteCommandWithDisposition( |
| case IDC_VIEW_SOURCE: ViewSelectedSource(); break; |
| case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; |
| case IDC_PRINT: Print(); break; |
| + case IDC_PRINT_TO_FILE : PrintToDelegate(); break; |
| case IDC_ADVANCED_PRINT: AdvancedPrint(); break; |
| case IDC_CHROME_TO_MOBILE_PAGE: ShowChromeToMobileBubble(); break; |
| case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; |
| @@ -4458,6 +4502,7 @@ void Browser::UpdatePrintingState(int content_restrictions) { |
| command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); |
| command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, |
| advanced_print_enabled); |
| + command_updater_.UpdateCommandEnabled(IDC_PRINT_TO_FILE, print_enabled); |
| } |
| void Browser::UpdateSaveAsState(int content_restrictions) { |