summaryrefslogtreecommitdiffstats
path: root/athena/content/app_activity_proxy.h
blob: a8193cc9c100718edd5082014e49436dd499d16f (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
// Copyright 2014 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 ATHENA_CONTENT_APP_ACTIVITY_PROXY_H_
#define ATHENA_CONTENT_APP_ACTIVITY_PROXY_H_

#include <vector>

#include "athena/activity/public/activity.h"
#include "athena/activity/public/activity_view_model.h"
#include "athena/content/content_proxy.h"
#include "base/memory/scoped_ptr.h"

namespace athena {

class AppActivity;
class AppActivityRegistry;

// This activity object is a proxy placeholder for the application while it is
// unloaded. When selected it will launch the application again and destroy
// itself indirectly.
class AppActivityProxy : public Activity,
                         public ActivityViewModel {
 public:
  // The |replaced_activity| is the activity which this proxy replaces. Note
  // that after the Init() call got called, this object will become invalid.
  // The |creator| should be informed when the object goes away.
  AppActivityProxy(AppActivity* replaced_activity,
                   AppActivityRegistry* creator);

 protected:
  ~AppActivityProxy() override;

 // Activity overrides:
  ActivityViewModel* GetActivityViewModel() override;
  void SetCurrentState(ActivityState state) override;
  ActivityState GetCurrentState() override;
  bool IsVisible() override;
  ActivityMediaState GetMediaState() override;
  aura::Window* GetWindow() override;
  content::WebContents* GetWebContents() override;

  // ActivityViewModel overrides:
  void Init() override;
  SkColor GetRepresentativeColor() const override;
  base::string16 GetTitle() const override;
  gfx::ImageSkia GetIcon() const override;
  bool UsesFrame() const override;
  views::View* GetContentsView() override;
  views::Widget* CreateWidget() override;
  gfx::ImageSkia GetOverviewModeImage() override;
  void PrepareContentsForOverview() override;
  void ResetContentsView() override;

 private:
  // The creator of this object which needs to be informed if the object gets
  // destroyed or the application should get restarted.
  AppActivityRegistry* app_activity_registry_;

  // The presentation values.
  const base::string16 title_;
  const SkColor color_;

  // The activity which gets replaced. It is used to sort the activity against
  // upon initialization. Once moved, this value gets reset since the object
  // can go away at any time.
  AppActivity* replaced_activity_;

  // The associated view.
  views::View* view_;

  // The content proxy.
  scoped_ptr<ContentProxy> content_proxy_;

  // True if restart got already called.
  bool restart_called_;

  DISALLOW_COPY_AND_ASSIGN(AppActivityProxy);
};

}  // namespace athena

#endif  // ATHENA_CONTENT_APP_ACTIVITY_PROXY_H_