| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1758 | 1758 |
| 1759 ChromeTranslateClient* chrome_translate_client = | 1759 ChromeTranslateClient* chrome_translate_client = |
| 1760 ChromeTranslateClient::FromWebContents(contents); | 1760 ChromeTranslateClient::FromWebContents(contents); |
| 1761 if (!chrome_translate_client->GetLanguageState() | 1761 if (!chrome_translate_client->GetLanguageState() |
| 1762 .original_language() | 1762 .original_language() |
| 1763 .empty()) { | 1763 .empty()) { |
| 1764 // Delay the callback invocation until after the current JS call has | 1764 // Delay the callback invocation until after the current JS call has |
| 1765 // returned. | 1765 // returned. |
| 1766 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1766 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1767 FROM_HERE, | 1767 FROM_HERE, |
| 1768 base::Bind( | 1768 base::BindOnce( |
| 1769 &TabsDetectLanguageFunction::GotLanguage, this, | 1769 &TabsDetectLanguageFunction::GotLanguage, this, |
| 1770 chrome_translate_client->GetLanguageState().original_language())); | 1770 chrome_translate_client->GetLanguageState().original_language())); |
| 1771 return true; | 1771 return true; |
| 1772 } | 1772 } |
| 1773 // The tab contents does not know its language yet. Let's wait until it | 1773 // The tab contents does not know its language yet. Let's wait until it |
| 1774 // receives it, or until the tab is closed/navigates to some other page. | 1774 // receives it, or until the tab is closed/navigates to some other page. |
| 1775 registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1775 registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
| 1776 content::Source<WebContents>(contents)); | 1776 content::Source<WebContents>(contents)); |
| 1777 registrar_.Add( | 1777 registrar_.Add( |
| 1778 this, chrome::NOTIFICATION_TAB_CLOSING, | 1778 this, chrome::NOTIFICATION_TAB_CLOSING, |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 params->tab_id | 2136 params->tab_id |
| 2137 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, | 2137 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, |
| 2138 base::IntToString(*params->tab_id)) | 2138 base::IntToString(*params->tab_id)) |
| 2139 : keys::kCannotFindTabToDiscard)); | 2139 : keys::kCannotFindTabToDiscard)); |
| 2140 } | 2140 } |
| 2141 | 2141 |
| 2142 TabsDiscardFunction::TabsDiscardFunction() {} | 2142 TabsDiscardFunction::TabsDiscardFunction() {} |
| 2143 TabsDiscardFunction::~TabsDiscardFunction() {} | 2143 TabsDiscardFunction::~TabsDiscardFunction() {} |
| 2144 | 2144 |
| 2145 } // namespace extensions | 2145 } // namespace extensions |
| OLD | NEW |