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 <list> | 7 #include <list> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 did_stop_loading_(false), | 123 did_stop_loading_(false), |
124 document_element_available_(false), | 124 document_element_available_(false), |
125 initial_url_(url), | 125 initial_url_(url), |
126 extension_function_dispatcher_(browser_context_, this), | 126 extension_function_dispatcher_(browser_context_, this), |
127 extension_host_type_(host_type) { | 127 extension_host_type_(host_type) { |
128 // Not used for panels, see PanelHost. | 128 // Not used for panels, see PanelHost. |
129 DCHECK(host_type == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || | 129 DCHECK(host_type == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE || |
130 host_type == VIEW_TYPE_EXTENSION_DIALOG || | 130 host_type == VIEW_TYPE_EXTENSION_DIALOG || |
131 host_type == VIEW_TYPE_EXTENSION_INFOBAR || | 131 host_type == VIEW_TYPE_EXTENSION_INFOBAR || |
132 host_type == VIEW_TYPE_EXTENSION_POPUP); | 132 host_type == VIEW_TYPE_EXTENSION_POPUP); |
133 host_contents_.reset(WebContents::Create( | 133 WebContents::CreateParams create_params(browser_context_, site_instance); |
134 WebContents::CreateParams(browser_context_, site_instance))), | 134 if (host_type == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) |
| 135 create_params.initially_hidden = true; |
| 136 host_contents_.reset(WebContents::Create(create_params)); |
135 content::WebContentsObserver::Observe(host_contents_.get()); | 137 content::WebContentsObserver::Observe(host_contents_.get()); |
136 host_contents_->SetDelegate(this); | 138 host_contents_->SetDelegate(this); |
137 SetViewType(host_contents_.get(), host_type); | 139 SetViewType(host_contents_.get(), host_type); |
138 | 140 |
139 render_view_host_ = host_contents_->GetRenderViewHost(); | 141 render_view_host_ = host_contents_->GetRenderViewHost(); |
140 | 142 |
141 // Listen for when an extension is unloaded from the same profile, as it may | 143 // Listen for when an extension is unloaded from the same profile, as it may |
142 // be the same extension that this points to. | 144 // be the same extension that this points to. |
143 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 145 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
144 content::Source<BrowserContext>(browser_context_)); | 146 content::Source<BrowserContext>(browser_context_)); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 } | 422 } |
421 | 423 |
422 void ExtensionHost::RequestMediaAccessPermission( | 424 void ExtensionHost::RequestMediaAccessPermission( |
423 content::WebContents* web_contents, | 425 content::WebContents* web_contents, |
424 const content::MediaStreamRequest& request, | 426 const content::MediaStreamRequest& request, |
425 const content::MediaResponseCallback& callback) { | 427 const content::MediaResponseCallback& callback) { |
426 delegate_->ProcessMediaAccessRequest( | 428 delegate_->ProcessMediaAccessRequest( |
427 web_contents, request, callback, extension()); | 429 web_contents, request, callback, extension()); |
428 } | 430 } |
429 | 431 |
| 432 bool ExtensionHost::IsWebContentsNeverVisible( |
| 433 content::WebContents* web_contents) { |
| 434 ViewType view_type = extensions::GetViewType(web_contents); |
| 435 return view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE; |
| 436 } |
| 437 |
430 } // namespace extensions | 438 } // namespace extensions |
OLD | NEW |