| 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 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 return (params_.media_type != WebContextMenuData::MediaTypePlugin) && | 1156 return (params_.media_type != WebContextMenuData::MediaTypePlugin) && |
| 1157 embedder_web_contents_->GetController().CanViewSource(); | 1157 embedder_web_contents_->GetController().CanViewSource(); |
| 1158 | 1158 |
| 1159 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: | 1159 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: |
| 1160 case IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE: | 1160 case IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE: |
| 1161 case IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP: | 1161 case IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP: |
| 1162 case IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP: | 1162 case IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP: |
| 1163 return IsDevCommandEnabled(id); | 1163 return IsDevCommandEnabled(id); |
| 1164 | 1164 |
| 1165 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: | 1165 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: |
| 1166 if (embedder_web_contents_->GetController().GetVisibleEntry() == NULL) | 1166 // Disabled for initial navigation. |
| 1167 if (embedder_web_contents_->GetController().IsInitialNavigation()) |
| 1167 return false; | 1168 return false; |
| 1168 // Disabled if no browser is associated (e.g. desktop notifications). | 1169 // Disabled if no browser is associated (e.g. desktop notifications). |
| 1169 if (chrome::FindBrowserWithWebContents(embedder_web_contents_) == NULL) | 1170 if (chrome::FindBrowserWithWebContents(embedder_web_contents_) == NULL) |
| 1170 return false; | 1171 return false; |
| 1171 return true; | 1172 return true; |
| 1172 | 1173 |
| 1173 case IDC_CONTENT_CONTEXT_TRANSLATE: { | 1174 case IDC_CONTENT_CONTEXT_TRANSLATE: { |
| 1174 ChromeTranslateClient* chrome_translate_client = | 1175 ChromeTranslateClient* chrome_translate_client = |
| 1175 ChromeTranslateClient::FromWebContents(embedder_web_contents_); | 1176 ChromeTranslateClient::FromWebContents(embedder_web_contents_); |
| 1176 // If no |chrome_translate_client| attached with this WebContents or we're | 1177 // If no |chrome_translate_client| attached with this WebContents or we're |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 PrefService* local_state = g_browser_process->local_state(); | 1308 PrefService* local_state = g_browser_process->local_state(); |
| 1308 DCHECK(local_state); | 1309 DCHECK(local_state); |
| 1309 // Test if file-selection dialogs are forbidden by policy. | 1310 // Test if file-selection dialogs are forbidden by policy. |
| 1310 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) | 1311 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
| 1311 return false; | 1312 return false; |
| 1312 | 1313 |
| 1313 // We save the last committed entry (which the user is looking at), as | 1314 // We save the last committed entry (which the user is looking at), as |
| 1314 // opposed to any pending URL that hasn't committed yet. | 1315 // opposed to any pending URL that hasn't committed yet. |
| 1315 NavigationEntry* entry = | 1316 NavigationEntry* entry = |
| 1316 embedder_web_contents_->GetController().GetLastCommittedEntry(); | 1317 embedder_web_contents_->GetController().GetLastCommittedEntry(); |
| 1317 return content::IsSavableURL(entry ? entry->GetURL() : GURL()); | 1318 return content::IsSavableURL(entry->GetURL()); |
| 1318 } | 1319 } |
| 1319 | 1320 |
| 1320 case IDC_CONTENT_CONTEXT_RELOADFRAME: | 1321 case IDC_CONTENT_CONTEXT_RELOADFRAME: |
| 1321 return params_.frame_url.is_valid(); | 1322 return params_.frame_url.is_valid(); |
| 1322 | 1323 |
| 1323 case IDC_CONTENT_CONTEXT_UNDO: | 1324 case IDC_CONTENT_CONTEXT_UNDO: |
| 1324 return !!(params_.edit_flags & WebContextMenuData::CanUndo); | 1325 return !!(params_.edit_flags & WebContextMenuData::CanUndo); |
| 1325 | 1326 |
| 1326 case IDC_CONTENT_CONTEXT_REDO: | 1327 case IDC_CONTENT_CONTEXT_REDO: |
| 1327 return !!(params_.edit_flags & WebContextMenuData::CanRedo); | 1328 return !!(params_.edit_flags & WebContextMenuData::CanRedo); |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1727 | 1728 |
| 1728 extensions::devtools_util::InspectBackgroundPage(platform_app, | 1729 extensions::devtools_util::InspectBackgroundPage(platform_app, |
| 1729 GetProfile()); | 1730 GetProfile()); |
| 1730 break; | 1731 break; |
| 1731 } | 1732 } |
| 1732 | 1733 |
| 1733 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: { | 1734 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: { |
| 1734 NavigationController* controller = | 1735 NavigationController* controller = |
| 1735 &embedder_web_contents_->GetController(); | 1736 &embedder_web_contents_->GetController(); |
| 1736 // Important to use GetVisibleEntry to match what's showing in the | 1737 // Important to use GetVisibleEntry to match what's showing in the |
| 1737 // omnibox. This may return null. | 1738 // omnibox. |
| 1738 NavigationEntry* nav_entry = controller->GetVisibleEntry(); | 1739 NavigationEntry* nav_entry = controller->GetVisibleEntry(); |
| 1739 if (!nav_entry) | |
| 1740 return; | |
| 1741 Browser* browser = | 1740 Browser* browser = |
| 1742 chrome::FindBrowserWithWebContents(embedder_web_contents_); | 1741 chrome::FindBrowserWithWebContents(embedder_web_contents_); |
| 1743 SecurityStateModel* security_model = | 1742 SecurityStateModel* security_model = |
| 1744 SecurityStateModel::FromWebContents(embedder_web_contents_); | 1743 SecurityStateModel::FromWebContents(embedder_web_contents_); |
| 1745 DCHECK(security_model); | 1744 DCHECK(security_model); |
| 1746 chrome::ShowWebsiteSettings(browser, embedder_web_contents_, | 1745 chrome::ShowWebsiteSettings(browser, embedder_web_contents_, |
| 1747 nav_entry->GetURL(), | 1746 nav_entry->GetURL(), |
| 1748 security_model->GetSecurityInfo()); | 1747 security_model->GetSecurityInfo()); |
| 1749 break; | 1748 break; |
| 1750 } | 1749 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 source_web_contents_->GetRenderViewHost()-> | 1976 source_web_contents_->GetRenderViewHost()-> |
| 1978 ExecuteMediaPlayerActionAtLocation(location, action); | 1977 ExecuteMediaPlayerActionAtLocation(location, action); |
| 1979 } | 1978 } |
| 1980 | 1979 |
| 1981 void RenderViewContextMenu::PluginActionAt( | 1980 void RenderViewContextMenu::PluginActionAt( |
| 1982 const gfx::Point& location, | 1981 const gfx::Point& location, |
| 1983 const WebPluginAction& action) { | 1982 const WebPluginAction& action) { |
| 1984 source_web_contents_->GetRenderViewHost()-> | 1983 source_web_contents_->GetRenderViewHost()-> |
| 1985 ExecutePluginActionAtLocation(location, action); | 1984 ExecutePluginActionAtLocation(location, action); |
| 1986 } | 1985 } |
| OLD | NEW |