OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tab_contents/render_view_context_menu.h" | 5 #include "chrome/browser/tab_contents/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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "chrome/browser/translate/translate_manager.h" | 53 #include "chrome/browser/translate/translate_manager.h" |
54 #include "chrome/browser/translate/translate_prefs.h" | 54 #include "chrome/browser/translate/translate_prefs.h" |
55 #include "chrome/browser/translate/translate_tab_helper.h" | 55 #include "chrome/browser/translate/translate_tab_helper.h" |
56 #include "chrome/browser/ui/browser.h" | 56 #include "chrome/browser/ui/browser.h" |
57 #include "chrome/browser/ui/browser_commands.h" | 57 #include "chrome/browser/ui/browser_commands.h" |
58 #include "chrome/browser/ui/browser_finder.h" | 58 #include "chrome/browser/ui/browser_finder.h" |
59 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" | 59 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" |
60 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 60 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
61 #include "chrome/common/chrome_constants.h" | 61 #include "chrome/common/chrome_constants.h" |
62 #include "chrome/common/chrome_switches.h" | 62 #include "chrome/common/chrome_switches.h" |
| 63 #include "chrome/common/content_restriction.h" |
63 #include "chrome/common/extensions/extension.h" | 64 #include "chrome/common/extensions/extension.h" |
64 #include "chrome/common/net/url_util.h" | 65 #include "chrome/common/net/url_util.h" |
65 #include "chrome/common/pref_names.h" | 66 #include "chrome/common/pref_names.h" |
66 #include "chrome/common/print_messages.h" | 67 #include "chrome/common/print_messages.h" |
67 #include "chrome/common/spellcheck_messages.h" | 68 #include "chrome/common/spellcheck_messages.h" |
68 #include "chrome/common/url_constants.h" | 69 #include "chrome/common/url_constants.h" |
69 #include "content/public/browser/child_process_security_policy.h" | 70 #include "content/public/browser/child_process_security_policy.h" |
70 #include "content/public/browser/download_manager.h" | 71 #include "content/public/browser/download_manager.h" |
71 #include "content/public/browser/download_save_info.h" | 72 #include "content/public/browser/download_save_info.h" |
72 #include "content/public/browser/download_url_parameters.h" | 73 #include "content/public/browser/download_url_parameters.h" |
73 #include "content/public/browser/navigation_details.h" | 74 #include "content/public/browser/navigation_details.h" |
74 #include "content/public/browser/navigation_entry.h" | 75 #include "content/public/browser/navigation_entry.h" |
75 #include "content/public/browser/notification_service.h" | 76 #include "content/public/browser/notification_service.h" |
76 #include "content/public/browser/render_process_host.h" | 77 #include "content/public/browser/render_process_host.h" |
77 #include "content/public/browser/render_view_host.h" | 78 #include "content/public/browser/render_view_host.h" |
78 #include "content/public/browser/render_widget_host_view.h" | 79 #include "content/public/browser/render_widget_host_view.h" |
79 #include "content/public/browser/user_metrics.h" | 80 #include "content/public/browser/user_metrics.h" |
80 #include "content/public/browser/web_contents.h" | 81 #include "content/public/browser/web_contents.h" |
81 #include "content/public/common/content_restriction.h" | |
82 #include "content/public/common/menu_item.h" | 82 #include "content/public/common/menu_item.h" |
83 #include "content/public/common/ssl_status.h" | 83 #include "content/public/common/ssl_status.h" |
84 #include "content/public/common/url_utils.h" | 84 #include "content/public/common/url_utils.h" |
85 #include "extensions/browser/view_type_utils.h" | 85 #include "extensions/browser/view_type_utils.h" |
86 #include "grit/generated_resources.h" | 86 #include "grit/generated_resources.h" |
87 #include "net/base/escape.h" | 87 #include "net/base/escape.h" |
88 #include "third_party/WebKit/public/web/WebContextMenuData.h" | 88 #include "third_party/WebKit/public/web/WebContextMenuData.h" |
89 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" | 89 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" |
90 #include "third_party/WebKit/public/web/WebPluginAction.h" | 90 #include "third_party/WebKit/public/web/WebPluginAction.h" |
91 #include "ui/base/clipboard/clipboard.h" | 91 #include "ui/base/clipboard/clipboard.h" |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { | 1115 bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { |
1116 // If this command is is added by one of our observers, we dispatch it to the | 1116 // If this command is is added by one of our observers, we dispatch it to the |
1117 // observer. | 1117 // observer. |
1118 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); | 1118 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); |
1119 RenderViewContextMenuObserver* observer; | 1119 RenderViewContextMenuObserver* observer; |
1120 while ((observer = it.GetNext()) != NULL) { | 1120 while ((observer = it.GetNext()) != NULL) { |
1121 if (observer->IsCommandIdSupported(id)) | 1121 if (observer->IsCommandIdSupported(id)) |
1122 return observer->IsCommandIdEnabled(id); | 1122 return observer->IsCommandIdEnabled(id); |
1123 } | 1123 } |
1124 | 1124 |
| 1125 CoreTabHelper* core_tab_helper = |
| 1126 CoreTabHelper::FromWebContents(source_web_contents_); |
| 1127 int content_restrictions = 0; |
| 1128 if (core_tab_helper) |
| 1129 content_restrictions = core_tab_helper->content_restrictions(); |
1125 if (id == IDC_PRINT && | 1130 if (id == IDC_PRINT && |
1126 (source_web_contents_->GetContentRestrictions() & | 1131 (content_restrictions & CONTENT_RESTRICTION_PRINT)) { |
1127 content::CONTENT_RESTRICTION_PRINT)) { | |
1128 return false; | 1132 return false; |
1129 } | 1133 } |
1130 | 1134 |
1131 if (id == IDC_SAVE_PAGE && | 1135 if (id == IDC_SAVE_PAGE && |
1132 (source_web_contents_->GetContentRestrictions() & | 1136 (content_restrictions & CONTENT_RESTRICTION_SAVE)) { |
1133 content::CONTENT_RESTRICTION_SAVE)) { | |
1134 return false; | 1137 return false; |
1135 } | 1138 } |
1136 | 1139 |
1137 // Allow Spell Check language items on sub menu for text area context menu. | 1140 // Allow Spell Check language items on sub menu for text area context menu. |
1138 if ((id >= IDC_SPELLCHECK_LANGUAGES_FIRST) && | 1141 if ((id >= IDC_SPELLCHECK_LANGUAGES_FIRST) && |
1139 (id < IDC_SPELLCHECK_LANGUAGES_LAST)) { | 1142 (id < IDC_SPELLCHECK_LANGUAGES_LAST)) { |
1140 return profile_->GetPrefs()->GetBoolean(prefs::kEnableContinuousSpellcheck); | 1143 return profile_->GetPrefs()->GetBoolean(prefs::kEnableContinuousSpellcheck); |
1141 } | 1144 } |
1142 | 1145 |
1143 // Custom items. | 1146 // Custom items. |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 source_web_contents_->GetRenderViewHost()-> | 2052 source_web_contents_->GetRenderViewHost()-> |
2050 ExecuteMediaPlayerActionAtLocation(location, action); | 2053 ExecuteMediaPlayerActionAtLocation(location, action); |
2051 } | 2054 } |
2052 | 2055 |
2053 void RenderViewContextMenu::PluginActionAt( | 2056 void RenderViewContextMenu::PluginActionAt( |
2054 const gfx::Point& location, | 2057 const gfx::Point& location, |
2055 const WebPluginAction& action) { | 2058 const WebPluginAction& action) { |
2056 source_web_contents_->GetRenderViewHost()-> | 2059 source_web_contents_->GetRenderViewHost()-> |
2057 ExecutePluginActionAtLocation(location, action); | 2060 ExecutePluginActionAtLocation(location, action); |
2058 } | 2061 } |
OLD | NEW |