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 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1139 case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE: | 1139 case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE: |
1140 return source_web_contents_->GetController().CanViewSource(); | 1140 return source_web_contents_->GetController().CanViewSource(); |
1141 | 1141 |
1142 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: | 1142 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: |
1143 case IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE: | 1143 case IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE: |
1144 case IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP: | 1144 case IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP: |
1145 case IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP: | 1145 case IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP: |
1146 return IsDevCommandEnabled(id); | 1146 return IsDevCommandEnabled(id); |
1147 | 1147 |
1148 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: | 1148 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: |
1149 if (source_web_contents_->GetController().GetActiveEntry() == NULL) | 1149 if (source_web_contents_->GetController().GetVisibleEntry() == NULL) |
Charlie Reis
2014/05/09 22:48:50
This needed to match the VIEWPAGEINFO case below,
| |
1150 return false; | 1150 return false; |
1151 // Disabled if no browser is associated (e.g. desktop notifications). | 1151 // Disabled if no browser is associated (e.g. desktop notifications). |
1152 if (chrome::FindBrowserWithWebContents(source_web_contents_) == NULL) | 1152 if (chrome::FindBrowserWithWebContents(source_web_contents_) == NULL) |
1153 return false; | 1153 return false; |
1154 return true; | 1154 return true; |
1155 | 1155 |
1156 case IDC_CONTENT_CONTEXT_TRANSLATE: { | 1156 case IDC_CONTENT_CONTEXT_TRANSLATE: { |
1157 TranslateTabHelper* translate_tab_helper = | 1157 TranslateTabHelper* translate_tab_helper = |
1158 TranslateTabHelper::FromWebContents(source_web_contents_); | 1158 TranslateTabHelper::FromWebContents(source_web_contents_); |
1159 if (!translate_tab_helper) | 1159 if (!translate_tab_helper) |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1275 if (core_delegate && | 1275 if (core_delegate && |
1276 !core_delegate->CanSaveContents(source_web_contents_)) | 1276 !core_delegate->CanSaveContents(source_web_contents_)) |
1277 return false; | 1277 return false; |
1278 | 1278 |
1279 PrefService* local_state = g_browser_process->local_state(); | 1279 PrefService* local_state = g_browser_process->local_state(); |
1280 DCHECK(local_state); | 1280 DCHECK(local_state); |
1281 // Test if file-selection dialogs are forbidden by policy. | 1281 // Test if file-selection dialogs are forbidden by policy. |
1282 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) | 1282 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
1283 return false; | 1283 return false; |
1284 | 1284 |
1285 // Instead of using GetURL here, we use url() (which is the "real" url of | 1285 // We save the last committed entry (which the user is looking at), as |
Charlie Reis
2014/05/09 22:48:50
John: It looks like you changed this behavior in h
jam
2014/05/09 23:06:54
I just looked at that cl, GetURL() there returned
Charlie Reis
2014/05/09 23:34:43
Huh. That confused me as well, but now I think "G
|
Charlie Reis
2014/05/09 22:48:50
I think it makes sense to save the page you're vie
nasko
2014/05/09 22:56:08
Agreed.
|
1286 // the page) from the NavigationEntry because its reflects their origin | 1286 // opposed to any pending URL that hasn't committed yet. |
1287 // rather than the display one (returned by GetURL) which may be | 1287 NavigationEntry* entry = |
1288 // different (like having "view-source:" on the front). | 1288 source_web_contents_->GetController().GetLastCommittedEntry(); |
1289 // TODO(nasko): Audit all GetActiveEntry calls in this file. | 1289 return content::IsSavableURL(entry ? entry->GetURL() : GURL()); |
Charlie Reis
2014/05/09 22:48:50
Nasko: I think this takes care of the rest of them
| |
1290 NavigationEntry* active_entry = | |
1291 source_web_contents_->GetController().GetActiveEntry(); | |
1292 return content::IsSavableURL( | |
1293 (active_entry) ? active_entry->GetURL() : GURL()); | |
1294 } | 1290 } |
1295 | 1291 |
1296 case IDC_CONTENT_CONTEXT_RELOADFRAME: | 1292 case IDC_CONTENT_CONTEXT_RELOADFRAME: |
1297 return params_.frame_url.is_valid(); | 1293 return params_.frame_url.is_valid(); |
1298 | 1294 |
1299 case IDC_CONTENT_CONTEXT_UNDO: | 1295 case IDC_CONTENT_CONTEXT_UNDO: |
1300 return !!(params_.edit_flags & WebContextMenuData::CanUndo); | 1296 return !!(params_.edit_flags & WebContextMenuData::CanUndo); |
1301 | 1297 |
1302 case IDC_CONTENT_CONTEXT_REDO: | 1298 case IDC_CONTENT_CONTEXT_REDO: |
1303 return !!(params_.edit_flags & WebContextMenuData::CanRedo); | 1299 return !!(params_.edit_flags & WebContextMenuData::CanRedo); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1678 DCHECK(platform_app); | 1674 DCHECK(platform_app); |
1679 DCHECK(platform_app->is_platform_app()); | 1675 DCHECK(platform_app->is_platform_app()); |
1680 | 1676 |
1681 extensions::devtools_util::InspectBackgroundPage(platform_app, profile_); | 1677 extensions::devtools_util::InspectBackgroundPage(platform_app, profile_); |
1682 break; | 1678 break; |
1683 } | 1679 } |
1684 | 1680 |
1685 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: { | 1681 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: { |
1686 NavigationController* controller = &source_web_contents_->GetController(); | 1682 NavigationController* controller = &source_web_contents_->GetController(); |
1687 // Important to use GetVisibleEntry to match what's showing in the | 1683 // Important to use GetVisibleEntry to match what's showing in the |
1688 // omnibox. | 1684 // omnibox. This may return null. |
1689 NavigationEntry* nav_entry = controller->GetVisibleEntry(); | 1685 NavigationEntry* nav_entry = controller->GetVisibleEntry(); |
1686 if (!nav_entry) | |
1687 return; | |
1690 Browser* browser = | 1688 Browser* browser = |
1691 chrome::FindBrowserWithWebContents(source_web_contents_); | 1689 chrome::FindBrowserWithWebContents(source_web_contents_); |
1692 chrome::ShowWebsiteSettings(browser, source_web_contents_, | 1690 chrome::ShowWebsiteSettings(browser, source_web_contents_, |
1693 nav_entry->GetURL(), nav_entry->GetSSL()); | 1691 nav_entry->GetURL(), nav_entry->GetSSL()); |
1694 break; | 1692 break; |
1695 } | 1693 } |
1696 | 1694 |
1697 case IDC_CONTENT_CONTEXT_TRANSLATE: { | 1695 case IDC_CONTENT_CONTEXT_TRANSLATE: { |
1698 // A translation might have been triggered by the time the menu got | 1696 // A translation might have been triggered by the time the menu got |
1699 // selected, do nothing in that case. | 1697 // selected, do nothing in that case. |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1967 source_web_contents_->GetRenderViewHost()-> | 1965 source_web_contents_->GetRenderViewHost()-> |
1968 ExecuteMediaPlayerActionAtLocation(location, action); | 1966 ExecuteMediaPlayerActionAtLocation(location, action); |
1969 } | 1967 } |
1970 | 1968 |
1971 void RenderViewContextMenu::PluginActionAt( | 1969 void RenderViewContextMenu::PluginActionAt( |
1972 const gfx::Point& location, | 1970 const gfx::Point& location, |
1973 const WebPluginAction& action) { | 1971 const WebPluginAction& action) { |
1974 source_web_contents_->GetRenderViewHost()-> | 1972 source_web_contents_->GetRenderViewHost()-> |
1975 ExecutePluginActionAtLocation(location, action); | 1973 ExecutePluginActionAtLocation(location, action); |
1976 } | 1974 } |
OLD | NEW |