| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 9 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 10 | 10 |
| (...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 IncognitoModePrefs::Availability incognito_avail = | 1142 IncognitoModePrefs::Availability incognito_avail = |
| 1143 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()); | 1143 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()); |
| 1144 switch (id) { | 1144 switch (id) { |
| 1145 case IDC_BACK: | 1145 case IDC_BACK: |
| 1146 return source_web_contents_->GetController().CanGoBack(); | 1146 return source_web_contents_->GetController().CanGoBack(); |
| 1147 | 1147 |
| 1148 case IDC_FORWARD: | 1148 case IDC_FORWARD: |
| 1149 return source_web_contents_->GetController().CanGoForward(); | 1149 return source_web_contents_->GetController().CanGoForward(); |
| 1150 | 1150 |
| 1151 case IDC_RELOAD: { | 1151 case IDC_RELOAD: { |
| 1152 TabContents* tab_contents = | 1152 CoreTabHelper* core_tab_helper = |
| 1153 TabContents::FromWebContents(source_web_contents_); | 1153 CoreTabHelper::FromWebContents(source_web_contents_); |
| 1154 if (!tab_contents) | 1154 if (!core_tab_helper) |
| 1155 return false; | 1155 return false; |
| 1156 CoreTabHelperDelegate* core_delegate = | 1156 |
| 1157 tab_contents->core_tab_helper()->delegate(); | 1157 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); |
| 1158 return !core_delegate || core_delegate->CanReloadContents(tab_contents); | 1158 return !core_delegate || |
| 1159 core_delegate->CanReloadContents(source_web_contents_); |
| 1159 } | 1160 } |
| 1160 | 1161 |
| 1161 case IDC_VIEW_SOURCE: | 1162 case IDC_VIEW_SOURCE: |
| 1162 case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE: | 1163 case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE: |
| 1163 return source_web_contents_->GetController().CanViewSource(); | 1164 return source_web_contents_->GetController().CanViewSource(); |
| 1164 | 1165 |
| 1165 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: | 1166 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: |
| 1166 return IsDevCommandEnabled(id); | 1167 return IsDevCommandEnabled(id); |
| 1167 | 1168 |
| 1168 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: | 1169 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 return (params_.media_flags & WebContextMenuData::MediaCanSave) && | 1287 return (params_.media_flags & WebContextMenuData::MediaCanSave) && |
| 1287 url.is_valid() && ProfileIOData::IsHandledProtocol(url.scheme()) && | 1288 url.is_valid() && ProfileIOData::IsHandledProtocol(url.scheme()) && |
| 1288 // Do not save the preview PDF on the print preview page. | 1289 // Do not save the preview PDF on the print preview page. |
| 1289 !(printing::PrintPreviewTabController::IsPrintPreviewURL(url)); | 1290 !(printing::PrintPreviewTabController::IsPrintPreviewURL(url)); |
| 1290 } | 1291 } |
| 1291 | 1292 |
| 1292 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: | 1293 case IDC_CONTENT_CONTEXT_OPENAVNEWTAB: |
| 1293 return true; | 1294 return true; |
| 1294 | 1295 |
| 1295 case IDC_SAVE_PAGE: { | 1296 case IDC_SAVE_PAGE: { |
| 1296 TabContents* tab_contents = | 1297 CoreTabHelper* core_tab_helper = |
| 1297 TabContents::FromWebContents(source_web_contents_); | 1298 CoreTabHelper::FromWebContents(source_web_contents_); |
| 1298 if (!tab_contents) | 1299 if (!core_tab_helper) |
| 1299 return false; | 1300 return false; |
| 1300 | 1301 |
| 1301 CoreTabHelperDelegate* core_delegate = | 1302 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); |
| 1302 tab_contents->core_tab_helper()->delegate(); | 1303 if (core_delegate && |
| 1303 if (core_delegate && !core_delegate->CanSaveContents(tab_contents)) | 1304 !core_delegate->CanSaveContents(source_web_contents_)) |
| 1304 return false; | 1305 return false; |
| 1305 | 1306 |
| 1306 PrefService* local_state = g_browser_process->local_state(); | 1307 PrefService* local_state = g_browser_process->local_state(); |
| 1307 DCHECK(local_state); | 1308 DCHECK(local_state); |
| 1308 // Test if file-selection dialogs are forbidden by policy. | 1309 // Test if file-selection dialogs are forbidden by policy. |
| 1309 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) | 1310 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
| 1310 return false; | 1311 return false; |
| 1311 | 1312 |
| 1312 // Instead of using GetURL here, we use url() (which is the "real" url of | 1313 // Instead of using GetURL here, we use url() (which is the "real" url of |
| 1313 // the page) from the NavigationEntry because its reflects their origin | 1314 // the page) from the NavigationEntry because its reflects their origin |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2024 source_web_contents_->GetRenderViewHost()-> | 2025 source_web_contents_->GetRenderViewHost()-> |
| 2025 ExecuteMediaPlayerActionAtLocation(location, action); | 2026 ExecuteMediaPlayerActionAtLocation(location, action); |
| 2026 } | 2027 } |
| 2027 | 2028 |
| 2028 void RenderViewContextMenu::PluginActionAt( | 2029 void RenderViewContextMenu::PluginActionAt( |
| 2029 const gfx::Point& location, | 2030 const gfx::Point& location, |
| 2030 const WebPluginAction& action) { | 2031 const WebPluginAction& action) { |
| 2031 source_web_contents_->GetRenderViewHost()-> | 2032 source_web_contents_->GetRenderViewHost()-> |
| 2032 ExecutePluginActionAtLocation(location, action); | 2033 ExecutePluginActionAtLocation(location, action); |
| 2033 } | 2034 } |
| OLD | NEW |