summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.h
blob: 0ba655ea65ac54fb72f8cb875bace411f8fc69ba (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
// 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_KIOSK_MODE_KIOSK_MODE_SCREENSAVER_H_
#define CHROME_BROWSER_CHROMEOS_KIOSK_MODE_KIOSK_MODE_SCREENSAVER_H_
#pragma once

#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/dbus/power_manager_client.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"

class Extension;

namespace chromeos {

class KioskModeScreensaver : public PowerManagerClient::Observer,
                             public content::NotificationObserver {
 public:
  KioskModeScreensaver();
  virtual ~KioskModeScreensaver();

  // NotificationObserver overrides:
  virtual void Observe(int type,
                       const content::NotificationSource& source,
                       const content::NotificationDetails& details) OVERRIDE;

  // PowerManagerClient::Observer overrides:
  virtual void ActiveNotify() OVERRIDE;

 private:
  friend class KioskModeScreensaverTest;

  // Initialization functions, in order
  // Get the screensaver path once KioskModeHelper is initialized.
  void GetScreensaverCrxPath();

  // Callback to receive the path to the screensaver extension's crx and call
  // the unpacker to unpack and load the crx.
  void ScreensaverPathCallback(const FilePath& screensaver_crx);

  // Called back on the UI thread to Setup the screensaver with the now unpacked
  // and loaded extension.
  void SetupScreensaver(scoped_refptr<Extension> extension,
                        const FilePath& extension_base_path);

  content::NotificationRegistrar registrar_;
  base::WeakPtrFactory<KioskModeScreensaver> weak_ptr_factory_;

  FilePath extension_base_path_;

  DISALLOW_COPY_AND_ASSIGN(KioskModeScreensaver);
};

void InitializeKioskModeScreensaver();
void ShutdownKioskModeScreensaver();

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_KIOSK_MODE_KIOSK_MODE_SCREENSAVER_H_