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

Side by Side Diff: chrome/browser/extensions/extension_mediaplayer_private_api.cc

Issue 7067020: Moving mediaplayer to the chrome filebrowser. Observable behaviour should not change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed style errors and localized strings. Created 9 years, 7 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) 2011 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 #include "chrome/browser/extensions/extension_mediaplayer_private_api.h"
6
7 #include "base/values.h"
8 #include "chrome/browser/ui/webui/mediaplayer_ui.h"
9
10 static const char kPropertyPath[] = "path";
11 static const char kPropertyForce[] = "force";
12 static const char kPropertyItems[] = "items";
13 static const char kPropertyPosition[] = "position";
14 static const char kPropertyError[] = "error";
15 static const char kPropertyPendingPlaybackRequest[] =
16 "pending_playback_request";
17
18 bool SetPlaylistPositionAndPlayMediaplayerFunction::RunImpl() {
19 int position;
20 CHECK(args_->GetInteger(0, &position));
zel 2011/05/24 17:54:25 I would't crash here. Just return false if GetInte
SeRya 2011/05/25 14:23:49 Done.
21 MediaPlayer::GetInstance()->SetPlaybackRequest();
22 MediaPlayer::GetInstance()->SetPlaylistPosition(position);
23 return true;
24 }
25
26 static ListValue* GetPlaylistItems() {
27 ListValue* result = new ListValue();
28
29 MediaPlayer::UrlVector const& src = MediaPlayer::GetInstance()->GetPlaylist();
30
31 for (size_t i = 0; i < src.size(); i++) {
32 DictionaryValue* url_value = new DictionaryValue();
33 url_value->SetString(kPropertyPath, src[i].url.spec());
34 url_value->SetBoolean(kPropertyError, src[i].haderror);
35 result->Append(url_value);
36 }
37 return result;
38 }
39
40 bool GetPlaylistMediaplayerFunction::RunImpl() {
41 DictionaryValue* result = new DictionaryValue();
42 MediaPlayer* player = MediaPlayer::GetInstance();
43
44 result->Set(kPropertyItems, GetPlaylistItems());
45 result->SetInteger(kPropertyPosition, player->GetPlaylistPosition());
46 result->SetBoolean(kPropertyPendingPlaybackRequest,
47 player->GetPendingPlayRequestAndReset());
48
49 result_.reset(result);
50 SendResponse(true);
51 return true;
52 }
53
54 bool PlaybackErrorMediaplayerFunction::RunImpl() {
55 std::string url;
56 // Get path string.
57 if (args_->GetString(0, &url))
58 MediaPlayer::GetInstance()->SetPlaybackError(GURL(url));
59 return true;
60 }
61
62 bool TogglePlaylistPanelMediaplayerFunction::RunImpl() {
63 MediaPlayer::GetInstance()->TogglePlaylistWindowVisible();
64 return true;
65 }
66
67 bool ToggleFullscreenMediaplayerFunction::RunImpl() {
68 MediaPlayer::GetInstance()->ToggleFullscreen();
69 return true;
70 }
71
72 bool ShowPlaylistPanelMediaplayerFunction::RunImpl() {
73 MediaPlayer::GetInstance()->ShowPlaylistWindow();
74 return true;
75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698