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

Unified Diff: chrome/browser/extensions/extension_tabs_module.cc

Issue 523149: Revert 35735 - Relanding the language detection code.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_tabs_module.cc
===================================================================
--- chrome/browser/extensions/extension_tabs_module.cc (revision 35751)
+++ chrome/browser/extensions/extension_tabs_module.cc (working copy)
@@ -839,24 +839,15 @@
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.
+ // 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()));
-
+ NotificationService::AllSources());
+ AddRef(); // balanced in Observe()
return true;
}
@@ -865,16 +856,9 @@
const NotificationDetails& details) {
DCHECK(type == NotificationType::TAB_LANGUAGE_DETERMINED);
std::string language(*Details<std::string>(details).ptr());
- registrar_.Remove(this, NotificationType::TAB_LANGUAGE_DETERMINED, source);
-
- GotLanguage(language);
-}
-
-void DetectTabLanguageFunction::GotLanguage(const std::string& language) {
result_.reset(Value::CreateStringValue(language.c_str()));
SendResponse(true);
-
- Release(); // Balanced in Run()
+ Release(); // balanced in Run()
}
// static helpers
« no previous file with comments | « chrome/browser/extensions/extension_tabs_module.h ('k') | chrome/browser/renderer_host/browser_render_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698