| 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/ui/browser_commands.h" | 5 #include "chrome/browser/ui/browser_commands.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_editor.h" | 10 #include "chrome/browser/bookmarks/bookmark_editor.h" |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 ASCIIToUTF16("http://webintents.org/share"), | 674 ASCIIToUTF16("http://webintents.org/share"), |
| 675 ASCIIToUTF16("text/uri-list"), | 675 ASCIIToUTF16("text/uri-list"), |
| 676 UTF8ToUTF16(current_url.spec())); | 676 UTF8ToUTF16(current_url.spec())); |
| 677 scoped_ptr<content::WebIntentsDispatcher> dispatcher( | 677 scoped_ptr<content::WebIntentsDispatcher> dispatcher( |
| 678 content::WebIntentsDispatcher::Create(intent_data)); | 678 content::WebIntentsDispatcher::Create(intent_data)); |
| 679 static_cast<content::WebContentsDelegate*>(browser)-> | 679 static_cast<content::WebContentsDelegate*>(browser)-> |
| 680 WebIntentDispatch(NULL, dispatcher.release()); | 680 WebIntentDispatch(NULL, dispatcher.release()); |
| 681 } | 681 } |
| 682 | 682 |
| 683 void Print(Browser* browser) { | 683 void Print(Browser* browser) { |
| 684 printing::PrintViewManager* print_view_manager = |
| 685 printing::PrintViewManager::FromWebContents( |
| 686 GetActiveWebContents(browser)); |
| 684 if (browser->profile()->GetPrefs()->GetBoolean( | 687 if (browser->profile()->GetPrefs()->GetBoolean( |
| 685 prefs::kPrintPreviewDisabled)) { | 688 prefs::kPrintPreviewDisabled)) |
| 686 GetActiveTabContents(browser)->print_view_manager()->PrintNow(); | 689 print_view_manager->PrintNow(); |
| 687 } else { | 690 else |
| 688 GetActiveTabContents(browser)->print_view_manager()-> | 691 print_view_manager->PrintPreviewNow(); |
| 689 PrintPreviewNow(); | |
| 690 } | |
| 691 } | 692 } |
| 692 | 693 |
| 693 bool CanPrint(const Browser* browser) { | 694 bool CanPrint(const Browser* browser) { |
| 694 // Do not print when printing is disabled via pref or policy. | 695 // Do not print when printing is disabled via pref or policy. |
| 695 // Do not print when a constrained window is showing. It's confusing. | 696 // Do not print when a constrained window is showing. It's confusing. |
| 696 // Do not print if instant extended API is enabled and mode is NTP. | 697 // Do not print if instant extended API is enabled and mode is NTP. |
| 697 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 698 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
| 698 !(HasConstrainedWindow(browser) || | 699 !(HasConstrainedWindow(browser) || |
| 699 GetContentRestrictions(browser) & content::CONTENT_RESTRICTION_PRINT || | 700 GetContentRestrictions(browser) & content::CONTENT_RESTRICTION_PRINT || |
| 700 IsNTPModeForInstantExtendedAPI(browser)); | 701 IsNTPModeForInstantExtendedAPI(browser)); |
| 701 } | 702 } |
| 702 | 703 |
| 703 void AdvancedPrint(Browser* browser) { | 704 void AdvancedPrint(Browser* browser) { |
| 704 GetActiveTabContents(browser)->print_view_manager()-> | 705 printing::PrintViewManager* print_view_manager = |
| 705 AdvancedPrintNow(); | 706 printing::PrintViewManager::FromWebContents( |
| 707 GetActiveWebContents(browser)); |
| 708 print_view_manager->AdvancedPrintNow(); |
| 706 } | 709 } |
| 707 | 710 |
| 708 bool CanAdvancedPrint(const Browser* browser) { | 711 bool CanAdvancedPrint(const Browser* browser) { |
| 709 // If printing is not disabled via pref or policy, it is always possible to | 712 // If printing is not disabled via pref or policy, it is always possible to |
| 710 // advanced print when the print preview is visible. | 713 // advanced print when the print preview is visible. |
| 711 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 714 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
| 712 (PrintPreviewShowing(browser) || CanPrint(browser)); | 715 (PrintPreviewShowing(browser) || CanPrint(browser)); |
| 713 } | 716 } |
| 714 | 717 |
| 715 void PrintToDestination(Browser* browser) { | 718 void PrintToDestination(Browser* browser) { |
| 716 GetActiveTabContents(browser)->print_view_manager()->PrintToDestination(); | 719 printing::PrintViewManager* print_view_manager = |
| 720 printing::PrintViewManager::FromWebContents( |
| 721 GetActiveWebContents(browser)); |
| 722 print_view_manager->PrintToDestination(); |
| 717 } | 723 } |
| 718 | 724 |
| 719 void EmailPageLocation(Browser* browser) { | 725 void EmailPageLocation(Browser* browser) { |
| 720 content::RecordAction(UserMetricsAction("EmailPageLocation")); | 726 content::RecordAction(UserMetricsAction("EmailPageLocation")); |
| 721 WebContents* wc = GetActiveWebContents(browser); | 727 WebContents* wc = GetActiveWebContents(browser); |
| 722 DCHECK(wc); | 728 DCHECK(wc); |
| 723 | 729 |
| 724 std::string title = net::EscapeQueryParamValue( | 730 std::string title = net::EscapeQueryParamValue( |
| 725 UTF16ToUTF8(wc->GetTitle()), false); | 731 UTF16ToUTF8(wc->GetTitle()), false); |
| 726 std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false); | 732 std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 BrowserCommandsTabContentsCreator::CreateTabContents(contents); | 1048 BrowserCommandsTabContentsCreator::CreateTabContents(contents); |
| 1043 } | 1049 } |
| 1044 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); | 1050 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); |
| 1045 | 1051 |
| 1046 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1052 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1047 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1053 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 1048 app_browser->window()->Show(); | 1054 app_browser->window()->Show(); |
| 1049 } | 1055 } |
| 1050 | 1056 |
| 1051 } // namespace chrome | 1057 } // namespace chrome |
| OLD | NEW |