Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Side by Side Diff: chrome/browser/tab_contents/render_view_context_menu.cc

Issue 15295004: Translate: enable against unknown languages with server side detection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (rebase for dcommit) Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/tab_contents/render_view_context_menu.h" 5 #include "chrome/browser/tab_contents/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 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 if (!translate_tab_helper) 1191 if (!translate_tab_helper)
1192 return false; 1192 return false;
1193 std::string original_lang = 1193 std::string original_lang =
1194 translate_tab_helper->language_state().original_language(); 1194 translate_tab_helper->language_state().original_language();
1195 std::string target_lang = g_browser_process->GetApplicationLocale(); 1195 std::string target_lang = g_browser_process->GetApplicationLocale();
1196 target_lang = TranslateManager::GetLanguageCode(target_lang); 1196 target_lang = TranslateManager::GetLanguageCode(target_lang);
1197 // Note that we intentionally enable the menu even if the original and 1197 // Note that we intentionally enable the menu even if the original and
1198 // target languages are identical. This is to give a way to user to 1198 // target languages are identical. This is to give a way to user to
1199 // translate a page that might contains text fragments in a different 1199 // translate a page that might contains text fragments in a different
1200 // language. 1200 // language.
1201 return !!(params_.edit_flags & WebContextMenuData::CanTranslate) && 1201 return ((params_.edit_flags & WebContextMenuData::CanTranslate) != 0) &&
1202 !original_lang.empty() && // Did we receive the page language yet? 1202 !original_lang.empty() && // Did we receive the page language yet?
1203 // Only allow translating languages we explitly support and the
1204 // unknown language (in which case the page language is detected on
1205 // the server side).
1206 (original_lang == chrome::kUnknownLanguageCode ||
1207 TranslateManager::IsSupportedLanguage(original_lang)) &&
1208 !translate_tab_helper->language_state().IsPageTranslated() && 1203 !translate_tab_helper->language_state().IsPageTranslated() &&
1209 !source_web_contents_->GetInterstitialPage() && 1204 !source_web_contents_->GetInterstitialPage() &&
1210 // There are some application locales which can't be used as a 1205 // There are some application locales which can't be used as a
1211 // target language for translation. 1206 // target language for translation.
1212 TranslateManager::IsSupportedLanguage(target_lang); 1207 TranslateManager::IsSupportedLanguage(target_lang);
1213 } 1208 }
1214 1209
1215 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: 1210 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB:
1216 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: 1211 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW:
1217 return params_.link_url.is_valid(); 1212 return params_.link_url.is_valid();
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 source_web_contents_->GetRenderViewHost()-> 2038 source_web_contents_->GetRenderViewHost()->
2044 ExecuteMediaPlayerActionAtLocation(location, action); 2039 ExecuteMediaPlayerActionAtLocation(location, action);
2045 } 2040 }
2046 2041
2047 void RenderViewContextMenu::PluginActionAt( 2042 void RenderViewContextMenu::PluginActionAt(
2048 const gfx::Point& location, 2043 const gfx::Point& location,
2049 const WebPluginAction& action) { 2044 const WebPluginAction& action) {
2050 source_web_contents_->GetRenderViewHost()-> 2045 source_web_contents_->GetRenderViewHost()->
2051 ExecutePluginActionAtLocation(location, action); 2046 ExecutePluginActionAtLocation(location, action);
2052 } 2047 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/translate.js ('k') | chrome/browser/translate/translate_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698