summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 02:32:24 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 02:32:24 +0000
commitbdd7a12d4abc0b6456f679bb077045a0147c3dfc (patch)
treeb660235491e9e7e7b83ca4952243ffc3c44573c0 /chrome/browser/extensions
parent935d561148669a26ece1535343a7be8bef3392ab (diff)
downloadchromium_src-bdd7a12d4abc0b6456f679bb077045a0147c3dfc.zip
chromium_src-bdd7a12d4abc0b6456f679bb077045a0147c3dfc.tar.gz
chromium_src-bdd7a12d4abc0b6456f679bb077045a0147c3dfc.tar.bz2
Revert 36589 - Still failing the reliability tests.
Another try at landing this. It caused several tests to fails previously. There was a crasher in some Windows code in the CLD that has been removed by the port of the CLD code to Linux and Mac. That should hopefully make everything work now. Enabling language detection on page load. A memory error has been fixed in the CLD library in the meantime. This should hopefully fixes the crashers in the reliability tests. Note that this version is actually simpler than the original review since the detection is now performed in the renderer. (So the CLD code runs sandboxed.) Original review: http://codereview.chromium.org/492024/show BUG=30662 TEST=Run the unittests. TBR=brettw Review URL: http://codereview.chromium.org/552049 TBR=jcampan@chromium.org Review URL: http://codereview.chromium.org/554015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36603 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_tabs_module.cc43
-rw-r--r--chrome/browser/extensions/extension_tabs_module.h1
2 files changed, 10 insertions, 34 deletions
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index 36cf400..8e6bf2f 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -855,49 +855,26 @@ bool DetectTabLanguageFunction::RunImpl() {
return false;
}
- 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;
- }
- }
- // 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.
+ // Figure out what language |contents| contains. This sends an async call via
+ // the browser to the renderer to determine the language of the tab the
+ // renderer has. The renderer sends back the language of the tab after the
+ // tab loads (it may be delayed) to the browser, which in turn notifies this
+ // object that the language has been received.
+ contents->GetPageLanguage();
registrar_.Add(this, NotificationType::TAB_LANGUAGE_DETERMINED,
Source<RenderViewHost>(contents->render_view_host()));
- registrar_.Add(this, NotificationType::TAB_CLOSING,
- Source<NavigationController>(&(contents->controller())));
- registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
- Source<NavigationController>(&(contents->controller())));
+ AddRef(); // balanced in Observe()
return true;
}
void DetectTabLanguageFunction::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- std::string language;
- if (type == NotificationType::TAB_LANGUAGE_DETERMINED)
- language = *Details<std::string>(details).ptr();
-
- registrar_.RemoveAll();
-
- // Call GotLanguage in all cases as we want to guarantee the callback is
- // called for every API call the extension made.
- GotLanguage(language);
-}
-
-void DetectTabLanguageFunction::GotLanguage(const std::string& language) {
+ DCHECK(type == NotificationType::TAB_LANGUAGE_DETERMINED);
+ std::string language(*Details<std::string>(details).ptr());
result_.reset(Value::CreateStringValue(language.c_str()));
SendResponse(true);
-
- Release(); // Balanced in Run()
+ Release(); // balanced in Run()
}
// static helpers
diff --git a/chrome/browser/extensions/extension_tabs_module.h b/chrome/browser/extensions/extension_tabs_module.h
index 5282a17..a4d6f5d 100644
--- a/chrome/browser/extensions/extension_tabs_module.h
+++ b/chrome/browser/extensions/extension_tabs_module.h
@@ -133,7 +133,6 @@ class DetectTabLanguageFunction : public AsyncExtensionFunction,
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
- void GotLanguage(const std::string& language);
NotificationRegistrar registrar_;
DECLARE_EXTENSION_FUNCTION_NAME("tabs.detectLanguage")
};