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 "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "chrome/browser/extensions/event_names.h" | 10 #include "chrome/browser/extensions/event_names.h" |
11 #include "chrome/browser/extensions/event_router.h" | 11 #include "chrome/browser/extensions/event_router.h" |
12 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/profiles/profile_dependency_manager.h" | 14 #include "chrome/browser/profiles/profile_dependency_manager.h" |
15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/common/extensions/extension.h" | 16 #include "chrome/common/extensions/extension.h" |
17 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
18 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
19 | 19 |
20 namespace events = extensions::event_names; | |
21 using content::BrowserThread; | 20 using content::BrowserThread; |
22 | 21 |
23 namespace extensions { | 22 namespace extensions { |
24 | 23 |
25 TabCaptureRegistry::TabCaptureRequest::TabCaptureRequest( | 24 TabCaptureRegistry::TabCaptureRequest::TabCaptureRequest( |
26 const std::string& extension_id, const int tab_id, | 25 const std::string& extension_id, const int tab_id, |
27 tab_capture::TabCaptureState status) | 26 tab_capture::TabCaptureState status) |
28 : extension_id(extension_id), tab_id(tab_id), status(status), | 27 : extension_id(extension_id), tab_id(tab_id), status(status), |
29 last_status(status) { | 28 last_status(status) { |
30 } | 29 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 scoped_ptr<tab_capture::CaptureInfo> info(new tab_capture::CaptureInfo()); | 162 scoped_ptr<tab_capture::CaptureInfo> info(new tab_capture::CaptureInfo()); |
164 info->tab_id = request_info->tab_id; | 163 info->tab_id = request_info->tab_id; |
165 info->status = request_info->status; | 164 info->status = request_info->status; |
166 | 165 |
167 // We will get duplicate events if we requested both audio and video, so only | 166 // We will get duplicate events if we requested both audio and video, so only |
168 // send new events. | 167 // send new events. |
169 if (request_info->last_status != request_info->status) { | 168 if (request_info->last_status != request_info->status) { |
170 scoped_ptr<base::ListValue> args(new ListValue()); | 169 scoped_ptr<base::ListValue> args(new ListValue()); |
171 args->Append(info->ToValue().release()); | 170 args->Append(info->ToValue().release()); |
172 scoped_ptr<Event> event(new Event( | 171 scoped_ptr<Event> event(new Event( |
173 events::kOnTabCaptureStatusChanged, args.Pass())); | 172 event_names::kOnTabCaptureStatusChanged, args.Pass())); |
174 event->restrict_to_profile = profile_; | 173 event->restrict_to_profile = profile_; |
175 router->DispatchEventToExtension(request_info->extension_id, event.Pass()); | 174 router->DispatchEventToExtension(request_info->extension_id, event.Pass()); |
176 } | 175 } |
177 } | 176 } |
178 | 177 |
179 } // namespace extensions | 178 } // namespace extensions |
OLD | NEW |