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

Side by Side Diff: chrome/renderer/translate/translate_helper.cc

Issue 14180010: Translate: browser test for Chrome Translate in an isolated world (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix two memory bugs Created 7 years, 4 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
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | chrome/test/data/translate/fr_test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/translate/translate_helper.h" 5 #include "chrome/renderer/translate/translate_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 TranslateCommonMetrics::ReportPageScheme(url.scheme()); 350 TranslateCommonMetrics::ReportPageScheme(url.scheme());
351 351
352 // Set up v8 isolated world with proper content-security-policy and 352 // Set up v8 isolated world with proper content-security-policy and
353 // security-origin. 353 // security-origin.
354 WebFrame* frame = GetMainFrame(); 354 WebFrame* frame = GetMainFrame();
355 if (frame) { 355 if (frame) {
356 frame->setIsolatedWorldContentSecurityPolicy( 356 frame->setIsolatedWorldContentSecurityPolicy(
357 chrome::ISOLATED_WORLD_ID_TRANSLATE, 357 chrome::ISOLATED_WORLD_ID_TRANSLATE,
358 WebString::fromUTF8(kContentSecurityPolicy)); 358 WebString::fromUTF8(kContentSecurityPolicy));
359 359
360 std::string security_origin(kSecurityOrigin);
361 CommandLine* command_line = CommandLine::ForCurrentProcess();
362 if (command_line->HasSwitch(switches::kTranslateSecurityOrigin)) {
363 security_origin =
364 command_line->GetSwitchValueASCII(switches::kTranslateSecurityOrigin);
365 }
360 frame->setIsolatedWorldSecurityOrigin( 366 frame->setIsolatedWorldSecurityOrigin(
361 chrome::ISOLATED_WORLD_ID_TRANSLATE, 367 chrome::ISOLATED_WORLD_ID_TRANSLATE,
362 WebSecurityOrigin::create(GURL(kSecurityOrigin))); 368 WebSecurityOrigin::create(GURL(security_origin)));
363 } 369 }
364 370
365 if (!IsTranslateLibAvailable()) { 371 if (!IsTranslateLibAvailable()) {
366 // Evaluate the script to add the translation related method to the global 372 // Evaluate the script to add the translation related method to the global
367 // context of the page. 373 // context of the page.
368 ExecuteScript(translate_script); 374 ExecuteScript(translate_script);
369 DCHECK(IsTranslateLibAvailable()); 375 DCHECK(IsTranslateLibAvailable());
370 } 376 }
371 377
372 TranslatePageImpl(0); 378 TranslatePageImpl(0);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 498
493 WebFrame* TranslateHelper::GetMainFrame() { 499 WebFrame* TranslateHelper::GetMainFrame() {
494 WebView* web_view = render_view()->GetWebView(); 500 WebView* web_view = render_view()->GetWebView();
495 501
496 // When the tab is going to be closed, the web_view can be NULL. 502 // When the tab is going to be closed, the web_view can be NULL.
497 if (!web_view) 503 if (!web_view)
498 return NULL; 504 return NULL;
499 505
500 return web_view->mainFrame(); 506 return web_view->mainFrame();
501 } 507 }
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | chrome/test/data/translate/fr_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698