diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-12 21:53:55 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-12 21:53:55 +0000 |
commit | 3b1c18191d41eac0a551b3009269a259757ca070 (patch) | |
tree | 5f466b716abc81ac3bb67262522ba1af0d699588 /chrome/browser/extensions | |
parent | 7d9ad0b30c0775a7345e965294c9f86bb0d543e5 (diff) | |
download | chromium_src-3b1c18191d41eac0a551b3009269a259757ca070.zip chromium_src-3b1c18191d41eac0a551b3009269a259757ca070.tar.gz chromium_src-3b1c18191d41eac0a551b3009269a259757ca070.tar.bz2 |
Implements the auto-translate on click: if you have translated
a page and are navigating to a new page in the same language by
clicking a link, the new page is automatically translated.
In order to do that I moved the language state from the navigation
entry to some dedicated class that each TabContents owns.
Also added some basic unit-testing for good measure.
BUG=35477
TEST=See bug steps. Run unit-tests.
Review URL: http://codereview.chromium.org/596092
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38961 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/extension_tabs_module.cc | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index f85f054..14621bf 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -883,16 +883,13 @@ bool DetectTabLanguageFunction::RunImpl() { AddRef(); // Balanced in GotLanguage() - NavigationEntry* entry = contents->controller().GetActiveEntry(); - if (entry) { - std::string language = entry->language(); - if (!language.empty()) { - // Delay the callback invocation until after the current JS call has - // returned. - MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( - this, &DetectTabLanguageFunction::GotLanguage, language)); - return true; - } + if (!contents->language_state().original_language().empty()) { + // Delay the callback invocation until after the current JS call has + // returned. + MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( + this, &DetectTabLanguageFunction::GotLanguage, + contents->language_state().original_language())); + return true; } // The tab contents does not know its language yet. Let's wait until it // receives it, or until the tab is closed/navigates to some other page. |