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

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: update 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 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 if (!translate_tab_helper) 1199 if (!translate_tab_helper)
1200 return false; 1200 return false;
1201 std::string original_lang = 1201 std::string original_lang =
1202 translate_tab_helper->language_state().original_language(); 1202 translate_tab_helper->language_state().original_language();
1203 std::string target_lang = g_browser_process->GetApplicationLocale(); 1203 std::string target_lang = g_browser_process->GetApplicationLocale();
1204 target_lang = TranslateManager::GetLanguageCode(target_lang); 1204 target_lang = TranslateManager::GetLanguageCode(target_lang);
1205 // Note that we intentionally enable the menu even if the original and 1205 // Note that we intentionally enable the menu even if the original and
1206 // target languages are identical. This is to give a way to user to 1206 // target languages are identical. This is to give a way to user to
1207 // translate a page that might contains text fragments in a different 1207 // translate a page that might contains text fragments in a different
1208 // language. 1208 // language.
1209 return !!(params_.edit_flags & WebContextMenuData::CanTranslate) && 1209 return ((params_.edit_flags & WebContextMenuData::CanTranslate) != 0) &&
1210 translate_tab_helper->language_state().page_translatable() && 1210 translate_tab_helper->language_state().page_translatable() &&
1211 !original_lang.empty() && // Did we receive the page language yet? 1211 !original_lang.empty() && // Did we receive the page language yet?
1212 // Only allow translating languages we explitly support and the
1213 // unknown language (in which case the page language is detected on
1214 // the server side).
1215 (original_lang == chrome::kUnknownLanguageCode ||
1216 TranslateManager::IsSupportedLanguage(original_lang)) &&
1217 !translate_tab_helper->language_state().IsPageTranslated() && 1212 !translate_tab_helper->language_state().IsPageTranslated() &&
1218 !source_web_contents_->GetInterstitialPage() && 1213 !source_web_contents_->GetInterstitialPage() &&
1219 TranslateManager::IsTranslatableURL(params_.page_url) &&
MAD 2013/05/17 17:33:11 Why did you remove this? I don't think we want to
Takashi Toyoshima 2013/05/17 17:57:07 Sorry, I just mistakenly mix a part of another CL
MAD 2013/05/17 18:42:25 Thanks!
Takashi Toyoshima 2013/05/20 06:56:08 Done.
1220 // There are some application locales which can't be used as a 1214 // There are some application locales which can't be used as a
1221 // target language for translation. 1215 // target language for translation.
1222 TranslateManager::IsSupportedLanguage(target_lang); 1216 TranslateManager::IsSupportedLanguage(target_lang);
1223 } 1217 }
1224 1218
1225 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: 1219 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB:
1226 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: 1220 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW:
1227 return params_.link_url.is_valid(); 1221 return params_.link_url.is_valid();
1228 1222
1229 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: 1223 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION:
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 source_web_contents_->GetRenderViewHost()-> 2040 source_web_contents_->GetRenderViewHost()->
2047 ExecuteMediaPlayerActionAtLocation(location, action); 2041 ExecuteMediaPlayerActionAtLocation(location, action);
2048 } 2042 }
2049 2043
2050 void RenderViewContextMenu::PluginActionAt( 2044 void RenderViewContextMenu::PluginActionAt(
2051 const gfx::Point& location, 2045 const gfx::Point& location,
2052 const WebPluginAction& action) { 2046 const WebPluginAction& action) {
2053 source_web_contents_->GetRenderViewHost()-> 2047 source_web_contents_->GetRenderViewHost()->
2054 ExecutePluginActionAtLocation(location, action); 2048 ExecutePluginActionAtLocation(location, action);
2055 } 2049 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698