| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer_context_menu/render_view_context_menu.h" | 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 #include "ui/base/clipboard/clipboard.h" | 97 #include "ui/base/clipboard/clipboard.h" |
| 98 #include "ui/base/l10n/l10n_util.h" | 98 #include "ui/base/l10n/l10n_util.h" |
| 99 #include "ui/gfx/favicon_size.h" | 99 #include "ui/gfx/favicon_size.h" |
| 100 #include "ui/gfx/point.h" | 100 #include "ui/gfx/point.h" |
| 101 #include "ui/gfx/size.h" | 101 #include "ui/gfx/size.h" |
| 102 #include "ui/gfx/text_elider.h" | 102 #include "ui/gfx/text_elider.h" |
| 103 | 103 |
| 104 #if defined(ENABLE_PRINTING) | 104 #if defined(ENABLE_PRINTING) |
| 105 #include "chrome/common/print_messages.h" | 105 #include "chrome/common/print_messages.h" |
| 106 | 106 |
| 107 #if defined(ENABLE_FULL_PRINTING) | 107 #if defined(ENABLE_PRINT_PREVIEW) |
| 108 #include "chrome/browser/printing/print_preview_context_menu_observer.h" | 108 #include "chrome/browser/printing/print_preview_context_menu_observer.h" |
| 109 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 109 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 110 #include "chrome/browser/printing/print_view_manager.h" | 110 #include "chrome/browser/printing/print_view_manager.h" |
| 111 #else | 111 #else |
| 112 #include "chrome/browser/printing/print_view_manager_basic.h" | 112 #include "chrome/browser/printing/print_view_manager_basic.h" |
| 113 #endif // defined(ENABLE_FULL_PRINTING) | 113 #endif // defined(ENABLE_PRINT_PREVIEW) |
| 114 #endif // defined(ENABLE_PRINTING) | 114 #endif // defined(ENABLE_PRINTING) |
| 115 | 115 |
| 116 using base::UserMetricsAction; | 116 using base::UserMetricsAction; |
| 117 using blink::WebContextMenuData; | 117 using blink::WebContextMenuData; |
| 118 using blink::WebMediaPlayerAction; | 118 using blink::WebMediaPlayerAction; |
| 119 using blink::WebPluginAction; | 119 using blink::WebPluginAction; |
| 120 using blink::WebString; | 120 using blink::WebString; |
| 121 using blink::WebURL; | 121 using blink::WebURL; |
| 122 using content::BrowserContext; | 122 using content::BrowserContext; |
| 123 using content::ChildProcessSecurityPolicy; | 123 using content::ChildProcessSecurityPolicy; |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 } | 609 } |
| 610 | 610 |
| 611 #if defined(ENABLE_PLUGINS) | 611 #if defined(ENABLE_PLUGINS) |
| 612 void RenderViewContextMenu::HandleAuthorizeAllPlugins() { | 612 void RenderViewContextMenu::HandleAuthorizeAllPlugins() { |
| 613 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( | 613 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( |
| 614 source_web_contents_, false, std::string()); | 614 source_web_contents_, false, std::string()); |
| 615 } | 615 } |
| 616 #endif | 616 #endif |
| 617 | 617 |
| 618 void RenderViewContextMenu::AppendPrintPreviewItems() { | 618 void RenderViewContextMenu::AppendPrintPreviewItems() { |
| 619 #if defined(ENABLE_FULL_PRINTING) | 619 #if defined(ENABLE_PRINT_PREVIEW) |
| 620 if (!print_preview_menu_observer_.get()) { | 620 if (!print_preview_menu_observer_.get()) { |
| 621 print_preview_menu_observer_.reset( | 621 print_preview_menu_observer_.reset( |
| 622 new PrintPreviewContextMenuObserver(source_web_contents_)); | 622 new PrintPreviewContextMenuObserver(source_web_contents_)); |
| 623 } | 623 } |
| 624 | 624 |
| 625 observers_.AddObserver(print_preview_menu_observer_.get()); | 625 observers_.AddObserver(print_preview_menu_observer_.get()); |
| 626 #endif | 626 #endif |
| 627 } | 627 } |
| 628 | 628 |
| 629 const Extension* RenderViewContextMenu::GetExtension() const { | 629 const Extension* RenderViewContextMenu::GetExtension() const { |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 PrefService* local_state = g_browser_process->local_state(); | 1139 PrefService* local_state = g_browser_process->local_state(); |
| 1140 DCHECK(local_state); | 1140 DCHECK(local_state); |
| 1141 // Test if file-selection dialogs are forbidden by policy. | 1141 // Test if file-selection dialogs are forbidden by policy. |
| 1142 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) | 1142 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
| 1143 return false; | 1143 return false; |
| 1144 | 1144 |
| 1145 const GURL& url = params_.src_url; | 1145 const GURL& url = params_.src_url; |
| 1146 bool can_save = | 1146 bool can_save = |
| 1147 (params_.media_flags & WebContextMenuData::MediaCanSave) && | 1147 (params_.media_flags & WebContextMenuData::MediaCanSave) && |
| 1148 url.is_valid() && ProfileIOData::IsHandledProtocol(url.scheme()); | 1148 url.is_valid() && ProfileIOData::IsHandledProtocol(url.scheme()); |
| 1149 #if defined(ENABLE_FULL_PRINTING) | 1149 #if defined(ENABLE_PRINT_PREVIEW) |
| 1150 // Do not save the preview PDF on the print preview page. | 1150 // Do not save the preview PDF on the print preview page. |
| 1151 can_save = can_save && | 1151 can_save = can_save && |
| 1152 !(printing::PrintPreviewDialogController::IsPrintPreviewURL(url)); | 1152 !(printing::PrintPreviewDialogController::IsPrintPreviewURL(url)); |
| 1153 #endif | 1153 #endif |
| 1154 return can_save; | 1154 return can_save; |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: | 1157 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: |
| 1158 return true; | 1158 return true; |
| 1159 | 1159 |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1490 case IDC_PRINT: { | 1490 case IDC_PRINT: { |
| 1491 #if defined(ENABLE_PRINTING) | 1491 #if defined(ENABLE_PRINTING) |
| 1492 if (params_.media_type != WebContextMenuData::MediaTypeNone) { | 1492 if (params_.media_type != WebContextMenuData::MediaTypeNone) { |
| 1493 if (render_frame_host) { | 1493 if (render_frame_host) { |
| 1494 render_frame_host->Send(new PrintMsg_PrintNodeUnderContextMenu( | 1494 render_frame_host->Send(new PrintMsg_PrintNodeUnderContextMenu( |
| 1495 render_frame_host->GetRoutingID())); | 1495 render_frame_host->GetRoutingID())); |
| 1496 } | 1496 } |
| 1497 break; | 1497 break; |
| 1498 } | 1498 } |
| 1499 | 1499 |
| 1500 #if defined(ENABLE_FULL_PRINTING) | 1500 #if defined(ENABLE_PRINT_PREVIEW) |
| 1501 printing::PrintViewManager* print_view_manager = | 1501 printing::PrintViewManager* print_view_manager = |
| 1502 printing::PrintViewManager::FromWebContents(source_web_contents_); | 1502 printing::PrintViewManager::FromWebContents(source_web_contents_); |
| 1503 if (!print_view_manager) | 1503 if (!print_view_manager) |
| 1504 break; | 1504 break; |
| 1505 if (!GetPrefs(browser_context_) | 1505 if (!GetPrefs(browser_context_) |
| 1506 ->GetBoolean(prefs::kPrintPreviewDisabled)) { | 1506 ->GetBoolean(prefs::kPrintPreviewDisabled)) { |
| 1507 print_view_manager->PrintPreviewNow(!params_.selection_text.empty()); | 1507 print_view_manager->PrintPreviewNow(!params_.selection_text.empty()); |
| 1508 break; | 1508 break; |
| 1509 } | 1509 } |
| 1510 #else // ENABLE_FULL_PRINTING | 1510 #else // ENABLE_PRINT_PREVIEW |
| 1511 printing::PrintViewManagerBasic* print_view_manager = | 1511 printing::PrintViewManagerBasic* print_view_manager = |
| 1512 printing::PrintViewManagerBasic::FromWebContents( | 1512 printing::PrintViewManagerBasic::FromWebContents( |
| 1513 source_web_contents_); | 1513 source_web_contents_); |
| 1514 if (!print_view_manager) | 1514 if (!print_view_manager) |
| 1515 break; | 1515 break; |
| 1516 #endif // ENABLE_FULL_PRINTING | 1516 #endif // ENABLE_PRINT_PREVIEW |
| 1517 | 1517 |
| 1518 #if !defined(DISABLE_BASIC_PRINTING) | 1518 #if defined(ENABLE_BASIC_PRINTING) |
| 1519 print_view_manager->PrintNow(); | 1519 print_view_manager->PrintNow(); |
| 1520 #endif // !DISABLE_BASIC_PRINTING | 1520 #endif // ENABLE_BASIC_PRINTING |
| 1521 | 1521 |
| 1522 #endif // ENABLE_PRINTING | 1522 #endif // ENABLE_PRINTING |
| 1523 break; | 1523 break; |
| 1524 } | 1524 } |
| 1525 | 1525 |
| 1526 case IDC_VIEW_SOURCE: | 1526 case IDC_VIEW_SOURCE: |
| 1527 source_web_contents_->ViewSource(); | 1527 source_web_contents_->ViewSource(); |
| 1528 break; | 1528 break; |
| 1529 | 1529 |
| 1530 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: | 1530 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1787 source_web_contents_->GetRenderViewHost()-> | 1787 source_web_contents_->GetRenderViewHost()-> |
| 1788 ExecuteMediaPlayerActionAtLocation(location, action); | 1788 ExecuteMediaPlayerActionAtLocation(location, action); |
| 1789 } | 1789 } |
| 1790 | 1790 |
| 1791 void RenderViewContextMenu::PluginActionAt( | 1791 void RenderViewContextMenu::PluginActionAt( |
| 1792 const gfx::Point& location, | 1792 const gfx::Point& location, |
| 1793 const WebPluginAction& action) { | 1793 const WebPluginAction& action) { |
| 1794 source_web_contents_->GetRenderViewHost()-> | 1794 source_web_contents_->GetRenderViewHost()-> |
| 1795 ExecutePluginActionAtLocation(location, action); | 1795 ExecutePluginActionAtLocation(location, action); |
| 1796 } | 1796 } |
| OLD | NEW |