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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #include "chrome/common/extensions/api/windows.h" | 54 #include "chrome/common/extensions/api/windows.h" |
55 #include "chrome/common/extensions/extension.h" | 55 #include "chrome/common/extensions/extension.h" |
56 #include "chrome/common/extensions/extension_constants.h" | 56 #include "chrome/common/extensions/extension_constants.h" |
57 #include "chrome/common/extensions/extension_file_util.h" | 57 #include "chrome/common/extensions/extension_file_util.h" |
58 #include "chrome/common/extensions/extension_l10n_util.h" | 58 #include "chrome/common/extensions/extension_l10n_util.h" |
59 #include "chrome/common/extensions/extension_manifest_constants.h" | 59 #include "chrome/common/extensions/extension_manifest_constants.h" |
60 #include "chrome/common/extensions/extension_messages.h" | 60 #include "chrome/common/extensions/extension_messages.h" |
61 #include "chrome/common/extensions/incognito_handler.h" | 61 #include "chrome/common/extensions/incognito_handler.h" |
62 #include "chrome/common/extensions/message_bundle.h" | 62 #include "chrome/common/extensions/message_bundle.h" |
63 #include "chrome/common/extensions/user_script.h" | 63 #include "chrome/common/extensions/user_script.h" |
| 64 #include "chrome/common/language_detection_details.h" |
64 #include "chrome/common/pref_names.h" | 65 #include "chrome/common/pref_names.h" |
65 #include "chrome/common/url_constants.h" | 66 #include "chrome/common/url_constants.h" |
66 #include "components/user_prefs/pref_registry_syncable.h" | 67 #include "components/user_prefs/pref_registry_syncable.h" |
67 #include "content/public/browser/navigation_controller.h" | 68 #include "content/public/browser/navigation_controller.h" |
68 #include "content/public/browser/navigation_entry.h" | 69 #include "content/public/browser/navigation_entry.h" |
69 #include "content/public/browser/notification_details.h" | 70 #include "content/public/browser/notification_details.h" |
70 #include "content/public/browser/notification_source.h" | 71 #include "content/public/browser/notification_source.h" |
71 #include "content/public/browser/render_view_host.h" | 72 #include "content/public/browser/render_view_host.h" |
72 #include "content/public/browser/render_widget_host_view.h" | 73 #include "content/public/browser/render_widget_host_view.h" |
73 #include "content/public/browser/web_contents.h" | 74 #include "content/public/browser/web_contents.h" |
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1920 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 1921 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
1921 content::Source<NavigationController>(&(contents->GetController()))); | 1922 content::Source<NavigationController>(&(contents->GetController()))); |
1922 return true; | 1923 return true; |
1923 } | 1924 } |
1924 | 1925 |
1925 void TabsDetectLanguageFunction::Observe( | 1926 void TabsDetectLanguageFunction::Observe( |
1926 int type, | 1927 int type, |
1927 const content::NotificationSource& source, | 1928 const content::NotificationSource& source, |
1928 const content::NotificationDetails& details) { | 1929 const content::NotificationDetails& details) { |
1929 std::string language; | 1930 std::string language; |
1930 if (type == chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED) | 1931 if (type == chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED) { |
1931 language = *content::Details<std::string>(details).ptr(); | 1932 const LanguageDetectionDetails* lang_det_details = |
| 1933 content::Details<const LanguageDetectionDetails>(details).ptr(); |
| 1934 language = lang_det_details->adopted_language; |
| 1935 } |
1932 | 1936 |
1933 registrar_.RemoveAll(); | 1937 registrar_.RemoveAll(); |
1934 | 1938 |
1935 // Call GotLanguage in all cases as we want to guarantee the callback is | 1939 // Call GotLanguage in all cases as we want to guarantee the callback is |
1936 // called for every API call the extension made. | 1940 // called for every API call the extension made. |
1937 GotLanguage(language); | 1941 GotLanguage(language); |
1938 } | 1942 } |
1939 | 1943 |
1940 void TabsDetectLanguageFunction::GotLanguage(const std::string& language) { | 1944 void TabsDetectLanguageFunction::GotLanguage(const std::string& language) { |
1941 SetResult(Value::CreateStringValue(language.c_str())); | 1945 SetResult(Value::CreateStringValue(language.c_str())); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 execute_tab_id_ = tab_id; | 2053 execute_tab_id_ = tab_id; |
2050 details_ = details.Pass(); | 2054 details_ = details.Pass(); |
2051 return true; | 2055 return true; |
2052 } | 2056 } |
2053 | 2057 |
2054 bool TabsInsertCSSFunction::ShouldInsertCSS() const { | 2058 bool TabsInsertCSSFunction::ShouldInsertCSS() const { |
2055 return true; | 2059 return true; |
2056 } | 2060 } |
2057 | 2061 |
2058 } // namespace extensions | 2062 } // namespace extensions |
OLD | NEW |