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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 | 1576 |
1577 case IDC_CONTENT_CONTEXT_SELECTALL: | 1577 case IDC_CONTENT_CONTEXT_SELECTALL: |
1578 return !!(params_.edit_flags & WebContextMenuData::CanSelectAll); | 1578 return !!(params_.edit_flags & WebContextMenuData::CanSelectAll); |
1579 | 1579 |
1580 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: | 1580 case IDC_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: |
1581 return !browser_context_->IsOffTheRecord() && | 1581 return !browser_context_->IsOffTheRecord() && |
1582 params_.link_url.is_valid() && | 1582 params_.link_url.is_valid() && |
1583 incognito_avail != IncognitoModePrefs::DISABLED; | 1583 incognito_avail != IncognitoModePrefs::DISABLED; |
1584 | 1584 |
1585 case IDC_PRINT: | 1585 case IDC_PRINT: |
1586 return prefs->GetBoolean(prefs::kPrintingEnabled) && | 1586 return IsPrintPreviewEnabled(); |
1587 (params_.media_type == WebContextMenuData::MediaTypeNone || | |
1588 params_.media_flags & WebContextMenuData::MediaCanPrint); | |
1589 | 1587 |
1590 case IDC_CONTENT_CONTEXT_SEARCHWEBFOR: | 1588 case IDC_CONTENT_CONTEXT_SEARCHWEBFOR: |
1591 case IDC_CONTENT_CONTEXT_GOTOURL: | 1589 case IDC_CONTENT_CONTEXT_GOTOURL: |
1592 case IDC_SPELLPANEL_TOGGLE: | 1590 case IDC_SPELLPANEL_TOGGLE: |
1593 case IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS: | 1591 case IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS: |
1594 return true; | 1592 return true; |
1595 case IDC_CHECK_SPELLING_WHILE_TYPING: | 1593 case IDC_CHECK_SPELLING_WHILE_TYPING: |
1596 return prefs->GetBoolean(prefs::kEnableContinuousSpellcheck); | 1594 return prefs->GetBoolean(prefs::kEnableContinuousSpellcheck); |
1597 | 1595 |
1598 #if !defined(OS_MACOSX) && defined(OS_POSIX) | 1596 #if !defined(OS_MACOSX) && defined(OS_POSIX) |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2075 | 2073 |
2076 bool RenderViewContextMenu::IsPasteAndMatchStyleEnabled() const { | 2074 bool RenderViewContextMenu::IsPasteAndMatchStyleEnabled() const { |
2077 if (!(params_.edit_flags & WebContextMenuData::CanPaste)) | 2075 if (!(params_.edit_flags & WebContextMenuData::CanPaste)) |
2078 return false; | 2076 return false; |
2079 | 2077 |
2080 return ui::Clipboard::GetForCurrentThread()->IsFormatAvailable( | 2078 return ui::Clipboard::GetForCurrentThread()->IsFormatAvailable( |
2081 ui::Clipboard::GetPlainTextFormatType(), | 2079 ui::Clipboard::GetPlainTextFormatType(), |
2082 ui::CLIPBOARD_TYPE_COPY_PASTE); | 2080 ui::CLIPBOARD_TYPE_COPY_PASTE); |
2083 } | 2081 } |
2084 | 2082 |
| 2083 bool RenderViewContextMenu::IsPrintPreviewEnabled() const { |
| 2084 if (params_.media_type != WebContextMenuData::MediaTypeNone && |
| 2085 !(params_.media_flags & WebContextMenuData::MediaCanPrint)) { |
| 2086 return false; |
| 2087 } |
| 2088 |
| 2089 // |browser| is a nullptr if a modal dialog is open. |
| 2090 Browser* browser = chrome::FindBrowserWithWebContents(source_web_contents_); |
| 2091 return browser && chrome::CanPrint(browser); |
| 2092 } |
| 2093 |
2085 bool RenderViewContextMenu::IsRouteMediaEnabled() const { | 2094 bool RenderViewContextMenu::IsRouteMediaEnabled() const { |
2086 if (!media_router::MediaRouterEnabled(browser_context_)) | 2095 if (!media_router::MediaRouterEnabled(browser_context_)) |
2087 return false; | 2096 return false; |
2088 | 2097 |
2089 Browser* browser = chrome::FindBrowserWithWebContents(source_web_contents_); | 2098 Browser* browser = chrome::FindBrowserWithWebContents(source_web_contents_); |
2090 if (!browser) | 2099 if (!browser) |
2091 return false; | 2100 return false; |
2092 | 2101 |
2093 // Disable the command if there is an active modal dialog. | 2102 // Disable the command if there is an active modal dialog. |
2094 // We don't use |source_web_contents_| here because it could be the | 2103 // We don't use |source_web_contents_| here because it could be the |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2438 source_web_contents_->GetRenderViewHost()-> | 2447 source_web_contents_->GetRenderViewHost()-> |
2439 ExecuteMediaPlayerActionAtLocation(location, action); | 2448 ExecuteMediaPlayerActionAtLocation(location, action); |
2440 } | 2449 } |
2441 | 2450 |
2442 void RenderViewContextMenu::PluginActionAt( | 2451 void RenderViewContextMenu::PluginActionAt( |
2443 const gfx::Point& location, | 2452 const gfx::Point& location, |
2444 const WebPluginAction& action) { | 2453 const WebPluginAction& action) { |
2445 source_web_contents_->GetRenderViewHost()-> | 2454 source_web_contents_->GetRenderViewHost()-> |
2446 ExecutePluginActionAtLocation(location, action); | 2455 ExecutePluginActionAtLocation(location, action); |
2447 } | 2456 } |
OLD | NEW |