Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/browser/extensions/api/tab_capture/tab_capture_api.cc

Issue 10928043: Media Related changes for TabCapture API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Implements the Chrome Extensions Tab Capture API.
6
7 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h"
8
9 #include "base/platform_file.h"
10 #include "base/stringprintf.h"
11 #include "base/values.h"
12 #include "chrome/browser/extensions/browser_event_router.h"
13 #include "chrome/browser/extensions/event_names.h"
14 #include "chrome/browser/extensions/extension_tab_id_map.h"
15
16 namespace TabCapture = extensions::api::experimental_tab_capture;
17 namespace GetTabMedia = TabCapture::GetTabMedia;
18 namespace GetCapturedTabs = TabCapture::GetCapturedTabs;
19
20 namespace extensions {
21
22 namespace {
23
24 const char kErrorTabIdNotFound[] = "Could not find the specified tab.";
25
26 } // namespace
27
28 TabCaptureAsyncApiFunction::TabCaptureAsyncApiFunction() {
29 }
30
31 TabCaptureAsyncApiFunction::~TabCaptureAsyncApiFunction() {
32 }
33
34 bool TabCaptureAsyncApiFunction::Respond() {
35 return error_.empty();
36 }
37
38 TabCaptureGetTabMediaFunction::TabCaptureGetTabMediaFunction() {
39 }
40
41 TabCaptureGetTabMediaFunction::~TabCaptureGetTabMediaFunction() {
42 }
43
44 bool TabCaptureGetTabMediaFunction::Prepare() {
45 params_ = GetTabMedia::Params::Create(*args_);
46 EXTENSION_FUNCTION_VALIDATE(params_.get());
47 return true;
48 }
49
50 void TabCaptureGetTabMediaFunction::Work() {
51 ExtensionTabIdMap* tab_id_map = ExtensionTabIdMap::GetInstance();
52 int render_process_id = -1;
53 int routing_id = -1;
54 if (!tab_id_map ||
55 !params_->tab_id.get() ||
56 !tab_id_map->GetProcessAndRoutingId(*params_->tab_id.get(),
57 &render_process_id,
58 &routing_id)) {
59 error_ = kErrorTabIdNotFound;
60 SendResponse(false);
61 SetResult(NULL);
62 }
63
64 bool audio = false;
65 bool video = false;
66 if (params_->options.get()) {
67 if (params_->options->audio.get()) {
68 audio = *params_->options->audio.get();
69 }
70 if (params_->options->video.get()) {
71 video = *params_->options->video.get();
72 }
73 }
74
75 base::DictionaryValue* result = new base::DictionaryValue();
76 result->SetString("deviceId", base::StringPrintf("%i:%i:%i",
77 *params_->tab_id.get(),
78 render_process_id,
79 routing_id));
80 result->SetBoolean("options.audio", audio);
81 result->SetBoolean("options.video", video);
82
83 SetResult(result);
84 }
85
86 TabCaptureGetCapturedTabsFunction::TabCaptureGetCapturedTabsFunction() {
87 }
88
89 TabCaptureGetCapturedTabsFunction::~TabCaptureGetCapturedTabsFunction() {
90 }
91
92 bool TabCaptureGetCapturedTabsFunction::Prepare() {
93 return true;
94 }
95
96 void TabCaptureGetCapturedTabsFunction::Work() {
97 base::ListValue *list = new base::ListValue();
98
99 // TODO(justinlin): Implement this.
100
101 SetResult(list);
102 SendResponse(false);
103 }
104
105 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698