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 // Implements the Chrome Extensions Tab Capture API. | 5 // Implements the Chrome Extensions Tab Capture API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h" | 7 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h" |
8 | 8 |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 12 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
13 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry_factory
.h" | 13 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry_factory
.h" |
14 #include "chrome/browser/extensions/browser_event_router.h" | 14 #include "chrome/browser/extensions/browser_event_router.h" |
15 #include "chrome/browser/extensions/event_names.h" | 15 #include "chrome/browser/extensions/event_names.h" |
16 #include "chrome/browser/extensions/extension_tab_id_map.h" | 16 #include "chrome/browser/extensions/extension_tab_id_map.h" |
17 #include "chrome/browser/sessions/session_tab_helper.h" | 17 #include "chrome/browser/sessions/session_tab_helper.h" |
18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
20 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
22 #include "chrome/common/extensions/feature_switch.h" | 22 #include "chrome/common/extensions/feature_switch.h" |
23 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
24 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
| 25 #include "content/public/common/media_stream_request.h" |
25 | 26 |
26 namespace TabCapture = extensions::api::tab_capture; | 27 namespace TabCapture = extensions::api::tab_capture; |
27 namespace GetCapturedTabs = TabCapture::GetCapturedTabs; | 28 namespace GetCapturedTabs = TabCapture::GetCapturedTabs; |
28 | 29 |
29 namespace extensions { | 30 namespace extensions { |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 const char kPermissionError[] = | 34 const char kPermissionError[] = |
34 "Extension does not have permission for tab capture."; | 35 "Extension does not have permission for tab capture."; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 79 } |
79 } | 80 } |
80 | 81 |
81 if (!found_tab) { | 82 if (!found_tab) { |
82 error_ = kErrorTabIdNotFound; | 83 error_ = kErrorTabIdNotFound; |
83 SetResult(base::Value::CreateIntegerValue(0)); | 84 SetResult(base::Value::CreateIntegerValue(0)); |
84 return false; | 85 return false; |
85 } | 86 } |
86 | 87 |
87 std::string device_id = | 88 std::string device_id = |
88 base::StringPrintf("%i:%i", render_process_id, routing_id); | 89 base::StringPrintf("%s%i:%i", content::kMediaStreamTabDeviceScheme, |
| 90 render_process_id, routing_id); |
89 | 91 |
90 bool audio = false; | 92 bool audio = false; |
91 bool video = false; | 93 bool video = false; |
92 if (params->options.get()) { | 94 if (params->options.get()) { |
93 if (params->options->audio.get()) | 95 if (params->options->audio.get()) |
94 audio = *params->options->audio.get(); | 96 audio = *params->options->audio.get(); |
95 if (params->options->video.get()) | 97 if (params->options->video.get()) |
96 video = *params->options->video.get(); | 98 video = *params->options->video.get(); |
97 } | 99 } |
98 | 100 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 info->tab_id = it->tab_id; | 151 info->tab_id = it->tab_id; |
150 info->status = it->status; | 152 info->status = it->status; |
151 list->Append(info->ToValue().release()); | 153 list->Append(info->ToValue().release()); |
152 } | 154 } |
153 | 155 |
154 SetResult(list); | 156 SetResult(list); |
155 return true; | 157 return true; |
156 } | 158 } |
157 | 159 |
158 } // namespace extensions | 160 } // namespace extensions |
OLD | NEW |