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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "chrome/browser/profiles/profile_io_data.h" | 46 #include "chrome/browser/profiles/profile_io_data.h" |
47 #include "chrome/browser/profiles/profile_manager.h" | 47 #include "chrome/browser/profiles/profile_manager.h" |
48 #include "chrome/browser/profiles/profile_window.h" | 48 #include "chrome/browser/profiles/profile_window.h" |
49 #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory
.h" | 49 #include "chrome/browser/renderer_context_menu/context_menu_content_type_factory
.h" |
50 #include "chrome/browser/renderer_context_menu/open_with_menu_factory.h" | 50 #include "chrome/browser/renderer_context_menu/open_with_menu_factory.h" |
51 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" | 51 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" |
52 #include "chrome/browser/search/search.h" | 52 #include "chrome/browser/search/search.h" |
53 #include "chrome/browser/search_engines/template_url_service_factory.h" | 53 #include "chrome/browser/search_engines/template_url_service_factory.h" |
54 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 54 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
55 #include "chrome/browser/spellchecker/spellcheck_service.h" | 55 #include "chrome/browser/spellchecker/spellcheck_service.h" |
56 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | |
57 #include "chrome/browser/tab_contents/retargeting_details.h" | 56 #include "chrome/browser/tab_contents/retargeting_details.h" |
58 #include "chrome/browser/translate/chrome_translate_client.h" | 57 #include "chrome/browser/translate/chrome_translate_client.h" |
59 #include "chrome/browser/translate/translate_service.h" | 58 #include "chrome/browser/translate/translate_service.h" |
60 #include "chrome/browser/ui/browser.h" | 59 #include "chrome/browser/ui/browser.h" |
61 #include "chrome/browser/ui/browser_commands.h" | 60 #include "chrome/browser/ui/browser_commands.h" |
62 #include "chrome/browser/ui/browser_finder.h" | 61 #include "chrome/browser/ui/browser_finder.h" |
63 #include "chrome/browser/ui/browser_navigator_params.h" | 62 #include "chrome/browser/ui/browser_navigator_params.h" |
64 #include "chrome/browser/ui/chrome_pages.h" | 63 #include "chrome/browser/ui/chrome_pages.h" |
65 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 64 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
66 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 65 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 using base::UserMetricsAction; | 155 using base::UserMetricsAction; |
157 using blink::WebContextMenuData; | 156 using blink::WebContextMenuData; |
158 using blink::WebMediaPlayerAction; | 157 using blink::WebMediaPlayerAction; |
159 using blink::WebPluginAction; | 158 using blink::WebPluginAction; |
160 using blink::WebString; | 159 using blink::WebString; |
161 using blink::WebURL; | 160 using blink::WebURL; |
162 using content::BrowserContext; | 161 using content::BrowserContext; |
163 using content::ChildProcessSecurityPolicy; | 162 using content::ChildProcessSecurityPolicy; |
164 using content::DownloadManager; | 163 using content::DownloadManager; |
165 using content::DownloadUrlParameters; | 164 using content::DownloadUrlParameters; |
166 using content::NavigationController; | |
167 using content::NavigationEntry; | 165 using content::NavigationEntry; |
168 using content::OpenURLParams; | 166 using content::OpenURLParams; |
169 using content::RenderFrameHost; | 167 using content::RenderFrameHost; |
170 using content::RenderViewHost; | 168 using content::RenderViewHost; |
171 using content::SSLStatus; | 169 using content::SSLStatus; |
172 using content::WebContents; | 170 using content::WebContents; |
173 using extensions::ContextMenuMatcher; | 171 using extensions::ContextMenuMatcher; |
174 using extensions::Extension; | 172 using extensions::Extension; |
175 using extensions::MenuItem; | 173 using extensions::MenuItem; |
176 using extensions::MenuManager; | 174 using extensions::MenuManager; |
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 } | 1457 } |
1460 return (params_.media_type != WebContextMenuData::MediaTypePlugin) && | 1458 return (params_.media_type != WebContextMenuData::MediaTypePlugin) && |
1461 embedder_web_contents_->GetController().CanViewSource(); | 1459 embedder_web_contents_->GetController().CanViewSource(); |
1462 | 1460 |
1463 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: | 1461 case IDC_CONTENT_CONTEXT_INSPECTELEMENT: |
1464 case IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE: | 1462 case IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE: |
1465 case IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP: | 1463 case IDC_CONTENT_CONTEXT_RELOAD_PACKAGED_APP: |
1466 case IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP: | 1464 case IDC_CONTENT_CONTEXT_RESTART_PACKAGED_APP: |
1467 return IsDevCommandEnabled(id); | 1465 return IsDevCommandEnabled(id); |
1468 | 1466 |
1469 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: | |
1470 if (embedder_web_contents_->GetController().GetVisibleEntry() == NULL) | |
1471 return false; | |
1472 // Disabled if no browser is associated (e.g. desktop notifications). | |
1473 if (chrome::FindBrowserWithWebContents(embedder_web_contents_) == NULL) | |
1474 return false; | |
1475 return true; | |
1476 | |
1477 case IDC_CONTENT_CONTEXT_TRANSLATE: { | 1467 case IDC_CONTENT_CONTEXT_TRANSLATE: { |
1478 ChromeTranslateClient* chrome_translate_client = | 1468 ChromeTranslateClient* chrome_translate_client = |
1479 ChromeTranslateClient::FromWebContents(embedder_web_contents_); | 1469 ChromeTranslateClient::FromWebContents(embedder_web_contents_); |
1480 // If no |chrome_translate_client| attached with this WebContents or we're | 1470 // If no |chrome_translate_client| attached with this WebContents or we're |
1481 // viewing in a MimeHandlerViewGuest translate will be disabled. | 1471 // viewing in a MimeHandlerViewGuest translate will be disabled. |
1482 if (!chrome_translate_client || | 1472 if (!chrome_translate_client || |
1483 !!extensions::MimeHandlerViewGuest::FromWebContents( | 1473 !!extensions::MimeHandlerViewGuest::FromWebContents( |
1484 source_web_contents_)) { | 1474 source_web_contents_)) { |
1485 return false; | 1475 return false; |
1486 } | 1476 } |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2061 case IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE: { | 2051 case IDC_CONTENT_CONTEXT_INSPECTBACKGROUNDPAGE: { |
2062 const Extension* platform_app = GetExtension(); | 2052 const Extension* platform_app = GetExtension(); |
2063 DCHECK(platform_app); | 2053 DCHECK(platform_app); |
2064 DCHECK(platform_app->is_platform_app()); | 2054 DCHECK(platform_app->is_platform_app()); |
2065 | 2055 |
2066 extensions::devtools_util::InspectBackgroundPage(platform_app, | 2056 extensions::devtools_util::InspectBackgroundPage(platform_app, |
2067 GetProfile()); | 2057 GetProfile()); |
2068 break; | 2058 break; |
2069 } | 2059 } |
2070 | 2060 |
2071 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: { | |
2072 NavigationController* controller = | |
2073 &embedder_web_contents_->GetController(); | |
2074 // Important to use GetVisibleEntry to match what's showing in the | |
2075 // omnibox. This may return null. | |
2076 NavigationEntry* nav_entry = controller->GetVisibleEntry(); | |
2077 if (!nav_entry) | |
2078 return; | |
2079 Browser* browser = | |
2080 chrome::FindBrowserWithWebContents(embedder_web_contents_); | |
2081 ChromeSecurityStateModelClient* security_model_client = | |
2082 ChromeSecurityStateModelClient::FromWebContents( | |
2083 embedder_web_contents_); | |
2084 DCHECK(security_model_client); | |
2085 chrome::ShowWebsiteSettings(browser, embedder_web_contents_, | |
2086 nav_entry->GetURL(), | |
2087 security_model_client->GetSecurityInfo()); | |
2088 break; | |
2089 } | |
2090 | |
2091 case IDC_CONTENT_CONTEXT_TRANSLATE: { | 2061 case IDC_CONTENT_CONTEXT_TRANSLATE: { |
2092 // A translation might have been triggered by the time the menu got | 2062 // A translation might have been triggered by the time the menu got |
2093 // selected, do nothing in that case. | 2063 // selected, do nothing in that case. |
2094 ChromeTranslateClient* chrome_translate_client = | 2064 ChromeTranslateClient* chrome_translate_client = |
2095 ChromeTranslateClient::FromWebContents(embedder_web_contents_); | 2065 ChromeTranslateClient::FromWebContents(embedder_web_contents_); |
2096 if (!chrome_translate_client || | 2066 if (!chrome_translate_client || |
2097 chrome_translate_client->GetLanguageState().IsPageTranslated() || | 2067 chrome_translate_client->GetLanguageState().IsPageTranslated() || |
2098 chrome_translate_client->GetLanguageState().translation_pending()) { | 2068 chrome_translate_client->GetLanguageState().translation_pending()) { |
2099 return; | 2069 return; |
2100 } | 2070 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2309 source_web_contents_->GetRenderViewHost()-> | 2279 source_web_contents_->GetRenderViewHost()-> |
2310 ExecuteMediaPlayerActionAtLocation(location, action); | 2280 ExecuteMediaPlayerActionAtLocation(location, action); |
2311 } | 2281 } |
2312 | 2282 |
2313 void RenderViewContextMenu::PluginActionAt( | 2283 void RenderViewContextMenu::PluginActionAt( |
2314 const gfx::Point& location, | 2284 const gfx::Point& location, |
2315 const WebPluginAction& action) { | 2285 const WebPluginAction& action) { |
2316 source_web_contents_->GetRenderViewHost()-> | 2286 source_web_contents_->GetRenderViewHost()-> |
2317 ExecutePluginActionAtLocation(location, action); | 2287 ExecutePluginActionAtLocation(location, action); |
2318 } | 2288 } |
OLD | NEW |