| 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/api/tabs/tabs_api.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1747 if (contents->GetController().NeedsReload()) { | 1747 if (contents->GetController().NeedsReload()) { |
| 1748 // If the tab hasn't been loaded, don't wait for the tab to load. | 1748 // If the tab hasn't been loaded, don't wait for the tab to load. |
| 1749 error_ = keys::kCannotDetermineLanguageOfUnloadedTab; | 1749 error_ = keys::kCannotDetermineLanguageOfUnloadedTab; |
| 1750 return false; | 1750 return false; |
| 1751 } | 1751 } |
| 1752 | 1752 |
| 1753 AddRef(); // Balanced in GotLanguage(). | 1753 AddRef(); // Balanced in GotLanguage(). |
| 1754 | 1754 |
| 1755 TranslateTabHelper* translate_tab_helper = | 1755 TranslateTabHelper* translate_tab_helper = |
| 1756 TranslateTabHelper::FromWebContents(contents); | 1756 TranslateTabHelper::FromWebContents(contents); |
| 1757 if (!translate_tab_helper->language_state().original_language().empty()) { | 1757 if (!translate_tab_helper->GetLanguageState().original_language().empty()) { |
| 1758 // Delay the callback invocation until after the current JS call has | 1758 // Delay the callback invocation until after the current JS call has |
| 1759 // returned. | 1759 // returned. |
| 1760 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 1760 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
| 1761 &TabsDetectLanguageFunction::GotLanguage, this, | 1761 &TabsDetectLanguageFunction::GotLanguage, this, |
| 1762 translate_tab_helper->language_state().original_language())); | 1762 translate_tab_helper->GetLanguageState().original_language())); |
| 1763 return true; | 1763 return true; |
| 1764 } | 1764 } |
| 1765 // The tab contents does not know its language yet. Let's wait until it | 1765 // The tab contents does not know its language yet. Let's wait until it |
| 1766 // receives it, or until the tab is closed/navigates to some other page. | 1766 // receives it, or until the tab is closed/navigates to some other page. |
| 1767 registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1767 registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
| 1768 content::Source<WebContents>(contents)); | 1768 content::Source<WebContents>(contents)); |
| 1769 registrar_.Add( | 1769 registrar_.Add( |
| 1770 this, chrome::NOTIFICATION_TAB_CLOSING, | 1770 this, chrome::NOTIFICATION_TAB_CLOSING, |
| 1771 content::Source<NavigationController>(&(contents->GetController()))); | 1771 content::Source<NavigationController>(&(contents->GetController()))); |
| 1772 registrar_.Add( | 1772 registrar_.Add( |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1920 execute_tab_id_ = tab_id; | 1920 execute_tab_id_ = tab_id; |
| 1921 details_ = details.Pass(); | 1921 details_ = details.Pass(); |
| 1922 return true; | 1922 return true; |
| 1923 } | 1923 } |
| 1924 | 1924 |
| 1925 bool TabsInsertCSSFunction::ShouldInsertCSS() const { | 1925 bool TabsInsertCSSFunction::ShouldInsertCSS() const { |
| 1926 return true; | 1926 return true; |
| 1927 } | 1927 } |
| 1928 | 1928 |
| 1929 } // namespace extensions | 1929 } // namespace extensions |
| OLD | NEW |