This source file includes following definitions.
- OnBrowserWindowReady
#include "chrome/browser/extensions/chrome_notification_observer.h"
#include "base/logging.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "content/public/browser/notification_service.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
namespace extensions {
ChromeNotificationObserver::ChromeNotificationObserver() {
registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY,
content::NotificationService::AllSources());
}
ChromeNotificationObserver::~ChromeNotificationObserver() {}
void ChromeNotificationObserver::OnBrowserWindowReady(Browser* browser) {
Profile* profile = browser->profile();
DCHECK(profile);
extensions::ProcessManager* manager =
ExtensionSystem::Get(profile)->process_manager();
if (!manager)
return;
DCHECK_EQ(profile, manager->GetBrowserContext());
manager->OnBrowserWindowReady();
if (profile->IsOffTheRecord()) {
Profile* original_profile = profile->GetOriginalProfile();
extensions::ProcessManager* original_manager =
ExtensionSystem::Get(original_profile)->process_manager();
DCHECK(original_manager);
DCHECK_EQ(original_profile, original_manager->GetBrowserContext());
original_manager->OnBrowserWindowReady();
}
}
void ChromeNotificationObserver::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_BROWSER_WINDOW_READY: {
Browser* browser = content::Source<Browser>(source).ptr();
OnBrowserWindowReady(browser);
break;
}
default:
NOTREACHED();
}
}
}