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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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/permissions/permissions_data.h" | 63 #include "chrome/common/extensions/permissions/permissions_data.h" |
64 #include "chrome/common/extensions/user_script.h" | 64 #include "chrome/common/extensions/user_script.h" |
| 65 #include "chrome/common/language_detection_details.h" |
65 #include "chrome/common/pref_names.h" | 66 #include "chrome/common/pref_names.h" |
66 #include "chrome/common/url_constants.h" | 67 #include "chrome/common/url_constants.h" |
67 #include "components/user_prefs/pref_registry_syncable.h" | 68 #include "components/user_prefs/pref_registry_syncable.h" |
68 #include "content/public/browser/navigation_controller.h" | 69 #include "content/public/browser/navigation_controller.h" |
69 #include "content/public/browser/navigation_entry.h" | 70 #include "content/public/browser/navigation_entry.h" |
70 #include "content/public/browser/notification_details.h" | 71 #include "content/public/browser/notification_details.h" |
71 #include "content/public/browser/notification_source.h" | 72 #include "content/public/browser/notification_source.h" |
72 #include "content/public/browser/render_view_host.h" | 73 #include "content/public/browser/render_view_host.h" |
73 #include "content/public/browser/render_widget_host_view.h" | 74 #include "content/public/browser/render_widget_host_view.h" |
74 #include "content/public/browser/web_contents.h" | 75 #include "content/public/browser/web_contents.h" |
(...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1929 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 1930 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
1930 content::Source<NavigationController>(&(contents->GetController()))); | 1931 content::Source<NavigationController>(&(contents->GetController()))); |
1931 return true; | 1932 return true; |
1932 } | 1933 } |
1933 | 1934 |
1934 void TabsDetectLanguageFunction::Observe( | 1935 void TabsDetectLanguageFunction::Observe( |
1935 int type, | 1936 int type, |
1936 const content::NotificationSource& source, | 1937 const content::NotificationSource& source, |
1937 const content::NotificationDetails& details) { | 1938 const content::NotificationDetails& details) { |
1938 std::string language; | 1939 std::string language; |
1939 if (type == chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED) | 1940 if (type == chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED) { |
1940 language = *content::Details<std::string>(details).ptr(); | 1941 const LanguageDetectionDetails* lang_det_details = |
| 1942 content::Details<const LanguageDetectionDetails>(details).ptr(); |
| 1943 language = lang_det_details->adopted_language; |
| 1944 } |
1941 | 1945 |
1942 registrar_.RemoveAll(); | 1946 registrar_.RemoveAll(); |
1943 | 1947 |
1944 // Call GotLanguage in all cases as we want to guarantee the callback is | 1948 // Call GotLanguage in all cases as we want to guarantee the callback is |
1945 // called for every API call the extension made. | 1949 // called for every API call the extension made. |
1946 GotLanguage(language); | 1950 GotLanguage(language); |
1947 } | 1951 } |
1948 | 1952 |
1949 void TabsDetectLanguageFunction::GotLanguage(const std::string& language) { | 1953 void TabsDetectLanguageFunction::GotLanguage(const std::string& language) { |
1950 SetResult(Value::CreateStringValue(language.c_str())); | 1954 SetResult(Value::CreateStringValue(language.c_str())); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2059 execute_tab_id_ = tab_id; | 2063 execute_tab_id_ = tab_id; |
2060 details_ = details.Pass(); | 2064 details_ = details.Pass(); |
2061 return true; | 2065 return true; |
2062 } | 2066 } |
2063 | 2067 |
2064 bool TabsInsertCSSFunction::ShouldInsertCSS() const { | 2068 bool TabsInsertCSSFunction::ShouldInsertCSS() const { |
2065 return true; | 2069 return true; |
2066 } | 2070 } |
2067 | 2071 |
2068 } // namespace extensions | 2072 } // namespace extensions |
OLD | NEW |