| Index: chrome/browser/extensions/api/runtime/runtime_api.cc
 | 
| ===================================================================
 | 
| --- chrome/browser/extensions/api/runtime/runtime_api.cc	(revision 152126)
 | 
| +++ chrome/browser/extensions/api/runtime/runtime_api.cc	(working copy)
 | 
| @@ -4,68 +4,26 @@
 | 
|  
 | 
|  #include "chrome/browser/extensions/api/runtime/runtime_api.h"
 | 
|  
 | 
| -#include "chrome/browser/browser_process.h"
 | 
|  #include "chrome/browser/extensions/event_router.h"
 | 
|  #include "chrome/browser/extensions/extension_host.h"
 | 
|  #include "chrome/browser/extensions/extension_process_manager.h"
 | 
| -#include "chrome/browser/extensions/extension_service.h"
 | 
|  #include "chrome/browser/extensions/extension_system.h"
 | 
|  #include "chrome/browser/extensions/lazy_background_task_queue.h"
 | 
|  #include "chrome/browser/profiles/profile.h"
 | 
| -#include "chrome/browser/profiles/profile_manager.h"
 | 
|  #include "chrome/common/extensions/extension.h"
 | 
|  #include "googleurl/src/gurl.h"
 | 
|  
 | 
| -namespace extensions {
 | 
| -
 | 
|  namespace {
 | 
|  
 | 
| -const char kOnStartupEvent[] = "runtime.onStartup";
 | 
|  const char kOnInstalledEvent[] = "runtime.onInstalled";
 | 
|  const char kNoBackgroundPageError[] = "You do not have a background page.";
 | 
|  const char kPageLoadError[] = "Background page failed to load.";
 | 
|  
 | 
| -static void DispatchOnStartupEventImpl(
 | 
| -    Profile* profile,
 | 
| -    const std::string& extension_id,
 | 
| -    bool first_call,
 | 
| -    ExtensionHost* unused) {
 | 
| -  if (g_browser_process->IsShuttingDown() ||
 | 
| -      !g_browser_process->profile_manager()->IsValidProfile(profile))
 | 
| -    return;
 | 
| -  ExtensionSystem* system = ExtensionSystem::Get(profile);
 | 
| -  if (!system)
 | 
| -    return;
 | 
| -
 | 
| -  // If this is a persistent background page, we want to wait for it to load
 | 
| -  // (it might not be ready, since this is startup). But only enqueue once.
 | 
| -  // If it fails to load the first time, don't bother trying again.
 | 
| -  const Extension* extension =
 | 
| -      system->extension_service()->extensions()->GetByID(extension_id);
 | 
| -  if (extension && extension->has_persistent_background_page() && first_call &&
 | 
| -      system->lazy_background_task_queue()->
 | 
| -          ShouldEnqueueTask(profile, extension)) {
 | 
| -    system->lazy_background_task_queue()->AddPendingTask(
 | 
| -        profile, extension_id,
 | 
| -        base::Bind(&DispatchOnStartupEventImpl,
 | 
| -                   profile, extension_id, false));
 | 
| -    return;
 | 
| -  }
 | 
| -
 | 
| -  scoped_ptr<ListValue> event_args(new ListValue());
 | 
| -  system->event_router()->DispatchEventToExtension(
 | 
| -      extension_id, kOnStartupEvent, event_args.Pass(), NULL, GURL());
 | 
|  }
 | 
|  
 | 
| -}  // namespace
 | 
| +namespace extensions {
 | 
|  
 | 
|  // static
 | 
| -void RuntimeEventRouter::DispatchOnStartupEvent(
 | 
| -    Profile* profile, const std::string& extension_id) {
 | 
| -  DispatchOnStartupEventImpl(profile, extension_id, true, NULL);
 | 
| -}
 | 
| -
 | 
| -// static
 | 
|  void RuntimeEventRouter::DispatchOnInstalledEvent(
 | 
|      Profile* profile, const std::string& extension_id) {
 | 
|    ExtensionSystem* system = ExtensionSystem::Get(profile);
 | 
| 
 |