summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/extensions/media_player_api.h
blob: 466d06648a2243e96dd0047fff304999c37c5784 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_MEDIA_PLAYER_API_H_
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_MEDIA_PLAYER_API_H_

#include <map>
#include <string>
#include <vector>

#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
#include "chrome/browser/extensions/extension_function.h"

class Profile;

namespace extensions {
class MediaPlayerEventRouter;

// Implements the chrome.mediaPlayerPrivate.play method.
class MediaPlayerPrivatePlayFunction : public SyncExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("mediaPlayerPrivate.play", MEDIAPLAYERPRIVATE_PLAY)

 protected:
  virtual ~MediaPlayerPrivatePlayFunction() {}

  // SyncExtensionFunction overrides.
  virtual bool RunImpl() OVERRIDE;
};

// Implements the chrome.mediaPlayerPrivate.getPlaylist method.
class MediaPlayerPrivateGetPlaylistFunction : public SyncExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("mediaPlayerPrivate.getPlaylist",
                             MEDIAPLAYERPRIVATE_GETPLAYLIST)

 protected:
  virtual ~MediaPlayerPrivateGetPlaylistFunction() {}

  // SyncExtensionFunction overrides.
  virtual bool RunImpl() OVERRIDE;
};

// Implements the chrome.mediaPlayerPrivate.setWindowHeight method.
class MediaPlayerPrivateSetWindowHeightFunction : public SyncExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("mediaPlayerPrivate.setWindowHeight",
                             MEDIAPLAYERPRIVATE_SETWINDOWHEIGHT)

 protected:
  virtual ~MediaPlayerPrivateSetWindowHeightFunction() {}

  // SyncExtensionFunction overrides.
  virtual bool RunImpl() OVERRIDE;
};

// Implements the chrome.mediaPlayerPrivate.closeWindow method.
class MediaPlayerPrivateCloseWindowFunction : public SyncExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("mediaPlayerPrivate.closeWindow",
                             MEDIAPLAYERPRIVATE_CLOSEWINDOW)

 protected:
  virtual ~MediaPlayerPrivateCloseWindowFunction() {}

  // SyncExtensionFunction overrides.
  virtual bool RunImpl() OVERRIDE;
};

class MediaPlayerAPI : public ProfileKeyedAPI {
 public:
  explicit MediaPlayerAPI(Profile* profile);
  virtual ~MediaPlayerAPI();

  // Convenience method to get the MediaPlayerAPI for a profile.
  static MediaPlayerAPI* Get(Profile* profile);

  MediaPlayerEventRouter* media_player_event_router();

  // ProfileKeyedAPI implementation.
  static ProfileKeyedAPIFactory<MediaPlayerAPI>* GetFactoryInstance();

 private:
  friend class ProfileKeyedAPIFactory<MediaPlayerAPI>;

  Profile* const profile_;

  // ProfileKeyedAPI implementation.
  static const char* service_name() {
    return "MediaPlayerAPI";
  }
  static const bool kServiceRedirectedInIncognito = true;
  static const bool kServiceIsNULLWhileTesting = true;

  scoped_ptr<MediaPlayerEventRouter> media_player_event_router_;

  DISALLOW_COPY_AND_ASSIGN(MediaPlayerAPI);
};

}  // namespace extensions

#endif  // CHROME_BROWSER_CHROMEOS_EXTENSIONS_MEDIA_PLAYER_API_H_