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/extension_host.h" | 5 #include "chrome/browser/extensions/extension_host.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/browser_shutdown.h" | 16 #include "chrome/browser/browser_shutdown.h" |
17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/extensions/error_console/error_console.h" |
18 #include "chrome/browser/extensions/event_router.h" | 19 #include "chrome/browser/extensions/event_router.h" |
19 #include "chrome/browser/extensions/extension_process_manager.h" | 20 #include "chrome/browser/extensions/extension_process_manager.h" |
20 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
21 #include "chrome/browser/extensions/extension_system.h" | 22 #include "chrome/browser/extensions/extension_system.h" |
22 #include "chrome/browser/extensions/extension_tab_util.h" | 23 #include "chrome/browser/extensions/extension_tab_util.h" |
23 #include "chrome/browser/extensions/window_controller.h" | 24 #include "chrome/browser/extensions/window_controller.h" |
24 #include "chrome/browser/file_select_helper.h" | 25 #include "chrome/browser/file_select_helper.h" |
25 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 26 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" | 28 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" |
(...skipping 13 matching lines...) Expand all Loading... |
41 #include "chrome/common/url_constants.h" | 42 #include "chrome/common/url_constants.h" |
42 #include "content/public/browser/content_browser_client.h" | 43 #include "content/public/browser/content_browser_client.h" |
43 #include "content/public/browser/native_web_keyboard_event.h" | 44 #include "content/public/browser/native_web_keyboard_event.h" |
44 #include "content/public/browser/notification_service.h" | 45 #include "content/public/browser/notification_service.h" |
45 #include "content/public/browser/render_process_host.h" | 46 #include "content/public/browser/render_process_host.h" |
46 #include "content/public/browser/render_view_host.h" | 47 #include "content/public/browser/render_view_host.h" |
47 #include "content/public/browser/render_widget_host_view.h" | 48 #include "content/public/browser/render_widget_host_view.h" |
48 #include "content/public/browser/site_instance.h" | 49 #include "content/public/browser/site_instance.h" |
49 #include "content/public/browser/web_contents.h" | 50 #include "content/public/browser/web_contents.h" |
50 #include "content/public/browser/web_contents_view.h" | 51 #include "content/public/browser/web_contents_view.h" |
| 52 #include "extensions/browser/extension_error.h" |
51 #include "extensions/browser/view_type_utils.h" | 53 #include "extensions/browser/view_type_utils.h" |
| 54 #include "extensions/common/extension_urls.h" |
52 #include "grit/browser_resources.h" | 55 #include "grit/browser_resources.h" |
53 #include "grit/chromium_strings.h" | 56 #include "grit/chromium_strings.h" |
54 #include "grit/generated_resources.h" | 57 #include "grit/generated_resources.h" |
55 #include "ui/base/keycodes/keyboard_codes.h" | 58 #include "ui/base/keycodes/keyboard_codes.h" |
56 #include "ui/base/l10n/l10n_util.h" | 59 #include "ui/base/l10n/l10n_util.h" |
57 #include "ui/base/resource/resource_bundle.h" | 60 #include "ui/base/resource/resource_bundle.h" |
58 | 61 |
59 #if !defined(OS_ANDROID) | 62 #if !defined(OS_ANDROID) |
60 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 63 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
61 #endif | 64 #endif |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 switch (extension_host_type_) { | 448 switch (extension_host_type_) { |
446 case VIEW_TYPE_EXTENSION_INFOBAR: | 449 case VIEW_TYPE_EXTENSION_INFOBAR: |
447 InsertInfobarCSS(); | 450 InsertInfobarCSS(); |
448 break; | 451 break; |
449 default: | 452 default: |
450 break; // No style sheet for other types, at the moment. | 453 break; // No style sheet for other types, at the moment. |
451 } | 454 } |
452 } | 455 } |
453 } | 456 } |
454 | 457 |
| 458 void ExtensionHost::OnMessageAddedToConsole(const base::string16& source, |
| 459 const base::string16& message, |
| 460 const base::string16& stack_trace, |
| 461 int32 line_number, |
| 462 logging::LogSeverity level) { |
| 463 if (IsSourceFromAnExtension(source)) { |
| 464 ErrorConsole::Get(profile_)->ReportError( |
| 465 scoped_ptr<const ExtensionError>(new JavascriptRuntimeError( |
| 466 profile_->IsOffTheRecord(), |
| 467 source, |
| 468 message, |
| 469 stack_trace, |
| 470 line_number, |
| 471 associated_web_contents_ ? |
| 472 associated_web_contents_->GetLastCommittedURL() : |
| 473 GURL::EmptyGURL(), |
| 474 level))); |
| 475 } |
| 476 } |
| 477 |
455 void ExtensionHost::CloseContents(WebContents* contents) { | 478 void ExtensionHost::CloseContents(WebContents* contents) { |
456 // TODO(mpcomplete): is this check really necessary? | 479 // TODO(mpcomplete): is this check really necessary? |
457 if (extension_host_type_ == VIEW_TYPE_EXTENSION_POPUP || | 480 if (extension_host_type_ == VIEW_TYPE_EXTENSION_POPUP || |
458 extension_host_type_ == VIEW_TYPE_EXTENSION_DIALOG || | 481 extension_host_type_ == VIEW_TYPE_EXTENSION_DIALOG || |
459 extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || | 482 extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || |
460 extension_host_type_ == VIEW_TYPE_EXTENSION_INFOBAR || | 483 extension_host_type_ == VIEW_TYPE_EXTENSION_INFOBAR || |
461 extension_host_type_ == VIEW_TYPE_PANEL) { | 484 extension_host_type_ == VIEW_TYPE_PANEL) { |
462 Close(); | 485 Close(); |
463 } | 486 } |
464 } | 487 } |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 | 692 |
670 void ExtensionHost::RequestMediaAccessPermission( | 693 void ExtensionHost::RequestMediaAccessPermission( |
671 content::WebContents* web_contents, | 694 content::WebContents* web_contents, |
672 const content::MediaStreamRequest& request, | 695 const content::MediaStreamRequest& request, |
673 const content::MediaResponseCallback& callback) { | 696 const content::MediaResponseCallback& callback) { |
674 MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest( | 697 MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest( |
675 web_contents, request, callback, extension()); | 698 web_contents, request, callback, extension()); |
676 } | 699 } |
677 | 700 |
678 } // namespace extensions | 701 } // namespace extensions |
OLD | NEW |