OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 5 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 base::ListValue* list_of_capture_info) const { | 271 base::ListValue* list_of_capture_info) const { |
272 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 272 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
273 DCHECK(list_of_capture_info); | 273 DCHECK(list_of_capture_info); |
274 list_of_capture_info->Clear(); | 274 list_of_capture_info->Clear(); |
275 for (const LiveRequest* request : requests_) { | 275 for (const LiveRequest* request : requests_) { |
276 if (request->is_anonymous() || !request->is_verified() || | 276 if (request->is_anonymous() || !request->is_verified() || |
277 request->extension_id() != extension_id) | 277 request->extension_id() != extension_id) |
278 continue; | 278 continue; |
279 tab_capture::CaptureInfo info; | 279 tab_capture::CaptureInfo info; |
280 request->GetCaptureInfo(&info); | 280 request->GetCaptureInfo(&info); |
281 list_of_capture_info->Append(info.ToValue().release()); | 281 list_of_capture_info->Append(info.ToValue()); |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 void TabCaptureRegistry::OnExtensionUnloaded( | 285 void TabCaptureRegistry::OnExtensionUnloaded( |
286 content::BrowserContext* browser_context, | 286 content::BrowserContext* browser_context, |
287 const Extension* extension, | 287 const Extension* extension, |
288 UnloadedExtensionInfo::Reason reason) { | 288 UnloadedExtensionInfo::Reason reason) { |
289 // Cleanup all the requested media streams for this extension. | 289 // Cleanup all the requested media streams for this extension. |
290 for (ScopedVector<LiveRequest>::iterator it = requests_.begin(); | 290 for (ScopedVector<LiveRequest>::iterator it = requests_.begin(); |
291 it != requests_.end();) { | 291 it != requests_.end();) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 if (request->is_anonymous()) | 418 if (request->is_anonymous()) |
419 return; | 419 return; |
420 | 420 |
421 EventRouter* router = EventRouter::Get(browser_context_); | 421 EventRouter* router = EventRouter::Get(browser_context_); |
422 if (!router) | 422 if (!router) |
423 return; | 423 return; |
424 | 424 |
425 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 425 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
426 tab_capture::CaptureInfo info; | 426 tab_capture::CaptureInfo info; |
427 request->GetCaptureInfo(&info); | 427 request->GetCaptureInfo(&info); |
428 args->Append(info.ToValue().release()); | 428 args->Append(info.ToValue()); |
429 std::unique_ptr<Event> event( | 429 std::unique_ptr<Event> event( |
430 new Event(events::TAB_CAPTURE_ON_STATUS_CHANGED, | 430 new Event(events::TAB_CAPTURE_ON_STATUS_CHANGED, |
431 tab_capture::OnStatusChanged::kEventName, std::move(args))); | 431 tab_capture::OnStatusChanged::kEventName, std::move(args))); |
432 event->restrict_to_browser_context = browser_context_; | 432 event->restrict_to_browser_context = browser_context_; |
433 | 433 |
434 router->DispatchEventToExtension(request->extension_id(), std::move(event)); | 434 router->DispatchEventToExtension(request->extension_id(), std::move(event)); |
435 } | 435 } |
436 | 436 |
437 TabCaptureRegistry::LiveRequest* TabCaptureRegistry::FindRequest( | 437 TabCaptureRegistry::LiveRequest* TabCaptureRegistry::FindRequest( |
438 const content::WebContents* target_contents) const { | 438 const content::WebContents* target_contents) const { |
(...skipping 23 matching lines...) Expand all Loading... |
462 it != requests_.end(); ++it) { | 462 it != requests_.end(); ++it) { |
463 if ((*it) == request) { | 463 if ((*it) == request) { |
464 requests_.erase(it); | 464 requests_.erase(it); |
465 return; | 465 return; |
466 } | 466 } |
467 } | 467 } |
468 NOTREACHED(); | 468 NOTREACHED(); |
469 } | 469 } |
470 | 470 |
471 } // namespace extensions | 471 } // namespace extensions |
OLD | NEW |