Index: chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc |
diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc b/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc |
index 105a0933e8410cd0f570ba657ae0804b74343794..e57de56044cf58fdba0048df00d1e2482139bc93 100644 |
--- a/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc |
+++ b/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc |
@@ -10,6 +10,7 @@ |
#include "chrome/browser/extensions/event_router.h" |
#include "chrome/browser/extensions/extension_system.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/extensions/extension.h" |
#include "components/browser_context_keyed_service/browser_context_dependency_manager.h" |
@@ -107,7 +108,9 @@ TabCaptureRegistry::TabCaptureRegistry(Profile* profile) |
registrar_.Add(this, |
chrome::NOTIFICATION_EXTENSION_UNLOADED, |
content::Source<Profile>(profile_)); |
- // TODO(justinlin): Hook up HTML5 fullscreen. |
+ registrar_.Add(this, |
+ chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
+ content::NotificationService::AllSources()); |
} |
TabCaptureRegistry::~TabCaptureRegistry() { |
@@ -130,6 +133,7 @@ const TabCaptureRegistry::RegistryCaptureInfo |
void TabCaptureRegistry::Observe(int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
switch (type) { |
case chrome::NOTIFICATION_EXTENSION_UNLOADED: { |
// Cleanup all the requested media streams for this extension. |
@@ -147,7 +151,36 @@ void TabCaptureRegistry::Observe(int type, |
break; |
} |
case chrome::NOTIFICATION_FULLSCREEN_CHANGED: { |
- // TODO(justinlin): Hook up HTML5 fullscreen. |
+ FullscreenController* fullscreen_controller = |
+ content::Source<FullscreenController>(source).ptr(); |
+ const bool is_fullscreen = *(content::Details<bool>(details).ptr()); |
Matt Perry
2013/06/18 21:13:02
fyi, outer parens are unnecessary
justinlin
2013/06/18 21:36:21
Done.
|
+ for (ScopedVector<TabCaptureRequest>::iterator it = requests_.begin(); |
+ it != requests_.end(); ++it) { |
+ // If we are exiting fullscreen mode, we only need to check if any of |
+ // the requests had the fullscreen flag toggled previously. The |
+ // fullscreen controller no longer has the reference to the fullscreen |
+ // web_contents here. |
+ if (!is_fullscreen) { |
+ if ((*it)->fullscreen) { |
+ (*it)->fullscreen = false; |
+ DispatchStatusChangeEvent(*it); |
+ break; |
+ } |
+ continue; |
+ } |
+ |
+ // If we are entering fullscreen mode, find whether the web_contents we |
+ // are capturing entered fullscreen mode. |
+ content::RenderViewHost* const rvh = |
+ content::RenderViewHost::FromID((*it)->render_process_id, |
+ (*it)->render_view_id); |
+ if (rvh && fullscreen_controller->IsFullscreenForTabOrPending( |
+ content::WebContents::FromRenderViewHost(rvh))) { |
+ (*it)->fullscreen = true; |
+ DispatchStatusChangeEvent(*it); |
+ break; |
+ } |
+ } |
break; |
} |
} |