Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / tab_capture / tab_capture_registry.cc
index 03420bf..09441ca 100644 (file)
@@ -8,7 +8,7 @@
 #include "chrome/browser/chrome_notification_types.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
-#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/notification_details.h"
 #include "content/public/browser/notification_service.h"
@@ -17,7 +17,6 @@
 #include "content/public/browser/web_contents.h"
 #include "content/public/browser/web_contents_observer.h"
 #include "extensions/browser/event_router.h"
-#include "extensions/browser/extension_system.h"
 #include "extensions/common/extension.h"
 
 using content::BrowserThread;
@@ -105,11 +104,11 @@ TabCaptureRequest::TabCaptureRequest(
 TabCaptureRequest::~TabCaptureRequest() {
 }
 
-TabCaptureRegistry::TabCaptureRegistry(Profile* profile)
-    : profile_(profile) {
+TabCaptureRegistry::TabCaptureRegistry(content::BrowserContext* context)
+    : profile_(Profile::FromBrowserContext(context)) {
   MediaCaptureDevicesDispatcher::GetInstance()->AddObserver(this);
   registrar_.Add(this,
-                 chrome::NOTIFICATION_EXTENSION_UNLOADED,
+                 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
                  content::Source<Profile>(profile_));
   registrar_.Add(this,
                  chrome::NOTIFICATION_FULLSCREEN_CHANGED,
@@ -121,22 +120,22 @@ TabCaptureRegistry::~TabCaptureRegistry() {
 }
 
 // static
-TabCaptureRegistry* TabCaptureRegistry::Get(Profile* profile) {
-  return ProfileKeyedAPIFactory<TabCaptureRegistry>::GetForProfile(profile);
+TabCaptureRegistry* TabCaptureRegistry::Get(content::BrowserContext* context) {
+  return BrowserContextKeyedAPIFactory<TabCaptureRegistry>::Get(context);
 }
 
-static base::LazyInstance<ProfileKeyedAPIFactory<TabCaptureRegistry> >
+static base::LazyInstance<BrowserContextKeyedAPIFactory<TabCaptureRegistry> >
     g_factory = LAZY_INSTANCE_INITIALIZER;
 
 // static
-ProfileKeyedAPIFactory<TabCaptureRegistry>*
+BrowserContextKeyedAPIFactory<TabCaptureRegistry>*
 TabCaptureRegistry::GetFactoryInstance() {
   return g_factory.Pointer();
 }
 
 const TabCaptureRegistry::RegistryCaptureInfo
     TabCaptureRegistry::GetCapturedTabs(const std::string& extension_id) const {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   RegistryCaptureInfo list;
   for (ScopedVector<TabCaptureRequest>::const_iterator it = requests_.begin();
        it != requests_.end(); ++it) {
@@ -150,9 +149,9 @@ const TabCaptureRegistry::RegistryCaptureInfo
 void TabCaptureRegistry::Observe(int type,
                                  const content::NotificationSource& source,
                                  const content::NotificationDetails& details) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   switch (type) {
-    case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
+    case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
       // Cleanup all the requested media streams for this extension.
       const std::string& extension_id =
           content::Details<extensions::UnloadedExtensionInfo>(details)->
@@ -230,7 +229,7 @@ bool TabCaptureRegistry::AddRequest(int render_process_id,
 
 bool TabCaptureRegistry::VerifyRequest(int render_process_id,
                                        int render_view_id) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   DVLOG(1) << "Verifying tabCapture request for "
            << render_process_id << ":" << render_view_id;
   // TODO(justinlin): Verify extension too.
@@ -242,7 +241,7 @@ void TabCaptureRegistry::OnRequestUpdate(
     int render_view_id,
     const content::MediaStreamDevice& device,
     const content::MediaRequestState new_state) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   if (device.type != content::MEDIA_TAB_VIDEO_CAPTURE &&
       device.type != content::MEDIA_TAB_AUDIO_CAPTURE) {
     return;
@@ -316,8 +315,7 @@ void TabCaptureRegistry::OnRequestUpdate(
 
 void TabCaptureRegistry::DispatchStatusChangeEvent(
     const TabCaptureRequest* request) const {
-  EventRouter* router = profile_ ?
-      extensions::ExtensionSystem::Get(profile_)->event_router() : NULL;
+  EventRouter* router = profile_ ? EventRouter::Get(profile_) : NULL;
   if (!router)
     return;