From 398206ce0943c935a8da55d382e60e7be16099cf Mon Sep 17 00:00:00 2001 From: "atwilson@chromium.org" Date: Mon, 21 Jun 2010 01:46:08 +0000 Subject: Added BackgroundContentsService to manage lifecycle of BackgroundContents. If --restore-background-contents flag is passed, stores the URLs of running BackgroundContents in preferences so they can be re-launched when the browser restarts. Moved logic to shutdown background contents into BackgroundContentsService so we can use this to coordinate when to keep the browser process running. BUG=43382 TEST=new tests Review URL: http://codereview.chromium.org/2104018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50329 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/extensions/extensions_ui.cc | 19 ++++++++++++++----- chrome/browser/extensions/extensions_ui.h | 3 +++ 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'chrome/browser/extensions') diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index 8c6664b..5cd3711 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -28,6 +28,7 @@ #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/renderer_host/render_widget_host.h" #include "chrome/browser/renderer_host/render_view_host.h" +#include "chrome/browser/tab_contents/background_contents.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/common/chrome_switches.h" @@ -698,8 +699,13 @@ void ExtensionsDOMHandler::Observe(NotificationType type, // Doing it this way gets everything but causes the page to be rendered // more than we need. It doesn't seem to result in any noticeable flicker. case NotificationType::RENDER_VIEW_HOST_DELETED: - case NotificationType::BACKGROUND_CONTENTS_DELETED: deleting_rvh_ = Details(details).ptr(); + MaybeUpdateAfterNotification(); + break; + case NotificationType::BACKGROUND_CONTENTS_DELETED: + deleting_rvh_ = Details(details)->render_view_host(); + MaybeUpdateAfterNotification(); + break; case NotificationType::EXTENSION_LOADED: case NotificationType::EXTENSION_PROCESS_CREATED: case NotificationType::EXTENSION_UNLOADED: @@ -709,16 +715,19 @@ void ExtensionsDOMHandler::Observe(NotificationType type, case NotificationType::EXTENSION_FUNCTION_DISPATCHER_DESTROYED: case NotificationType::NAV_ENTRY_COMMITTED: case NotificationType::BACKGROUND_CONTENTS_NAVIGATED: - if (!ignore_notifications_ && dom_ui_->tab_contents()) - HandleRequestExtensionsData(NULL); - deleting_rvh_ = NULL; + MaybeUpdateAfterNotification(); break; - default: NOTREACHED(); } } +void ExtensionsDOMHandler::MaybeUpdateAfterNotification() { + if (!ignore_notifications_ && dom_ui_->tab_contents()) + HandleRequestExtensionsData(NULL); + deleting_rvh_ = NULL; +} + static void CreateScriptFileDetailValue( const FilePath& extension_path, const UserScript::FileList& scripts, const wchar_t* key, DictionaryValue* script_data) { diff --git a/chrome/browser/extensions/extensions_ui.h b/chrome/browser/extensions/extensions_ui.h index 449c8da..e85e586 100644 --- a/chrome/browser/extensions/extensions_ui.h +++ b/chrome/browser/extensions/extensions_ui.h @@ -170,6 +170,9 @@ class ExtensionsDOMHandler // Callback for "selectFilePath" message. void HandleSelectFilePathMessage(const Value* value); + // Forces a UI update if appropriate after a notification is received. + void MaybeUpdateAfterNotification(); + // SelectFileDialog::Listener virtual void FileSelected(const FilePath& path, int index, void* params); -- cgit v1.1