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

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

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 8 years, 9 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/renderer/searchbox.cc ('k') | chrome/test/base/browser_with_test_window_test.cc » ('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_helper.h" 5 #include "chrome/renderer/translate_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 326
327 if (!translation_pending_) { 327 if (!translation_pending_) {
328 NOTREACHED(); 328 NOTREACHED();
329 return; 329 return;
330 } 330 }
331 331
332 translation_pending_ = false; 332 translation_pending_ = false;
333 333
334 // Notify the browser we are done. 334 // Notify the browser we are done.
335 render_view()->Send(new ChromeViewHostMsg_PageTranslated( 335 render_view()->Send(new ChromeViewHostMsg_PageTranslated(
336 render_view()->GetRoutingId(), render_view()->GetPageId(), 336 render_view()->GetRoutingID(), render_view()->GetPageId(),
337 actual_source_lang, target_lang_, TranslateErrors::NONE)); 337 actual_source_lang, target_lang_, TranslateErrors::NONE));
338 return; 338 return;
339 } 339 }
340 340
341 // The translation is still pending, check again later. 341 // The translation is still pending, check again later.
342 MessageLoop::current()->PostDelayedTask( 342 MessageLoop::current()->PostDelayedTask(
343 FROM_HERE, 343 FROM_HERE,
344 base::Bind(&TranslateHelper::CheckTranslateStatus, 344 base::Bind(&TranslateHelper::CheckTranslateStatus,
345 weak_method_factory_.GetWeakPtr()), 345 weak_method_factory_.GetWeakPtr()),
346 base::TimeDelta::FromMilliseconds( 346 base::TimeDelta::FromMilliseconds(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 weak_method_factory_.GetWeakPtr()), 423 weak_method_factory_.GetWeakPtr()),
424 base::TimeDelta::FromMilliseconds( 424 base::TimeDelta::FromMilliseconds(
425 DontDelayTasks() ? 0 : kTranslateStatusCheckDelayMs)); 425 DontDelayTasks() ? 0 : kTranslateStatusCheckDelayMs));
426 } 426 }
427 427
428 void TranslateHelper::NotifyBrowserTranslationFailed( 428 void TranslateHelper::NotifyBrowserTranslationFailed(
429 TranslateErrors::Type error) { 429 TranslateErrors::Type error) {
430 translation_pending_ = false; 430 translation_pending_ = false;
431 // Notify the browser there was an error. 431 // Notify the browser there was an error.
432 render_view()->Send(new ChromeViewHostMsg_PageTranslated( 432 render_view()->Send(new ChromeViewHostMsg_PageTranslated(
433 render_view()->GetRoutingId(), page_id_, source_lang_, 433 render_view()->GetRoutingID(), page_id_, source_lang_,
434 target_lang_, error)); 434 target_lang_, error));
435 } 435 }
436 436
437 WebFrame* TranslateHelper::GetMainFrame() { 437 WebFrame* TranslateHelper::GetMainFrame() {
438 WebView* web_view = render_view()->GetWebView(); 438 WebView* web_view = render_view()->GetWebView();
439 if (!web_view) { 439 if (!web_view) {
440 // When the WebView is going away, the render view should have called 440 // When the WebView is going away, the render view should have called
441 // CancelPendingTranslation() which should have stopped any pending work, so 441 // CancelPendingTranslation() which should have stopped any pending work, so
442 // that case should not happen. 442 // that case should not happen.
443 NOTREACHED(); 443 NOTREACHED();
444 return NULL; 444 return NULL;
445 } 445 }
446 return web_view->mainFrame(); 446 return web_view->mainFrame();
447 } 447 }
OLDNEW
« no previous file with comments | « chrome/renderer/searchbox.cc ('k') | chrome/test/base/browser_with_test_window_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698