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

Side by Side Diff: athena/content/app_activity_proxy.cc

Issue 536013002: Decoupling visibility states from webcontent, adding visibility management in ResourceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Created 6 years, 3 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
« no previous file with comments | « athena/content/app_activity_proxy.h ('k') | athena/content/app_activity_registry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/content/app_activity_proxy.h" 5 #include "athena/content/app_activity_proxy.h"
6 6
7 #include "athena/content/app_activity_registry.h" 7 #include "athena/content/app_activity_registry.h"
8 #include "ui/aura/window.h"
8 #include "ui/views/view.h" 9 #include "ui/views/view.h"
9 #include "ui/views/widget/widget.h" 10 #include "ui/views/widget/widget.h"
10 11
11 namespace athena { 12 namespace athena {
12 13
13 AppActivityProxy::AppActivityProxy(ActivityViewModel* view_model, 14 AppActivityProxy::AppActivityProxy(Activity* replaced_activity,
14 AppActivityRegistry* creator) : 15 AppActivityRegistry* creator) :
15 app_activity_registry_(creator), 16 app_activity_registry_(creator),
16 title_(view_model->GetTitle()), 17 title_(replaced_activity->GetActivityViewModel()->GetTitle()),
17 image_(view_model->GetOverviewModeImage()), 18 image_(replaced_activity->GetActivityViewModel()->GetOverviewModeImage()),
18 color_(view_model->GetRepresentativeColor()), 19 color_(replaced_activity->GetActivityViewModel()->GetRepresentativeColor()),
20 replaced_activity_(replaced_activity),
19 // TODO(skuhne): We probably need to do something better with the view 21 // TODO(skuhne): We probably need to do something better with the view
20 // (e.g. showing the image). 22 // (e.g. showing the passed image / layer).
21 view_(new views::View()) {} 23 view_(new views::View()) {
24 }
22 25
23 AppActivityProxy::~AppActivityProxy() { 26 AppActivityProxy::~AppActivityProxy() {
24 app_activity_registry_->ProxyDestroyed(this); 27 app_activity_registry_->ProxyDestroyed(this);
25 } 28 }
26 29
27 ActivityViewModel* AppActivityProxy::GetActivityViewModel() { 30 ActivityViewModel* AppActivityProxy::GetActivityViewModel() {
28 return this; 31 return this;
29 } 32 }
30 33
31 void AppActivityProxy::SetCurrentState(ActivityState state) { 34 void AppActivityProxy::SetCurrentState(ActivityState state) {
32 // We ignore all calls which try to re-load the application at a lower than 35 // We only restart the application when we are switching to visible.
33 // running invisible state. 36 if (state != ACTIVITY_VISIBLE)
34 if (state != ACTIVITY_VISIBLE && state != ACTIVITY_INVISIBLE)
35 return; 37 return;
36 app_activity_registry_->RestartApplication(this); 38 app_activity_registry_->RestartApplication(this);
37 // Note: This object is now destroyed. 39 // Note: This object is now destroyed.
38 } 40 }
39 41
40 Activity::ActivityState AppActivityProxy::GetCurrentState() { 42 Activity::ActivityState AppActivityProxy::GetCurrentState() {
41 return ACTIVITY_UNLOADED; 43 return ACTIVITY_UNLOADED;
42 } 44 }
43 45
44 bool AppActivityProxy::IsVisible() { 46 bool AppActivityProxy::IsVisible() {
45 return false; 47 return false;
46 } 48 }
47 49
48 Activity::ActivityMediaState AppActivityProxy::GetMediaState() { 50 Activity::ActivityMediaState AppActivityProxy::GetMediaState() {
49 // This proxy has never any media playing. 51 // This proxy has never any media playing.
50 return ACTIVITY_MEDIA_STATE_NONE; 52 return ACTIVITY_MEDIA_STATE_NONE;
51 } 53 }
52 54
53 aura::Window* AppActivityProxy::GetWindow() { 55 aura::Window* AppActivityProxy::GetWindow() {
54 return view_->GetWidget()->GetNativeWindow(); 56 return view_->GetWidget()->GetNativeWindow();
55 } 57 }
56 58
57 void AppActivityProxy::Init() { 59 void AppActivityProxy::Init() {
60 DCHECK(replaced_activity_);
61 // TODO(skuhne): This should call the WindowListProvider to re-arrange.
62 // At this point we can move the Activity to its proper Activity location.
63 aura::Window* relative_window = replaced_activity_->GetWindow();
64 relative_window->parent()->StackChildBelow(GetWindow(), relative_window);
65 // We moved.
66 replaced_activity_ = NULL;
58 } 67 }
59 68
60 SkColor AppActivityProxy::GetRepresentativeColor() const { 69 SkColor AppActivityProxy::GetRepresentativeColor() const {
61 return color_; 70 return color_;
62 } 71 }
63 72
64 base::string16 AppActivityProxy::GetTitle() const { 73 base::string16 AppActivityProxy::GetTitle() const {
65 return title_; 74 return title_;
66 } 75 }
67 76
68 bool AppActivityProxy::UsesFrame() const { 77 bool AppActivityProxy::UsesFrame() const {
69 return true; 78 return true;
70 } 79 }
71 80
72 views::View* AppActivityProxy::GetContentsView() { 81 views::View* AppActivityProxy::GetContentsView() {
73 return view_; 82 return view_;
74 } 83 }
75 84
76 void AppActivityProxy::CreateOverviewModeImage() { 85 void AppActivityProxy::CreateOverviewModeImage() {
77 // Nothing we can do here. 86 // Nothing we can do here.
78 } 87 }
79 88
80 gfx::ImageSkia AppActivityProxy::GetOverviewModeImage() { 89 gfx::ImageSkia AppActivityProxy::GetOverviewModeImage() {
81 return image_; 90 return image_;
82 } 91 }
83 92
84 } // namespace athena 93 } // namespace athena
OLDNEW
« no previous file with comments | « athena/content/app_activity_proxy.h ('k') | athena/content/app_activity_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698