| 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 2037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2048 } | 2048 } |
| 2049 | 2049 |
| 2050 bool RenderViewContextMenu::IsSaveLinkAsEnabled() const { | 2050 bool RenderViewContextMenu::IsSaveLinkAsEnabled() const { |
| 2051 PrefService* local_state = g_browser_process->local_state(); | 2051 PrefService* local_state = g_browser_process->local_state(); |
| 2052 DCHECK(local_state); | 2052 DCHECK(local_state); |
| 2053 // Test if file-selection dialogs are forbidden by policy. | 2053 // Test if file-selection dialogs are forbidden by policy. |
| 2054 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) | 2054 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
| 2055 return false; | 2055 return false; |
| 2056 | 2056 |
| 2057 return params_.link_url.is_valid() && | 2057 return params_.link_url.is_valid() && |
| 2058 ProfileIOData::IsHandledProtocol(params_.link_url.scheme()); | 2058 ProfileIOData::IsBuiltInProtocol(params_.link_url.scheme()); |
| 2059 } | 2059 } |
| 2060 | 2060 |
| 2061 bool RenderViewContextMenu::IsSaveImageAsEnabled() const { | 2061 bool RenderViewContextMenu::IsSaveImageAsEnabled() const { |
| 2062 PrefService* local_state = g_browser_process->local_state(); | 2062 PrefService* local_state = g_browser_process->local_state(); |
| 2063 DCHECK(local_state); | 2063 DCHECK(local_state); |
| 2064 // Test if file-selection dialogs are forbidden by policy. | 2064 // Test if file-selection dialogs are forbidden by policy. |
| 2065 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) | 2065 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
| 2066 return false; | 2066 return false; |
| 2067 | 2067 |
| 2068 return params_.has_image_contents; | 2068 return params_.has_image_contents; |
| 2069 } | 2069 } |
| 2070 | 2070 |
| 2071 bool RenderViewContextMenu::IsSaveAsEnabled() const { | 2071 bool RenderViewContextMenu::IsSaveAsEnabled() const { |
| 2072 PrefService* local_state = g_browser_process->local_state(); | 2072 PrefService* local_state = g_browser_process->local_state(); |
| 2073 DCHECK(local_state); | 2073 DCHECK(local_state); |
| 2074 // Test if file-selection dialogs are forbidden by policy. | 2074 // Test if file-selection dialogs are forbidden by policy. |
| 2075 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) | 2075 if (!local_state->GetBoolean(prefs::kAllowFileSelectionDialogs)) |
| 2076 return false; | 2076 return false; |
| 2077 | 2077 |
| 2078 const GURL& url = params_.src_url; | 2078 const GURL& url = params_.src_url; |
| 2079 bool can_save = | 2079 bool can_save = (params_.media_flags & WebContextMenuData::MediaCanSave) && |
| 2080 (params_.media_flags & WebContextMenuData::MediaCanSave) && | 2080 url.is_valid() && |
| 2081 url.is_valid() && ProfileIOData::IsHandledProtocol(url.scheme()); | 2081 ProfileIOData::IsBuiltInProtocol(url.scheme()); |
| 2082 #if defined(ENABLE_PRINT_PREVIEW) | 2082 #if defined(ENABLE_PRINT_PREVIEW) |
| 2083 // Do not save the preview PDF on the print preview page. | 2083 // Do not save the preview PDF on the print preview page. |
| 2084 can_save = can_save && | 2084 can_save = can_save && |
| 2085 !(printing::PrintPreviewDialogController::IsPrintPreviewURL(url)); | 2085 !(printing::PrintPreviewDialogController::IsPrintPreviewURL(url)); |
| 2086 #endif | 2086 #endif |
| 2087 return can_save; | 2087 return can_save; |
| 2088 } | 2088 } |
| 2089 | 2089 |
| 2090 bool RenderViewContextMenu::IsSavePageEnabled() const { | 2090 bool RenderViewContextMenu::IsSavePageEnabled() const { |
| 2091 CoreTabHelper* core_tab_helper = | 2091 CoreTabHelper* core_tab_helper = |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2496 void RenderViewContextMenu::PluginActionAt( | 2496 void RenderViewContextMenu::PluginActionAt( |
| 2497 const gfx::Point& location, | 2497 const gfx::Point& location, |
| 2498 const WebPluginAction& action) { | 2498 const WebPluginAction& action) { |
| 2499 source_web_contents_->GetRenderViewHost()-> | 2499 source_web_contents_->GetRenderViewHost()-> |
| 2500 ExecutePluginActionAtLocation(location, action); | 2500 ExecutePluginActionAtLocation(location, action); |
| 2501 } | 2501 } |
| 2502 | 2502 |
| 2503 Browser* RenderViewContextMenu::GetBrowser() const { | 2503 Browser* RenderViewContextMenu::GetBrowser() const { |
| 2504 return chrome::FindBrowserWithWebContents(embedder_web_contents_); | 2504 return chrome::FindBrowserWithWebContents(embedder_web_contents_); |
| 2505 } | 2505 } |
| OLD | NEW |