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/developer_private/developer_private_api.
h" | 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api.
h" |
6 | 6 |
7 #include "apps/app_load_service.h" | 7 #include "apps/app_load_service.h" |
8 #include "apps/app_window.h" | 8 #include "apps/app_window.h" |
9 #include "apps/app_window_registry.h" | 9 #include "apps/app_window_registry.h" |
10 #include "apps/saved_files_service.h" | 10 #include "apps/saved_files_service.h" |
11 #include "base/base64.h" | 11 #include "base/base64.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
15 #include "base/files/file_enumerator.h" | 15 #include "base/files/file_enumerator.h" |
16 #include "base/i18n/file_util_icu.h" | 16 #include "base/i18n/file_util_icu.h" |
17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "base/values.h" | 20 #include "base/values.h" |
21 #include "chrome/browser/chrome_notification_types.h" | |
22 #include "chrome/browser/devtools/devtools_window.h" | 21 #include "chrome/browser/devtools/devtools_window.h" |
23 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" | 22 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" |
24 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 23 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
25 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" | 24 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" |
26 #include "chrome/browser/extensions/devtools_util.h" | 25 #include "chrome/browser/extensions/devtools_util.h" |
27 #include "chrome/browser/extensions/extension_disabled_ui.h" | 26 #include "chrome/browser/extensions/extension_disabled_ui.h" |
28 #include "chrome/browser/extensions/extension_error_reporter.h" | 27 #include "chrome/browser/extensions/extension_error_reporter.h" |
29 #include "chrome/browser/extensions/extension_service.h" | 28 #include "chrome/browser/extensions/extension_service.h" |
30 #include "chrome/browser/extensions/extension_ui_util.h" | 29 #include "chrome/browser/extensions/extension_ui_util.h" |
31 #include "chrome/browser/extensions/extension_util.h" | 30 #include "chrome/browser/extensions/extension_util.h" |
(...skipping 15 matching lines...) Expand all Loading... |
47 #include "content/public/browser/render_process_host.h" | 46 #include "content/public/browser/render_process_host.h" |
48 #include "content/public/browser/render_view_host.h" | 47 #include "content/public/browser/render_view_host.h" |
49 #include "content/public/browser/site_instance.h" | 48 #include "content/public/browser/site_instance.h" |
50 #include "content/public/browser/storage_partition.h" | 49 #include "content/public/browser/storage_partition.h" |
51 #include "content/public/browser/web_contents.h" | 50 #include "content/public/browser/web_contents.h" |
52 #include "extensions/browser/extension_error.h" | 51 #include "extensions/browser/extension_error.h" |
53 #include "extensions/browser/extension_prefs.h" | 52 #include "extensions/browser/extension_prefs.h" |
54 #include "extensions/browser/extension_registry.h" | 53 #include "extensions/browser/extension_registry.h" |
55 #include "extensions/browser/extension_system.h" | 54 #include "extensions/browser/extension_system.h" |
56 #include "extensions/browser/management_policy.h" | 55 #include "extensions/browser/management_policy.h" |
| 56 #include "extensions/browser/notification_types.h" |
57 #include "extensions/browser/view_type_utils.h" | 57 #include "extensions/browser/view_type_utils.h" |
58 #include "extensions/common/constants.h" | 58 #include "extensions/common/constants.h" |
59 #include "extensions/common/extension_resource.h" | 59 #include "extensions/common/extension_resource.h" |
60 #include "extensions/common/extension_set.h" | 60 #include "extensions/common/extension_set.h" |
61 #include "extensions/common/install_warning.h" | 61 #include "extensions/common/install_warning.h" |
62 #include "extensions/common/manifest.h" | 62 #include "extensions/common/manifest.h" |
63 #include "extensions/common/manifest_handlers/background_info.h" | 63 #include "extensions/common/manifest_handlers/background_info.h" |
64 #include "extensions/common/manifest_handlers/icons_handler.h" | 64 #include "extensions/common/manifest_handlers/icons_handler.h" |
65 #include "extensions/common/manifest_handlers/incognito_info.h" | 65 #include "extensions/common/manifest_handlers/incognito_info.h" |
66 #include "extensions/common/manifest_handlers/offline_enabled_info.h" | 66 #include "extensions/common/manifest_handlers/offline_enabled_info.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 186 } |
187 | 187 |
188 DeveloperPrivateAPI::DeveloperPrivateAPI(content::BrowserContext* context) | 188 DeveloperPrivateAPI::DeveloperPrivateAPI(content::BrowserContext* context) |
189 : profile_(Profile::FromBrowserContext(context)) { | 189 : profile_(Profile::FromBrowserContext(context)) { |
190 RegisterNotifications(); | 190 RegisterNotifications(); |
191 } | 191 } |
192 | 192 |
193 DeveloperPrivateEventRouter::DeveloperPrivateEventRouter(Profile* profile) | 193 DeveloperPrivateEventRouter::DeveloperPrivateEventRouter(Profile* profile) |
194 : extension_registry_observer_(this), profile_(profile) { | 194 : extension_registry_observer_(this), profile_(profile) { |
195 registrar_.Add(this, | 195 registrar_.Add(this, |
196 chrome::NOTIFICATION_EXTENSION_VIEW_REGISTERED, | 196 extensions::NOTIFICATION_EXTENSION_VIEW_REGISTERED, |
197 content::Source<Profile>(profile_)); | 197 content::Source<Profile>(profile_)); |
198 registrar_.Add(this, | 198 registrar_.Add(this, |
199 chrome::NOTIFICATION_EXTENSION_VIEW_UNREGISTERED, | 199 extensions::NOTIFICATION_EXTENSION_VIEW_UNREGISTERED, |
200 content::Source<Profile>(profile_)); | 200 content::Source<Profile>(profile_)); |
201 | 201 |
202 // TODO(limasdf): Use scoped_observer instead. | 202 // TODO(limasdf): Use scoped_observer instead. |
203 ErrorConsole::Get(profile)->AddObserver(this); | 203 ErrorConsole::Get(profile)->AddObserver(this); |
204 | 204 |
205 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); | 205 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); |
206 } | 206 } |
207 | 207 |
208 DeveloperPrivateEventRouter::~DeveloperPrivateEventRouter() { | 208 DeveloperPrivateEventRouter::~DeveloperPrivateEventRouter() { |
209 ErrorConsole::Get(profile_)->RemoveObserver(this); | 209 ErrorConsole::Get(profile_)->RemoveObserver(this); |
(...skipping 12 matching lines...) Expand all Loading... |
222 void DeveloperPrivateEventRouter::Observe( | 222 void DeveloperPrivateEventRouter::Observe( |
223 int type, | 223 int type, |
224 const content::NotificationSource& source, | 224 const content::NotificationSource& source, |
225 const content::NotificationDetails& details) { | 225 const content::NotificationDetails& details) { |
226 Profile* profile = content::Source<Profile>(source).ptr(); | 226 Profile* profile = content::Source<Profile>(source).ptr(); |
227 CHECK(profile); | 227 CHECK(profile); |
228 CHECK(profile_->IsSameProfile(profile)); | 228 CHECK(profile_->IsSameProfile(profile)); |
229 developer::EventData event_data; | 229 developer::EventData event_data; |
230 | 230 |
231 switch (type) { | 231 switch (type) { |
232 case chrome::NOTIFICATION_EXTENSION_VIEW_UNREGISTERED: { | 232 case extensions::NOTIFICATION_EXTENSION_VIEW_UNREGISTERED: { |
233 event_data.event_type = developer::EVENT_TYPE_VIEW_UNREGISTERED; | 233 event_data.event_type = developer::EVENT_TYPE_VIEW_UNREGISTERED; |
234 event_data.item_id = GetExtensionID( | 234 event_data.item_id = GetExtensionID( |
235 content::Details<const RenderViewHost>(details).ptr()); | 235 content::Details<const RenderViewHost>(details).ptr()); |
236 break; | 236 break; |
237 } | 237 } |
238 case chrome::NOTIFICATION_EXTENSION_VIEW_REGISTERED: { | 238 case extensions::NOTIFICATION_EXTENSION_VIEW_REGISTERED: { |
239 event_data.event_type = developer::EVENT_TYPE_VIEW_REGISTERED; | 239 event_data.event_type = developer::EVENT_TYPE_VIEW_REGISTERED; |
240 event_data.item_id = GetExtensionID( | 240 event_data.item_id = GetExtensionID( |
241 content::Details<const RenderViewHost>(details).ptr()); | 241 content::Details<const RenderViewHost>(details).ptr()); |
242 break; | 242 break; |
243 } | 243 } |
244 default: | 244 default: |
245 NOTREACHED(); | 245 NOTREACHED(); |
246 return; | 246 return; |
247 } | 247 } |
248 | 248 |
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 } | 1398 } |
1399 | 1399 |
1400 error_ui_util::HandleOpenDevTools(dict); | 1400 error_ui_util::HandleOpenDevTools(dict); |
1401 | 1401 |
1402 return true; | 1402 return true; |
1403 } | 1403 } |
1404 | 1404 |
1405 } // namespace api | 1405 } // namespace api |
1406 | 1406 |
1407 } // namespace extensions | 1407 } // namespace extensions |
OLD | NEW |