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

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

Issue 378253002: Fix translate namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
OLDNEW
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 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 menu_model_.AddItemWithStringId(IDC_BACK, IDS_CONTENT_CONTEXT_BACK); 913 menu_model_.AddItemWithStringId(IDC_BACK, IDS_CONTENT_CONTEXT_BACK);
914 menu_model_.AddItemWithStringId(IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD); 914 menu_model_.AddItemWithStringId(IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD);
915 menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD); 915 menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD);
916 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); 916 menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
917 menu_model_.AddItemWithStringId(IDC_SAVE_PAGE, 917 menu_model_.AddItemWithStringId(IDC_SAVE_PAGE,
918 IDS_CONTENT_CONTEXT_SAVEPAGEAS); 918 IDS_CONTENT_CONTEXT_SAVEPAGEAS);
919 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); 919 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT);
920 920
921 if (TranslateService::IsTranslatableURL(params_.page_url)) { 921 if (TranslateService::IsTranslatableURL(params_.page_url)) {
922 std::string locale = g_browser_process->GetApplicationLocale(); 922 std::string locale = g_browser_process->GetApplicationLocale();
923 locale = TranslateDownloadManager::GetLanguageCode(locale); 923 locale = translate::TranslateDownloadManager::GetLanguageCode(locale);
924 base::string16 language = 924 base::string16 language =
925 l10n_util::GetDisplayNameForLocale(locale, locale, true); 925 l10n_util::GetDisplayNameForLocale(locale, locale, true);
926 menu_model_.AddItem( 926 menu_model_.AddItem(
927 IDC_CONTENT_CONTEXT_TRANSLATE, 927 IDC_CONTENT_CONTEXT_TRANSLATE,
928 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_TRANSLATE, language)); 928 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_TRANSLATE, language));
929 } 929 }
930 930
931 menu_model_.AddItemWithStringId(IDC_VIEW_SOURCE, 931 menu_model_.AddItemWithStringId(IDC_VIEW_SOURCE,
932 IDS_CONTENT_CONTEXT_VIEWPAGESOURCE); 932 IDS_CONTENT_CONTEXT_VIEWPAGESOURCE);
933 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_VIEWPAGEINFO, 933 menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_VIEWPAGEINFO,
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 return true; 1172 return true;
1173 1173
1174 case IDC_CONTENT_CONTEXT_TRANSLATE: { 1174 case IDC_CONTENT_CONTEXT_TRANSLATE: {
1175 ChromeTranslateClient* chrome_translate_client = 1175 ChromeTranslateClient* chrome_translate_client =
1176 ChromeTranslateClient::FromWebContents(source_web_contents_); 1176 ChromeTranslateClient::FromWebContents(source_web_contents_);
1177 if (!chrome_translate_client) 1177 if (!chrome_translate_client)
1178 return false; 1178 return false;
1179 std::string original_lang = 1179 std::string original_lang =
1180 chrome_translate_client->GetLanguageState().original_language(); 1180 chrome_translate_client->GetLanguageState().original_language();
1181 std::string target_lang = g_browser_process->GetApplicationLocale(); 1181 std::string target_lang = g_browser_process->GetApplicationLocale();
1182 target_lang = TranslateDownloadManager::GetLanguageCode(target_lang); 1182 target_lang =
1183 translate::TranslateDownloadManager::GetLanguageCode(target_lang);
1183 // Note that we intentionally enable the menu even if the original and 1184 // Note that we intentionally enable the menu even if the original and
1184 // target languages are identical. This is to give a way to user to 1185 // target languages are identical. This is to give a way to user to
1185 // translate a page that might contains text fragments in a different 1186 // translate a page that might contains text fragments in a different
1186 // language. 1187 // language.
1187 return ((params_.edit_flags & WebContextMenuData::CanTranslate) != 0) && 1188 return ((params_.edit_flags & WebContextMenuData::CanTranslate) != 0) &&
1188 !original_lang.empty() && // Did we receive the page language yet? 1189 !original_lang.empty() && // Did we receive the page language yet?
1189 !chrome_translate_client->GetLanguageState().IsPageTranslated() && 1190 !chrome_translate_client->GetLanguageState().IsPageTranslated() &&
1190 !source_web_contents_->GetInterstitialPage() && 1191 !source_web_contents_->GetInterstitialPage() &&
1191 // There are some application locales which can't be used as a 1192 // There are some application locales which can't be used as a
1192 // target language for translation. 1193 // target language for translation.
1193 TranslateDownloadManager::IsSupportedLanguage(target_lang) && 1194 translate::TranslateDownloadManager::IsSupportedLanguage(
1195 target_lang) &&
1194 // Disable on the Instant Extended NTP. 1196 // Disable on the Instant Extended NTP.
1195 !chrome::IsInstantNTP(source_web_contents_); 1197 !chrome::IsInstantNTP(source_web_contents_);
1196 } 1198 }
1197 1199
1198 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB: 1200 case IDC_CONTENT_CONTEXT_OPENLINKNEWTAB:
1199 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW: 1201 case IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW:
1200 return params_.link_url.is_valid(); 1202 return params_.link_url.is_valid();
1201 1203
1202 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION: 1204 case IDC_CONTENT_CONTEXT_COPYLINKLOCATION:
1203 return params_.unfiltered_link_url.is_valid(); 1205 return params_.unfiltered_link_url.is_valid();
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 ChromeTranslateClient* chrome_translate_client = 1727 ChromeTranslateClient* chrome_translate_client =
1726 ChromeTranslateClient::FromWebContents(source_web_contents_); 1728 ChromeTranslateClient::FromWebContents(source_web_contents_);
1727 if (!chrome_translate_client || 1729 if (!chrome_translate_client ||
1728 chrome_translate_client->GetLanguageState().IsPageTranslated() || 1730 chrome_translate_client->GetLanguageState().IsPageTranslated() ||
1729 chrome_translate_client->GetLanguageState().translation_pending()) { 1731 chrome_translate_client->GetLanguageState().translation_pending()) {
1730 return; 1732 return;
1731 } 1733 }
1732 std::string original_lang = 1734 std::string original_lang =
1733 chrome_translate_client->GetLanguageState().original_language(); 1735 chrome_translate_client->GetLanguageState().original_language();
1734 std::string target_lang = g_browser_process->GetApplicationLocale(); 1736 std::string target_lang = g_browser_process->GetApplicationLocale();
1735 target_lang = TranslateDownloadManager::GetLanguageCode(target_lang); 1737 target_lang =
1738 translate::TranslateDownloadManager::GetLanguageCode(target_lang);
1736 // Since the user decided to translate for that language and site, clears 1739 // Since the user decided to translate for that language and site, clears
1737 // any preferences for not translating them. 1740 // any preferences for not translating them.
1738 scoped_ptr<TranslatePrefs> prefs( 1741 scoped_ptr<translate::TranslatePrefs> prefs(
1739 ChromeTranslateClient::CreateTranslatePrefs(profile_->GetPrefs())); 1742 ChromeTranslateClient::CreateTranslatePrefs(profile_->GetPrefs()));
1740 prefs->UnblockLanguage(original_lang); 1743 prefs->UnblockLanguage(original_lang);
1741 prefs->RemoveSiteFromBlacklist(params_.page_url.HostNoBrackets()); 1744 prefs->RemoveSiteFromBlacklist(params_.page_url.HostNoBrackets());
1742 TranslateManager* manager = 1745 translate::TranslateManager* manager =
1743 chrome_translate_client->GetTranslateManager(); 1746 chrome_translate_client->GetTranslateManager();
1744 DCHECK(manager); 1747 DCHECK(manager);
1745 manager->TranslatePage(original_lang, target_lang, true); 1748 manager->TranslatePage(original_lang, target_lang, true);
1746 break; 1749 break;
1747 } 1750 }
1748 1751
1749 case IDC_CONTENT_CONTEXT_RELOADFRAME: 1752 case IDC_CONTENT_CONTEXT_RELOADFRAME:
1750 // We always obey the cache here. 1753 // We always obey the cache here.
1751 // TODO(evanm): Perhaps we could allow shift-clicking the menu item to do 1754 // TODO(evanm): Perhaps we could allow shift-clicking the menu item to do
1752 // a cache-ignoring reload of the frame. 1755 // a cache-ignoring reload of the frame.
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 source_web_contents_->GetRenderViewHost()-> 1995 source_web_contents_->GetRenderViewHost()->
1993 ExecuteMediaPlayerActionAtLocation(location, action); 1996 ExecuteMediaPlayerActionAtLocation(location, action);
1994 } 1997 }
1995 1998
1996 void RenderViewContextMenu::PluginActionAt( 1999 void RenderViewContextMenu::PluginActionAt(
1997 const gfx::Point& location, 2000 const gfx::Point& location,
1998 const WebPluginAction& action) { 2001 const WebPluginAction& action) {
1999 source_web_contents_->GetRenderViewHost()-> 2002 source_web_contents_->GetRenderViewHost()->
2000 ExecutePluginActionAtLocation(location, action); 2003 ExecutePluginActionAtLocation(location, action);
2001 } 2004 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698