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 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 if (embedder_web_contents_->GetController().GetVisibleEntry() == NULL) | 1168 if (embedder_web_contents_->GetController().GetVisibleEntry() == NULL) |
1169 return false; | 1169 return false; |
1170 // Disabled if no browser is associated (e.g. desktop notifications). | 1170 // Disabled if no browser is associated (e.g. desktop notifications). |
1171 if (chrome::FindBrowserWithWebContents(embedder_web_contents_) == NULL) | 1171 if (chrome::FindBrowserWithWebContents(embedder_web_contents_) == NULL) |
1172 return false; | 1172 return false; |
1173 return true; | 1173 return true; |
1174 | 1174 |
1175 case IDC_CONTENT_CONTEXT_TRANSLATE: { | 1175 case IDC_CONTENT_CONTEXT_TRANSLATE: { |
1176 ChromeTranslateClient* chrome_translate_client = | 1176 ChromeTranslateClient* chrome_translate_client = |
1177 ChromeTranslateClient::FromWebContents(embedder_web_contents_); | 1177 ChromeTranslateClient::FromWebContents(embedder_web_contents_); |
1178 if (!chrome_translate_client) | 1178 // If no |chrome_translate_client| attached with this WebContents or we're |
| 1179 // viewing in a MimeHandlerViewGuest translate will be disabled. |
| 1180 if (!chrome_translate_client || |
| 1181 !!extensions::MimeHandlerViewGuest::FromWebContents( |
| 1182 source_web_contents_)) { |
1179 return false; | 1183 return false; |
| 1184 } |
1180 std::string original_lang = | 1185 std::string original_lang = |
1181 chrome_translate_client->GetLanguageState().original_language(); | 1186 chrome_translate_client->GetLanguageState().original_language(); |
1182 std::string target_lang = g_browser_process->GetApplicationLocale(); | 1187 std::string target_lang = g_browser_process->GetApplicationLocale(); |
1183 target_lang = | 1188 target_lang = |
1184 translate::TranslateDownloadManager::GetLanguageCode(target_lang); | 1189 translate::TranslateDownloadManager::GetLanguageCode(target_lang); |
1185 // Note that we intentionally enable the menu even if the original and | 1190 // Note that we intentionally enable the menu even if the original and |
1186 // target languages are identical. This is to give a way to user to | 1191 // target languages are identical. This is to give a way to user to |
1187 // translate a page that might contains text fragments in a different | 1192 // translate a page that might contains text fragments in a different |
1188 // language. | 1193 // language. |
1189 return ((params_.edit_flags & WebContextMenuData::CanTranslate) != 0) && | 1194 return ((params_.edit_flags & WebContextMenuData::CanTranslate) != 0) && |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2005 source_web_contents_->GetRenderViewHost()-> | 2010 source_web_contents_->GetRenderViewHost()-> |
2006 ExecuteMediaPlayerActionAtLocation(location, action); | 2011 ExecuteMediaPlayerActionAtLocation(location, action); |
2007 } | 2012 } |
2008 | 2013 |
2009 void RenderViewContextMenu::PluginActionAt( | 2014 void RenderViewContextMenu::PluginActionAt( |
2010 const gfx::Point& location, | 2015 const gfx::Point& location, |
2011 const WebPluginAction& action) { | 2016 const WebPluginAction& action) { |
2012 source_web_contents_->GetRenderViewHost()-> | 2017 source_web_contents_->GetRenderViewHost()-> |
2013 ExecutePluginActionAtLocation(location, action); | 2018 ExecutePluginActionAtLocation(location, action); |
2014 } | 2019 } |
OLD | NEW |