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 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1885 return false; | 1885 return false; |
1886 } | 1886 } |
1887 | 1887 |
1888 AddRef(); // Balanced in GotLanguage(). | 1888 AddRef(); // Balanced in GotLanguage(). |
1889 | 1889 |
1890 TranslateTabHelper* translate_tab_helper = | 1890 TranslateTabHelper* translate_tab_helper = |
1891 TranslateTabHelper::FromWebContents(contents); | 1891 TranslateTabHelper::FromWebContents(contents); |
1892 if (!translate_tab_helper->language_state().original_language().empty()) { | 1892 if (!translate_tab_helper->language_state().original_language().empty()) { |
1893 // Delay the callback invocation until after the current JS call has | 1893 // Delay the callback invocation until after the current JS call has |
1894 // returned. | 1894 // returned. |
1895 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 1895 base::MessageLoop::current()->PostTask( |
1896 &TabsDetectLanguageFunction::GotLanguage, this, | 1896 FROM_HERE, |
1897 translate_tab_helper->language_state().original_language())); | 1897 base::Bind(&TabsDetectLanguageFunction::GotLanguage, |
| 1898 this, |
| 1899 translate_tab_helper->language_state().original_language())); |
1898 return true; | 1900 return true; |
1899 } | 1901 } |
1900 // The tab contents does not know its language yet. Let's wait until it | 1902 // The tab contents does not know its language yet. Let's wait until it |
1901 // receives it, or until the tab is closed/navigates to some other page. | 1903 // receives it, or until the tab is closed/navigates to some other page. |
1902 registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1904 registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
1903 content::Source<WebContents>(contents)); | 1905 content::Source<WebContents>(contents)); |
1904 registrar_.Add( | 1906 registrar_.Add( |
1905 this, chrome::NOTIFICATION_TAB_CLOSING, | 1907 this, chrome::NOTIFICATION_TAB_CLOSING, |
1906 content::Source<NavigationController>(&(contents->GetController()))); | 1908 content::Source<NavigationController>(&(contents->GetController()))); |
1907 registrar_.Add( | 1909 registrar_.Add( |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2161 extension->id(), | 2163 extension->id(), |
2162 script_type, | 2164 script_type, |
2163 code_string, | 2165 code_string, |
2164 frame_scope, | 2166 frame_scope, |
2165 run_at, | 2167 run_at, |
2166 ScriptExecutor::ISOLATED_WORLD, | 2168 ScriptExecutor::ISOLATED_WORLD, |
2167 false /* is_web_view */, | 2169 false /* is_web_view */, |
2168 base::Bind(&ExecuteCodeInTabFunction::OnExecuteCodeFinished, this)); | 2170 base::Bind(&ExecuteCodeInTabFunction::OnExecuteCodeFinished, this)); |
2169 return true; | 2171 return true; |
2170 } | 2172 } |
OLD | NEW |