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

Side by Side Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 552216: This CL makes the TranslationService class send the text to be translated to ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/tab_contents.h" 5 #include "chrome/browser/tab_contents/tab_contents.h"
6 6
7 #include "app/gfx/text_elider.h" 7 #include "app/gfx/text_elider.h"
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/file_version_info.h" 10 #include "base/file_version_info.h"
(...skipping 27 matching lines...) Expand all
38 #include "chrome/browser/metrics/metric_event_duration_details.h" 38 #include "chrome/browser/metrics/metric_event_duration_details.h"
39 #include "chrome/browser/modal_html_dialog_delegate.h" 39 #include "chrome/browser/modal_html_dialog_delegate.h"
40 #include "chrome/browser/omnibox_search_hint.h" 40 #include "chrome/browser/omnibox_search_hint.h"
41 #include "chrome/browser/password_manager/password_manager.h" 41 #include "chrome/browser/password_manager/password_manager.h"
42 #include "chrome/browser/plugin_installer.h" 42 #include "chrome/browser/plugin_installer.h"
43 #include "chrome/browser/profile.h" 43 #include "chrome/browser/profile.h"
44 #include "chrome/browser/renderer_host/render_process_host.h" 44 #include "chrome/browser/renderer_host/render_process_host.h"
45 #include "chrome/browser/renderer_host/render_widget_host_view.h" 45 #include "chrome/browser/renderer_host/render_widget_host_view.h"
46 #include "chrome/browser/renderer_host/resource_request_details.h" 46 #include "chrome/browser/renderer_host/resource_request_details.h"
47 #include "chrome/browser/renderer_host/site_instance.h" 47 #include "chrome/browser/renderer_host/site_instance.h"
48 #include "chrome/browser/renderer_host/translation_service.h"
48 #include "chrome/browser/renderer_host/web_cache_manager.h" 49 #include "chrome/browser/renderer_host/web_cache_manager.h"
49 #include "chrome/browser/renderer_preferences_util.h" 50 #include "chrome/browser/renderer_preferences_util.h"
50 #include "chrome/browser/sessions/session_types.h" 51 #include "chrome/browser/sessions/session_types.h"
51 #include "chrome/browser/tab_contents/infobar_delegate.h" 52 #include "chrome/browser/tab_contents/infobar_delegate.h"
52 #include "chrome/browser/tab_contents/interstitial_page.h" 53 #include "chrome/browser/tab_contents/interstitial_page.h"
53 #include "chrome/browser/tab_contents/navigation_entry.h" 54 #include "chrome/browser/tab_contents/navigation_entry.h"
54 #include "chrome/browser/tab_contents/provisional_load_details.h" 55 #include "chrome/browser/tab_contents/provisional_load_details.h"
55 #include "chrome/browser/tab_contents/tab_contents_delegate.h" 56 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
56 #include "chrome/browser/tab_contents/tab_contents_view.h" 57 #include "chrome/browser/tab_contents/tab_contents_view.h"
57 #include "chrome/browser/tab_contents/thumbnail_generator.h" 58 #include "chrome/browser/tab_contents/thumbnail_generator.h"
(...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 hs->SetPageContents(url, contents); 1801 hs->SetPageContents(url, contents);
1801 } 1802 }
1802 } 1803 }
1803 1804
1804 NavigationEntry* entry = controller_.GetActiveEntry(); 1805 NavigationEntry* entry = controller_.GetActiveEntry();
1805 if (process()->id() == renderer_process_id && 1806 if (process()->id() == renderer_process_id &&
1806 entry && entry->page_id() == page_id) { 1807 entry && entry->page_id() == page_id) {
1807 entry->set_language(language); 1808 entry->set_language(language);
1808 } 1809 }
1809 1810
1811 if (CommandLine::ForCurrentProcess()->HasSwitch(
1812 switches::kAutoPageTranslate) &&
1813 TranslationService::IsTranslationEnabled()) {
1814 std::string locale = g_browser_process->GetApplicationLocale();
jungshik at Google 2010/01/30 01:27:17 nit: perhaps, s/locale/ui_language/ and s/language
1815 if (!locale.empty() && locale != language) {
1816 // Don't translate the NTP, download page, history...
1817 if (entry && !entry->url().SchemeIs("chrome") &&
1818 TranslationService::ShouldTranslatePage(language, locale)) {
1819 render_view_host()->TranslatePage(entry->page_id(), language, locale);
1820 }
1821 }
1822 }
1823
1810 std::string lang = language; 1824 std::string lang = language;
1811 NotificationService::current()->Notify( 1825 NotificationService::current()->Notify(
1812 NotificationType::TAB_LANGUAGE_DETERMINED, 1826 NotificationType::TAB_LANGUAGE_DETERMINED,
1813 Source<RenderViewHost>(render_view_host()), 1827 Source<RenderViewHost>(render_view_host()),
1814 Details<std::string>(&lang)); 1828 Details<std::string>(&lang));
1815 } 1829 }
1816 1830
1817 void TabContents::DidStartProvisionalLoadForFrame( 1831 void TabContents::DidStartProvisionalLoadForFrame(
1818 RenderViewHost* render_view_host, 1832 RenderViewHost* render_view_host,
1819 bool is_main_frame, 1833 bool is_main_frame,
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
2744 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, success, prompt); 2758 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, success, prompt);
2745 } 2759 }
2746 2760
2747 void TabContents::SetSuppressMessageBoxes(bool suppress_message_boxes) { 2761 void TabContents::SetSuppressMessageBoxes(bool suppress_message_boxes) {
2748 set_suppress_javascript_messages(suppress_message_boxes); 2762 set_suppress_javascript_messages(suppress_message_boxes);
2749 } 2763 }
2750 2764
2751 void TabContents::set_encoding(const std::string& encoding) { 2765 void TabContents::set_encoding(const std::string& encoding) {
2752 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); 2766 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding);
2753 } 2767 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698