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

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

Issue 2819793002: Translate: do not show the context menu entry when the feature is disabled (Closed)
Patch Set: ifdef macro name update Created 3 years, 8 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 menu_model_.AddItemWithStringId(IDC_SAVE_PAGE, 1238 menu_model_.AddItemWithStringId(IDC_SAVE_PAGE,
1239 IDS_CONTENT_CONTEXT_SAVEPAGEAS); 1239 IDS_CONTENT_CONTEXT_SAVEPAGEAS);
1240 } 1240 }
1241 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); 1241 menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT);
1242 AppendMediaRouterItem(); 1242 AppendMediaRouterItem();
1243 1243
1244 if (TranslateService::IsTranslatableURL(params_.page_url)) { 1244 if (TranslateService::IsTranslatableURL(params_.page_url)) {
1245 std::unique_ptr<translate::TranslatePrefs> prefs( 1245 std::unique_ptr<translate::TranslatePrefs> prefs(
1246 ChromeTranslateClient::CreateTranslatePrefs( 1246 ChromeTranslateClient::CreateTranslatePrefs(
1247 GetPrefs(browser_context_))); 1247 GetPrefs(browser_context_)));
1248 std::string locale = 1248 if (prefs->IsEnabled()) {
Takashi Toyoshima 2017/04/14 10:22:28 This is the main change. Others are just a mechani
lazyboy 2017/04/17 20:25:45 Thanks for pointing this one out.
1249 translate::TranslateManager::GetTargetLanguage(prefs.get()); 1249 std::string locale =
1250 base::string16 language = 1250 translate::TranslateManager::GetTargetLanguage(prefs.get());
1251 l10n_util::GetDisplayNameForLocale(locale, locale, true); 1251 base::string16 language =
1252 menu_model_.AddItem( 1252 l10n_util::GetDisplayNameForLocale(locale, locale, true);
1253 IDC_CONTENT_CONTEXT_TRANSLATE, 1253 menu_model_.AddItem(
1254 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_TRANSLATE, language)); 1254 IDC_CONTENT_CONTEXT_TRANSLATE,
1255 AddGoogleIconToLastMenuItem(&menu_model_); 1255 l10n_util::GetStringFUTF16(IDS_CONTENT_CONTEXT_TRANSLATE, language));
1256 AddGoogleIconToLastMenuItem(&menu_model_);
1257 }
1256 } 1258 }
1257 } 1259 }
1258 1260
1259 void RenderViewContextMenu::AppendExitFullscreenItem() { 1261 void RenderViewContextMenu::AppendExitFullscreenItem() {
1260 Browser* browser = GetBrowser(); 1262 Browser* browser = GetBrowser();
1261 if (!browser) 1263 if (!browser)
1262 return; 1264 return;
1263 1265
1264 // Only show item if in fullscreen mode. 1266 // Only show item if in fullscreen mode.
1265 if (!browser->exclusive_access_manager() 1267 if (!browser->exclusive_access_manager()
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
2499 void RenderViewContextMenu::PluginActionAt( 2501 void RenderViewContextMenu::PluginActionAt(
2500 const gfx::Point& location, 2502 const gfx::Point& location,
2501 const WebPluginAction& action) { 2503 const WebPluginAction& action) {
2502 source_web_contents_->GetRenderViewHost()-> 2504 source_web_contents_->GetRenderViewHost()->
2503 ExecutePluginActionAtLocation(location, action); 2505 ExecutePluginActionAtLocation(location, action);
2504 } 2506 }
2505 2507
2506 Browser* RenderViewContextMenu::GetBrowser() const { 2508 Browser* RenderViewContextMenu::GetBrowser() const {
2507 return chrome::FindBrowserWithWebContents(embedder_web_contents_); 2509 return chrome::FindBrowserWithWebContents(embedder_web_contents_);
2508 } 2510 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698