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

Side by Side Diff: chrome/browser/chromeos/extensions/media_player_api.cc

Issue 12089062: Move API functions registrations out of ExtensionFunctionRegistry. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 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
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/chromeos/extensions/media_player_api.h" 5 #include "chrome/browser/chromeos/extensions/media_player_api.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" 9 #include "chrome/browser/chromeos/extensions/media_player_event_router.h"
10 #include "chrome/browser/chromeos/media/media_player.h" 10 #include "chrome/browser/chromeos/media/media_player.h"
11 11
12 namespace { 12 namespace {
13 13
14 static const char kPropertyItems[] = "items"; 14 static const char kPropertyItems[] = "items";
15 static const char kPropertyPosition[] = "position"; 15 static const char kPropertyPosition[] = "position";
16 16
17 } // namespace 17 } // namespace
18 18
19 namespace extensions { 19 namespace extensions {
20 20
21 bool PlayMediaplayerFunction::RunImpl() { 21 bool MediaPlayerPrivatePlayFunction::RunImpl() {
22 if (args_->GetSize() < 2) { 22 if (args_->GetSize() < 2) {
23 return false; 23 return false;
24 } 24 }
25 25
26 ListValue* url_list = NULL; 26 ListValue* url_list = NULL;
27 if (!args_->GetList(0, &url_list)) 27 if (!args_->GetList(0, &url_list))
28 return false; 28 return false;
29 29
30 int position; 30 int position;
31 if (!args_->GetInteger(1, &position)) 31 if (!args_->GetInteger(1, &position))
(...skipping 21 matching lines...) Expand all
53 ListValue* result = new ListValue(); 53 ListValue* result = new ListValue();
54 54
55 MediaPlayer::UrlVector const& src = MediaPlayer::GetInstance()->GetPlaylist(); 55 MediaPlayer::UrlVector const& src = MediaPlayer::GetInstance()->GetPlaylist();
56 56
57 for (size_t i = 0; i < src.size(); i++) { 57 for (size_t i = 0; i < src.size(); i++) {
58 result->Append(new base::StringValue(src[i].spec())); 58 result->Append(new base::StringValue(src[i].spec()));
59 } 59 }
60 return result; 60 return result;
61 } 61 }
62 62
63 bool GetPlaylistMediaplayerFunction::RunImpl() { 63 bool MediaPlayerPrivateGetPlaylistFunction::RunImpl() {
64 DictionaryValue* result = new DictionaryValue(); 64 DictionaryValue* result = new DictionaryValue();
65 MediaPlayer* player = MediaPlayer::GetInstance(); 65 MediaPlayer* player = MediaPlayer::GetInstance();
66 66
67 result->Set(kPropertyItems, GetPlaylistItems()); 67 result->Set(kPropertyItems, GetPlaylistItems());
68 result->SetInteger(kPropertyPosition, player->GetPlaylistPosition()); 68 result->SetInteger(kPropertyPosition, player->GetPlaylistPosition());
69 69
70 SetResult(result); 70 SetResult(result);
71 return true; 71 return true;
72 } 72 }
73 73
74 // TODO(kaznacheev): rename the API method to adjustWindowHeight here and in 74 // TODO(kaznacheev): rename the API method to adjustWindowHeight here and in
75 // media_player_private.json. 75 // media_player_private.json.
76 bool SetWindowHeightMediaplayerFunction::RunImpl() { 76 bool MediaPlayerPrivateSetWindowHeightFunction::RunImpl() {
77 int height_diff; 77 int height_diff;
78 if (!args_->GetInteger(0, &height_diff)) 78 if (!args_->GetInteger(0, &height_diff))
79 return false; 79 return false;
80 MediaPlayer::GetInstance()->AdjustWindowHeight(height_diff); 80 MediaPlayer::GetInstance()->AdjustWindowHeight(height_diff);
81 return true; 81 return true;
82 } 82 }
83 83
84 bool CloseWindowMediaplayerFunction::RunImpl() { 84 bool MediaPlayerPrivateCloseWindowFunction::RunImpl() {
85 MediaPlayer::GetInstance()->CloseWindow(); 85 MediaPlayer::GetInstance()->CloseWindow();
86 return true; 86 return true;
87 } 87 }
88 88
89 MediaPlayerAPI::MediaPlayerAPI(Profile* profile) 89 MediaPlayerAPI::MediaPlayerAPI(Profile* profile)
90 : profile_(profile) { 90 : profile_(profile) {
91 } 91 }
92 92
93 MediaPlayerAPI::~MediaPlayerAPI() { 93 MediaPlayerAPI::~MediaPlayerAPI() {
94 } 94 }
(...skipping 11 matching lines...) Expand all
106 106
107 static base::LazyInstance<ProfileKeyedAPIFactory<MediaPlayerAPI> > 107 static base::LazyInstance<ProfileKeyedAPIFactory<MediaPlayerAPI> >
108 g_factory = LAZY_INSTANCE_INITIALIZER; 108 g_factory = LAZY_INSTANCE_INITIALIZER;
109 109
110 // static 110 // static
111 ProfileKeyedAPIFactory<MediaPlayerAPI>* MediaPlayerAPI::GetFactoryInstance() { 111 ProfileKeyedAPIFactory<MediaPlayerAPI>* MediaPlayerAPI::GetFactoryInstance() {
112 return &g_factory.Get(); 112 return &g_factory.Get();
113 } 113 }
114 114
115 } // namespace extensions 115 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698