Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/browser/extensions/extension_host.cc

Issue 11362166: Merge 166715 - Revert r165772: Keep browser process alive while there are platform apps with backgr… (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1320/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.h" 12 #include "base/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/browser_shutdown.h" 16 #include "chrome/browser/browser_shutdown.h"
17 #include "chrome/browser/extensions/event_router.h" 17 #include "chrome/browser/extensions/event_router.h"
18 #include "chrome/browser/extensions/extension_process_manager.h" 18 #include "chrome/browser/extensions/extension_process_manager.h"
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/extension_system.h" 20 #include "chrome/browser/extensions/extension_system.h"
21 #include "chrome/browser/extensions/extension_tab_util.h" 21 #include "chrome/browser/extensions/extension_tab_util.h"
22 #include "chrome/browser/extensions/window_controller.h" 22 #include "chrome/browser/extensions/window_controller.h"
23 #include "chrome/browser/file_select_helper.h" 23 #include "chrome/browser/file_select_helper.h"
24 #include "chrome/browser/lifetime/application_lifetime.h"
25 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h" 25 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h"
27 #include "chrome/browser/ui/browser.h" 26 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/browser_finder.h" 27 #include "chrome/browser/ui/browser_finder.h"
29 #include "chrome/browser/ui/browser_list.h" 28 #include "chrome/browser/ui/browser_list.h"
30 #include "chrome/browser/ui/browser_window.h" 29 #include "chrome/browser/ui/browser_window.h"
31 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" 30 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
32 #include "chrome/browser/ui/tab_contents/tab_contents.h" 31 #include "chrome/browser/ui/tab_contents/tab_contents.h"
33 #include "chrome/browser/view_type_utils.h" 32 #include "chrome/browser/view_type_utils.h"
34 #include "chrome/common/chrome_constants.h" 33 #include "chrome/common/chrome_constants.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 SiteInstance* site_instance, 133 SiteInstance* site_instance,
135 const GURL& url, 134 const GURL& url,
136 chrome::ViewType host_type) 135 chrome::ViewType host_type)
137 : extension_(extension), 136 : extension_(extension),
138 extension_id_(extension->id()), 137 extension_id_(extension->id()),
139 profile_(Profile::FromBrowserContext( 138 profile_(Profile::FromBrowserContext(
140 site_instance->GetBrowserContext())), 139 site_instance->GetBrowserContext())),
141 render_view_host_(NULL), 140 render_view_host_(NULL),
142 did_stop_loading_(false), 141 did_stop_loading_(false),
143 document_element_available_(false), 142 document_element_available_(false),
144 keeping_browser_process_alive_(false),
145 initial_url_(url), 143 initial_url_(url),
146 ALLOW_THIS_IN_INITIALIZER_LIST( 144 ALLOW_THIS_IN_INITIALIZER_LIST(
147 extension_function_dispatcher_(profile_, this)), 145 extension_function_dispatcher_(profile_, this)),
148 extension_host_type_(host_type), 146 extension_host_type_(host_type),
149 associated_web_contents_(NULL) { 147 associated_web_contents_(NULL) {
150 host_contents_.reset(WebContents::Create( 148 host_contents_.reset(WebContents::Create(
151 profile_, site_instance, MSG_ROUTING_NONE, NULL)); 149 profile_, site_instance, MSG_ROUTING_NONE, NULL));
152 content::WebContentsObserver::Observe(host_contents_.get()); 150 content::WebContentsObserver::Observe(host_contents_.get());
153 host_contents_->SetDelegate(this); 151 host_contents_->SetDelegate(this);
154 chrome::SetViewType(host_contents_.get(), host_type); 152 chrome::SetViewType(host_contents_.get(), host_type);
(...skipping 12 matching lines...) Expand all
167 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE && 165 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE &&
168 extension_ && extension_->has_lazy_background_page()) { 166 extension_ && extension_->has_lazy_background_page()) {
169 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageActiveTime", 167 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageActiveTime",
170 since_created_.Elapsed()); 168 since_created_.Elapsed());
171 } 169 }
172 content::NotificationService::current()->Notify( 170 content::NotificationService::current()->Notify(
173 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, 171 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
174 content::Source<Profile>(profile_), 172 content::Source<Profile>(profile_),
175 content::Details<ExtensionHost>(this)); 173 content::Details<ExtensionHost>(this));
176 ProcessCreationQueue::GetInstance()->Remove(this); 174 ProcessCreationQueue::GetInstance()->Remove(this);
177
178 #if !defined(OS_ANDROID)
179 if (keeping_browser_process_alive_)
180 browser::EndKeepAlive();
181 #endif
182 } 175 }
183 176
184 void ExtensionHost::CreateView(Browser* browser) { 177 void ExtensionHost::CreateView(Browser* browser) {
185 #if defined(TOOLKIT_VIEWS) 178 #if defined(TOOLKIT_VIEWS)
186 view_.reset(new ExtensionViewViews(this, browser)); 179 view_.reset(new ExtensionViewViews(this, browser));
187 // We own |view_|, so don't auto delete when it's removed from the view 180 // We own |view_|, so don't auto delete when it's removed from the view
188 // hierarchy. 181 // hierarchy.
189 view_->set_owned_by_client(); 182 view_->set_owned_by_client();
190 #elif defined(OS_MACOSX) 183 #elif defined(OS_MACOSX)
191 view_.reset(new ExtensionViewMac(this, browser)); 184 view_.reset(new ExtensionViewMac(this, browser));
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 pm->IncrementLazyKeepaliveCount(extension()); 461 pm->IncrementLazyKeepaliveCount(extension());
469 } 462 }
470 463
471 void ExtensionHost::DidCloseJavaScriptDialog() { 464 void ExtensionHost::DidCloseJavaScriptDialog() {
472 ExtensionProcessManager* pm = 465 ExtensionProcessManager* pm =
473 ExtensionSystem::Get(profile_)->process_manager(); 466 ExtensionSystem::Get(profile_)->process_manager();
474 if (pm) 467 if (pm)
475 pm->DecrementLazyKeepaliveCount(extension()); 468 pm->DecrementLazyKeepaliveCount(extension());
476 } 469 }
477 470
478 void ExtensionHost::SetKeepsBrowserProcessAlive() {
479 if (keeping_browser_process_alive_)
480 return;
481
482 #if !defined(OS_ANDROID)
483 keeping_browser_process_alive_ = true;
484 browser::StartKeepAlive();
485 #endif
486 }
487
488 WebContents* ExtensionHost::OpenURLFromTab(WebContents* source, 471 WebContents* ExtensionHost::OpenURLFromTab(WebContents* source,
489 const OpenURLParams& params) { 472 const OpenURLParams& params) {
490 // Whitelist the dispositions we will allow to be opened. 473 // Whitelist the dispositions we will allow to be opened.
491 switch (params.disposition) { 474 switch (params.disposition) {
492 case SINGLETON_TAB: 475 case SINGLETON_TAB:
493 case NEW_FOREGROUND_TAB: 476 case NEW_FOREGROUND_TAB:
494 case NEW_BACKGROUND_TAB: 477 case NEW_BACKGROUND_TAB:
495 case NEW_POPUP: 478 case NEW_POPUP:
496 case NEW_WINDOW: 479 case NEW_WINDOW:
497 case SAVE_TO_DISK: 480 case SAVE_TO_DISK:
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 void ExtensionHost::RequestMediaAccessPermission( 656 void ExtensionHost::RequestMediaAccessPermission(
674 content::WebContents* web_contents, 657 content::WebContents* web_contents,
675 const content::MediaStreamRequest* request, 658 const content::MediaStreamRequest* request,
676 const content::MediaResponseCallback& callback) { 659 const content::MediaResponseCallback& callback) {
677 // For tab capture device, we require the tabCapture permission. 660 // For tab capture device, we require the tabCapture permission.
678 RequestMediaAccessPermissionHelper::AuthorizeRequest( 661 RequestMediaAccessPermissionHelper::AuthorizeRequest(
679 request, callback, extension(), false); 662 request, callback, extension(), false);
680 } 663 }
681 664
682 } // namespace extensions 665 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/extensions/platform_app_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698