OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_tabs_module.h" | 5 #include "chrome/browser/extensions/extension_tabs_module.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 // Delay the callback invocation until after the current JS call has | 1623 // Delay the callback invocation until after the current JS call has |
1624 // returned. | 1624 // returned. |
1625 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 1625 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
1626 &DetectTabLanguageFunction::GotLanguage, this, | 1626 &DetectTabLanguageFunction::GotLanguage, this, |
1627 helper->language_state().original_language())); | 1627 helper->language_state().original_language())); |
1628 return true; | 1628 return true; |
1629 } | 1629 } |
1630 // The tab contents does not know its language yet. Let's wait until it | 1630 // The tab contents does not know its language yet. Let's wait until it |
1631 // receives it, or until the tab is closed/navigates to some other page. | 1631 // receives it, or until the tab is closed/navigates to some other page. |
1632 registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1632 registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
1633 content::Source<TabContents>(contents->tab_contents())); | 1633 content::Source<WebContents>(contents->tab_contents())); |
1634 registrar_.Add( | 1634 registrar_.Add( |
1635 this, content::NOTIFICATION_TAB_CLOSING, | 1635 this, content::NOTIFICATION_TAB_CLOSING, |
1636 content::Source<NavigationController>( | 1636 content::Source<NavigationController>( |
1637 &(contents->tab_contents()->GetController()))); | 1637 &(contents->tab_contents()->GetController()))); |
1638 registrar_.Add( | 1638 registrar_.Add( |
1639 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 1639 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
1640 content::Source<NavigationController>( | 1640 content::Source<NavigationController>( |
1641 &(contents->tab_contents()->GetController()))); | 1641 &(contents->tab_contents()->GetController()))); |
1642 return true; | 1642 return true; |
1643 } | 1643 } |
(...skipping 12 matching lines...) Expand all Loading... |
1656 // called for every API call the extension made. | 1656 // called for every API call the extension made. |
1657 GotLanguage(language); | 1657 GotLanguage(language); |
1658 } | 1658 } |
1659 | 1659 |
1660 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1660 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
1661 result_.reset(Value::CreateStringValue(language.c_str())); | 1661 result_.reset(Value::CreateStringValue(language.c_str())); |
1662 SendResponse(true); | 1662 SendResponse(true); |
1663 | 1663 |
1664 Release(); // Balanced in Run() | 1664 Release(); // Balanced in Run() |
1665 } | 1665 } |
OLD | NEW |