OLD | NEW |
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.h" |
7 #include "athena/content/app_activity_registry.h" | 8 #include "athena/content/app_activity_registry.h" |
8 #include "athena/wm/public/window_list_provider.h" | 9 #include "athena/wm/public/window_list_provider.h" |
9 #include "athena/wm/public/window_manager.h" | 10 #include "athena/wm/public/window_manager.h" |
10 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
11 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
12 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 14 #include "ui/wm/core/window_util.h" |
13 | 15 |
14 namespace athena { | 16 namespace athena { |
15 | 17 |
16 AppActivityProxy::AppActivityProxy(Activity* replaced_activity, | 18 AppActivityProxy::AppActivityProxy(AppActivity* replaced_activity, |
17 AppActivityRegistry* creator) : | 19 AppActivityRegistry* creator) : |
18 app_activity_registry_(creator), | 20 app_activity_registry_(creator), |
19 title_(replaced_activity->GetActivityViewModel()->GetTitle()), | 21 title_(replaced_activity->GetActivityViewModel()->GetTitle()), |
20 image_(replaced_activity->GetActivityViewModel()->GetOverviewModeImage()), | |
21 color_(replaced_activity->GetActivityViewModel()->GetRepresentativeColor()), | 22 color_(replaced_activity->GetActivityViewModel()->GetRepresentativeColor()), |
22 replaced_activity_(replaced_activity), | 23 replaced_activity_(replaced_activity), |
23 // TODO(skuhne): We probably need to do something better with the view | |
24 // (e.g. showing the passed image / layer). | |
25 view_(new views::View()) { | 24 view_(new views::View()) { |
26 } | 25 } |
27 | 26 |
28 AppActivityProxy::~AppActivityProxy() { | 27 AppActivityProxy::~AppActivityProxy() { |
29 app_activity_registry_->ProxyDestroyed(this); | 28 app_activity_registry_->ProxyDestroyed(this); |
30 } | 29 } |
31 | 30 |
32 ActivityViewModel* AppActivityProxy::GetActivityViewModel() { | 31 ActivityViewModel* AppActivityProxy::GetActivityViewModel() { |
33 return this; | 32 return this; |
34 } | 33 } |
(...skipping 18 matching lines...) Expand all Loading... |
53 // This proxy has never any media playing. | 52 // This proxy has never any media playing. |
54 return ACTIVITY_MEDIA_STATE_NONE; | 53 return ACTIVITY_MEDIA_STATE_NONE; |
55 } | 54 } |
56 | 55 |
57 aura::Window* AppActivityProxy::GetWindow() { | 56 aura::Window* AppActivityProxy::GetWindow() { |
58 return view_->GetWidget()->GetNativeWindow(); | 57 return view_->GetWidget()->GetNativeWindow(); |
59 } | 58 } |
60 | 59 |
61 void AppActivityProxy::Init() { | 60 void AppActivityProxy::Init() { |
62 DCHECK(replaced_activity_); | 61 DCHECK(replaced_activity_); |
| 62 // Get the content proxy to present the content. |
| 63 content_proxy_ = replaced_activity_->GetContentProxy(GetWindow()); |
63 WindowListProvider* window_list_provider = | 64 WindowListProvider* window_list_provider = |
64 WindowManager::GetInstance()->GetWindowListProvider(); | 65 WindowManager::GetInstance()->GetWindowListProvider(); |
65 window_list_provider->StackWindowBehindTo(GetWindow(), | 66 window_list_provider->StackWindowBehindTo(GetWindow(), |
66 replaced_activity_->GetWindow()); | 67 replaced_activity_->GetWindow()); |
67 // We moved. | 68 // Creating this object was moving the activation to this window which should |
| 69 // not be the active window. As such we re-activate the top activity window. |
| 70 // TODO(skuhne): This should possibly move to the WindowListProvider. |
| 71 wm::ActivateWindow(window_list_provider->GetWindowList().back()); |
| 72 // After the Init() function returns, the passed |replaced_activity_| might |
| 73 // get destroyed. Since we do not need it anymore we reset it. |
68 replaced_activity_ = NULL; | 74 replaced_activity_ = NULL; |
69 } | 75 } |
70 | 76 |
71 SkColor AppActivityProxy::GetRepresentativeColor() const { | 77 SkColor AppActivityProxy::GetRepresentativeColor() const { |
72 return color_; | 78 return color_; |
73 } | 79 } |
74 | 80 |
75 base::string16 AppActivityProxy::GetTitle() const { | 81 base::string16 AppActivityProxy::GetTitle() const { |
76 return title_; | 82 return title_; |
77 } | 83 } |
78 | 84 |
79 gfx::ImageSkia AppActivityProxy::GetIcon() const { | 85 gfx::ImageSkia AppActivityProxy::GetIcon() const { |
80 return gfx::ImageSkia(); | 86 return gfx::ImageSkia(); |
81 } | 87 } |
82 | 88 |
83 bool AppActivityProxy::UsesFrame() const { | 89 bool AppActivityProxy::UsesFrame() const { |
84 return true; | 90 return true; |
85 } | 91 } |
86 | 92 |
87 views::View* AppActivityProxy::GetContentsView() { | 93 views::View* AppActivityProxy::GetContentsView() { |
88 return view_; | 94 return view_; |
89 } | 95 } |
90 | 96 |
91 views::Widget* AppActivityProxy::CreateWidget() { | 97 views::Widget* AppActivityProxy::CreateWidget() { |
92 return NULL; | 98 return NULL; |
93 } | 99 } |
94 | 100 |
95 void AppActivityProxy::CreateOverviewModeImage() { | |
96 // Nothing we can do here. | |
97 } | |
98 | |
99 gfx::ImageSkia AppActivityProxy::GetOverviewModeImage() { | 101 gfx::ImageSkia AppActivityProxy::GetOverviewModeImage() { |
100 return image_; | 102 return content_proxy_->GetContentImage(); |
101 } | 103 } |
102 | 104 |
103 void AppActivityProxy::PrepareContentsForOverview() { | 105 void AppActivityProxy::PrepareContentsForOverview() { |
104 } | 106 } |
105 | 107 |
106 void AppActivityProxy::ResetContentsView() { | 108 void AppActivityProxy::ResetContentsView() { |
107 } | 109 } |
108 | 110 |
109 } // namespace athena | 111 } // namespace athena |
OLD | NEW |