summaryrefslogtreecommitdiffstats
path: root/athena/content/app_activity_proxy.cc
blob: 222e697b38ba116d42584ab2444cdefb0902e611 (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.

#include "athena/content/app_activity_proxy.h"

#include "athena/content/app_activity_registry.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"

namespace athena {

AppActivityProxy::AppActivityProxy(ActivityViewModel* view_model,
                                   AppActivityRegistry* creator) :
    app_activity_registry_(creator),
    title_(view_model->GetTitle()),
    image_(view_model->GetOverviewModeImage()),
    color_(view_model->GetRepresentativeColor()),
    // TODO(skuhne): We probably need to do something better with the view
    // (e.g. showing the image).
    view_(new views::View()) {}

AppActivityProxy::~AppActivityProxy() {
  app_activity_registry_->ProxyDestroyed(this);
}

ActivityViewModel* AppActivityProxy::GetActivityViewModel() {
  return this;
}

void AppActivityProxy::SetCurrentState(ActivityState state) {
  // We ignore all calls which try to re-load the application at a lower than
  // running invisible state.
  if (state != ACTIVITY_VISIBLE && state != ACTIVITY_INVISIBLE)
    return;
  app_activity_registry_->RestartApplication(this);
  // Note: This object is now destroyed.
}

Activity::ActivityState AppActivityProxy::GetCurrentState() {
  return ACTIVITY_UNLOADED;
}

bool AppActivityProxy::IsVisible() {
  return true;
}

Activity::ActivityMediaState AppActivityProxy::GetMediaState() {
  // This proxy has never any media playing.
  return ACTIVITY_MEDIA_STATE_NONE;
}

aura::Window* AppActivityProxy::GetWindow() {
  return view_->GetWidget()->GetNativeWindow();
}

void AppActivityProxy::Init() {
}

SkColor AppActivityProxy::GetRepresentativeColor() const {
  return color_;
}

base::string16 AppActivityProxy::GetTitle() const {
  return title_;
}

bool AppActivityProxy::UsesFrame() const {
  return true;
}

views::View* AppActivityProxy::GetContentsView() {
  return view_;
}

void AppActivityProxy::CreateOverviewModeImage() {
  // Nothing we can do here.
}

gfx::ImageSkia AppActivityProxy::GetOverviewModeImage() {
  return image_;
}

}  // namespace athena