OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1793 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 1793 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
1794 &DetectTabLanguageFunction::GotLanguage, this, | 1794 &DetectTabLanguageFunction::GotLanguage, this, |
1795 helper->language_state().original_language())); | 1795 helper->language_state().original_language())); |
1796 return true; | 1796 return true; |
1797 } | 1797 } |
1798 // The tab contents does not know its language yet. Let's wait until it | 1798 // The tab contents does not know its language yet. Let's wait until it |
1799 // receives it, or until the tab is closed/navigates to some other page. | 1799 // receives it, or until the tab is closed/navigates to some other page. |
1800 registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1800 registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
1801 content::Source<WebContents>(contents->web_contents())); | 1801 content::Source<WebContents>(contents->web_contents())); |
1802 registrar_.Add( | 1802 registrar_.Add( |
1803 this, content::NOTIFICATION_TAB_CLOSING, | 1803 this, chrome::NOTIFICATION_TAB_CLOSING, |
1804 content::Source<NavigationController>( | 1804 content::Source<NavigationController>( |
1805 &(contents->web_contents()->GetController()))); | 1805 &(contents->web_contents()->GetController()))); |
1806 registrar_.Add( | 1806 registrar_.Add( |
1807 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 1807 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
1808 content::Source<NavigationController>( | 1808 content::Source<NavigationController>( |
1809 &(contents->web_contents()->GetController()))); | 1809 &(contents->web_contents()->GetController()))); |
1810 return true; | 1810 return true; |
1811 } | 1811 } |
1812 | 1812 |
1813 void DetectTabLanguageFunction::Observe( | 1813 void DetectTabLanguageFunction::Observe( |
(...skipping 10 matching lines...) Expand all Loading... |
1824 // called for every API call the extension made. | 1824 // called for every API call the extension made. |
1825 GotLanguage(language); | 1825 GotLanguage(language); |
1826 } | 1826 } |
1827 | 1827 |
1828 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1828 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
1829 result_.reset(Value::CreateStringValue(language.c_str())); | 1829 result_.reset(Value::CreateStringValue(language.c_str())); |
1830 SendResponse(true); | 1830 SendResponse(true); |
1831 | 1831 |
1832 Release(); // Balanced in Run() | 1832 Release(); // Balanced in Run() |
1833 } | 1833 } |
OLD | NEW |