OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/extension_host.h" | 5 #include "extensions/browser/extension_host.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
14 #include "content/public/browser/content_browser_client.h" | 14 #include "content/public/browser/content_browser_client.h" |
15 #include "content/public/browser/native_web_keyboard_event.h" | 15 #include "content/public/browser/native_web_keyboard_event.h" |
16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
17 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
18 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
19 #include "content/public/browser/render_widget_host_view.h" | 19 #include "content/public/browser/render_widget_host_view.h" |
20 #include "content/public/browser/site_instance.h" | 20 #include "content/public/browser/site_instance.h" |
21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/browser/web_contents_source.h" |
22 #include "extensions/browser/bad_message.h" | 23 #include "extensions/browser/bad_message.h" |
23 #include "extensions/browser/event_router.h" | 24 #include "extensions/browser/event_router.h" |
24 #include "extensions/browser/extension_error.h" | 25 #include "extensions/browser/extension_error.h" |
25 #include "extensions/browser/extension_host_delegate.h" | 26 #include "extensions/browser/extension_host_delegate.h" |
26 #include "extensions/browser/extension_host_observer.h" | 27 #include "extensions/browser/extension_host_observer.h" |
27 #include "extensions/browser/extension_host_queue.h" | 28 #include "extensions/browser/extension_host_queue.h" |
28 #include "extensions/browser/extension_registry.h" | 29 #include "extensions/browser/extension_registry.h" |
29 #include "extensions/browser/extension_system.h" | 30 #include "extensions/browser/extension_system.h" |
30 #include "extensions/browser/extension_web_contents_observer.h" | 31 #include "extensions/browser/extension_web_contents_observer.h" |
31 #include "extensions/browser/extensions_browser_client.h" | 32 #include "extensions/browser/extensions_browser_client.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 is_render_view_creation_pending_(false), | 64 is_render_view_creation_pending_(false), |
64 has_loaded_once_(false), | 65 has_loaded_once_(false), |
65 document_element_available_(false), | 66 document_element_available_(false), |
66 initial_url_(url), | 67 initial_url_(url), |
67 extension_host_type_(host_type) { | 68 extension_host_type_(host_type) { |
68 // Not used for panels, see PanelHost. | 69 // Not used for panels, see PanelHost. |
69 DCHECK(host_type == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || | 70 DCHECK(host_type == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || |
70 host_type == VIEW_TYPE_EXTENSION_DIALOG || | 71 host_type == VIEW_TYPE_EXTENSION_DIALOG || |
71 host_type == VIEW_TYPE_EXTENSION_POPUP); | 72 host_type == VIEW_TYPE_EXTENSION_POPUP); |
72 host_contents_.reset(WebContents::Create( | 73 host_contents_.reset(WebContents::Create( |
73 WebContents::CreateParams(browser_context_, site_instance))), | 74 WebContents::CreateParams(browser_context_, site_instance))); |
| 75 WebContentsSource::CreateForWebContentsAndLocation(host_contents_.get(), |
| 76 FROM_HERE); |
74 content::WebContentsObserver::Observe(host_contents_.get()); | 77 content::WebContentsObserver::Observe(host_contents_.get()); |
75 host_contents_->SetDelegate(this); | 78 host_contents_->SetDelegate(this); |
76 SetViewType(host_contents_.get(), host_type); | 79 SetViewType(host_contents_.get(), host_type); |
77 | 80 |
78 render_view_host_ = host_contents_->GetRenderViewHost(); | 81 render_view_host_ = host_contents_->GetRenderViewHost(); |
79 | 82 |
80 // Listen for when an extension is unloaded from the same profile, as it may | 83 // Listen for when an extension is unloaded from the same profile, as it may |
81 // be the same extension that this points to. | 84 // be the same extension that this points to. |
82 ExtensionRegistry::Get(browser_context_)->AddObserver(this); | 85 ExtensionRegistry::Get(browser_context_)->AddObserver(this); |
83 | 86 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 } | 489 } |
487 } else if (extension_host_type_ == VIEW_TYPE_EXTENSION_POPUP) { | 490 } else if (extension_host_type_ == VIEW_TYPE_EXTENSION_POPUP) { |
488 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.PopupLoadTime2", | 491 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.PopupLoadTime2", |
489 load_start_->Elapsed()); | 492 load_start_->Elapsed()); |
490 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.PopupCreateTime", | 493 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.PopupCreateTime", |
491 create_start_.Elapsed()); | 494 create_start_.Elapsed()); |
492 } | 495 } |
493 } | 496 } |
494 | 497 |
495 } // namespace extensions | 498 } // namespace extensions |
OLD | NEW |