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" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 browser_context_(site_instance->GetBrowserContext()), | 60 browser_context_(site_instance->GetBrowserContext()), |
61 render_view_host_(nullptr), | 61 render_view_host_(nullptr), |
62 has_loaded_once_(false), | 62 has_loaded_once_(false), |
63 document_element_available_(false), | 63 document_element_available_(false), |
64 initial_url_(url), | 64 initial_url_(url), |
65 extension_function_dispatcher_(browser_context_, this), | 65 extension_function_dispatcher_(browser_context_, this), |
66 extension_host_type_(host_type) { | 66 extension_host_type_(host_type) { |
67 // Not used for panels, see PanelHost. | 67 // Not used for panels, see PanelHost. |
68 DCHECK(host_type == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || | 68 DCHECK(host_type == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || |
69 host_type == VIEW_TYPE_EXTENSION_DIALOG || | 69 host_type == VIEW_TYPE_EXTENSION_DIALOG || |
70 host_type == VIEW_TYPE_EXTENSION_POPUP); | 70 host_type == VIEW_TYPE_EXTENSION_POPUP || |
| 71 host_type == VIEW_TYPE_EXTENSION_SIDEBAR); |
71 host_contents_.reset(WebContents::Create( | 72 host_contents_.reset(WebContents::Create( |
72 WebContents::CreateParams(browser_context_, site_instance))), | 73 WebContents::CreateParams(browser_context_, site_instance))); |
73 content::WebContentsObserver::Observe(host_contents_.get()); | 74 content::WebContentsObserver::Observe(host_contents_.get()); |
74 host_contents_->SetDelegate(this); | 75 host_contents_->SetDelegate(this); |
75 SetViewType(host_contents_.get(), host_type); | 76 SetViewType(host_contents_.get(), host_type); |
76 | 77 |
77 render_view_host_ = host_contents_->GetRenderViewHost(); | 78 render_view_host_ = host_contents_->GetRenderViewHost(); |
78 | 79 |
79 // Listen for when an extension is unloaded from the same profile, as it may | 80 // Listen for when an extension is unloaded from the same profile, as it may |
80 // be the same extension that this points to. | 81 // be the same extension that this points to. |
81 ExtensionRegistry::Get(browser_context_)->AddObserver(this); | 82 ExtensionRegistry::Get(browser_context_)->AddObserver(this); |
82 | 83 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 return host_contents()->GetURL(); | 219 return host_contents()->GetURL(); |
219 } | 220 } |
220 | 221 |
221 void ExtensionHost::LoadInitialURL() { | 222 void ExtensionHost::LoadInitialURL() { |
222 load_start_.reset(new base::ElapsedTimer()); | 223 load_start_.reset(new base::ElapsedTimer()); |
223 host_contents_->GetController().LoadURL( | 224 host_contents_->GetController().LoadURL( |
224 initial_url_, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 225 initial_url_, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
225 std::string()); | 226 std::string()); |
226 } | 227 } |
227 | 228 |
| 229 void ExtensionHost::LoadURL(const GURL& url) { |
| 230 initial_url_ = url; |
| 231 LoadInitialURL(); |
| 232 } |
| 233 |
228 bool ExtensionHost::IsBackgroundPage() const { | 234 bool ExtensionHost::IsBackgroundPage() const { |
229 DCHECK_EQ(extension_host_type_, VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 235 DCHECK_EQ(extension_host_type_, VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
230 return true; | 236 return true; |
231 } | 237 } |
232 | 238 |
233 void ExtensionHost::OnExtensionUnloaded( | 239 void ExtensionHost::OnExtensionUnloaded( |
234 content::BrowserContext* browser_context, | 240 content::BrowserContext* browser_context, |
235 const Extension* extension, | 241 const Extension* extension, |
236 UnloadedExtensionInfo::Reason reason) { | 242 UnloadedExtensionInfo::Reason reason) { |
237 // The extension object will be deleted after this notification has been sent. | 243 // The extension object will be deleted after this notification has been sent. |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 } | 479 } |
474 } else if (extension_host_type_ == VIEW_TYPE_EXTENSION_POPUP) { | 480 } else if (extension_host_type_ == VIEW_TYPE_EXTENSION_POPUP) { |
475 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.PopupLoadTime2", | 481 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.PopupLoadTime2", |
476 load_start_->Elapsed()); | 482 load_start_->Elapsed()); |
477 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.PopupCreateTime", | 483 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.PopupCreateTime", |
478 create_start_.Elapsed()); | 484 create_start_.Elapsed()); |
479 } | 485 } |
480 } | 486 } |
481 | 487 |
482 } // namespace extensions | 488 } // namespace extensions |
OLD | NEW |