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.h" |
8 #include "athena/content/app_activity_registry.h" | 8 #include "athena/content/app_activity_registry.h" |
9 #include "athena/wm/public/window_list_provider.h" | 9 #include "athena/wm/public/window_list_provider.h" |
10 #include "athena/wm/public/window_manager.h" | 10 #include "athena/wm/public/window_manager.h" |
11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
12 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
14 #include "ui/wm/core/window_util.h" | 14 #include "ui/wm/core/window_util.h" |
15 | 15 |
16 namespace athena { | 16 namespace athena { |
17 | 17 |
18 AppActivityProxy::AppActivityProxy(AppActivity* replaced_activity, | 18 AppActivityProxy::AppActivityProxy(AppActivity* replaced_activity, |
19 AppActivityRegistry* creator) : | 19 AppActivityRegistry* creator) : |
20 app_activity_registry_(creator), | 20 app_activity_registry_(creator), |
21 title_(replaced_activity->GetActivityViewModel()->GetTitle()), | 21 title_(replaced_activity->GetActivityViewModel()->GetTitle()), |
22 color_(replaced_activity->GetActivityViewModel()->GetRepresentativeColor()), | 22 color_(replaced_activity->GetActivityViewModel()->GetRepresentativeColor()), |
23 replaced_activity_(replaced_activity), | 23 replaced_activity_(replaced_activity), |
24 view_(new views::View()) { | 24 view_(new views::View()), |
| 25 restart_called_(false) { |
25 } | 26 } |
26 | 27 |
27 AppActivityProxy::~AppActivityProxy() { | 28 AppActivityProxy::~AppActivityProxy() { |
28 app_activity_registry_->ProxyDestroyed(this); | 29 app_activity_registry_->ProxyDestroyed(this); |
29 } | 30 } |
30 | 31 |
31 ActivityViewModel* AppActivityProxy::GetActivityViewModel() { | 32 ActivityViewModel* AppActivityProxy::GetActivityViewModel() { |
32 return this; | 33 return this; |
33 } | 34 } |
34 | 35 |
35 void AppActivityProxy::SetCurrentState(ActivityState state) { | 36 void AppActivityProxy::SetCurrentState(ActivityState state) { |
36 // We only restart the application when we are switching to visible. | 37 // We only restart the application when we are switching to visible, and only |
37 if (state != ACTIVITY_VISIBLE) | 38 // once. |
| 39 if (state != ACTIVITY_VISIBLE || restart_called_) |
38 return; | 40 return; |
| 41 restart_called_ = true; |
39 app_activity_registry_->RestartApplication(this); | 42 app_activity_registry_->RestartApplication(this); |
40 // Note: This object is now destroyed. | 43 // Note: This object is now destroyed. |
41 } | 44 } |
42 | 45 |
43 Activity::ActivityState AppActivityProxy::GetCurrentState() { | 46 Activity::ActivityState AppActivityProxy::GetCurrentState() { |
44 return ACTIVITY_UNLOADED; | 47 return ACTIVITY_UNLOADED; |
45 } | 48 } |
46 | 49 |
47 bool AppActivityProxy::IsVisible() { | 50 bool AppActivityProxy::IsVisible() { |
48 return false; | 51 return false; |
(...skipping 13 matching lines...) Expand all Loading... |
62 } | 65 } |
63 | 66 |
64 void AppActivityProxy::Init() { | 67 void AppActivityProxy::Init() { |
65 DCHECK(replaced_activity_); | 68 DCHECK(replaced_activity_); |
66 // Get the content proxy to present the content. | 69 // Get the content proxy to present the content. |
67 content_proxy_ = replaced_activity_->GetContentProxy(); | 70 content_proxy_ = replaced_activity_->GetContentProxy(); |
68 WindowListProvider* window_list_provider = | 71 WindowListProvider* window_list_provider = |
69 WindowManager::Get()->GetWindowListProvider(); | 72 WindowManager::Get()->GetWindowListProvider(); |
70 window_list_provider->StackWindowBehindTo(GetWindow(), | 73 window_list_provider->StackWindowBehindTo(GetWindow(), |
71 replaced_activity_->GetWindow()); | 74 replaced_activity_->GetWindow()); |
72 // Creating this object was moving the activation to this window which should | |
73 // not be the active window. As such we re-activate the top activity window. | |
74 // TODO(skuhne): This should possibly move to the WindowListProvider. | |
75 wm::ActivateWindow(window_list_provider->GetWindowList().back()); | |
76 // After the Init() function returns, the passed |replaced_activity_| might | 75 // After the Init() function returns, the passed |replaced_activity_| might |
77 // get destroyed. Since we do not need it anymore we reset it. | 76 // get destroyed. Since we do not need it anymore we reset it. |
78 replaced_activity_ = NULL; | 77 replaced_activity_ = NULL; |
79 } | 78 } |
80 | 79 |
81 SkColor AppActivityProxy::GetRepresentativeColor() const { | 80 SkColor AppActivityProxy::GetRepresentativeColor() const { |
82 return color_; | 81 return color_; |
83 } | 82 } |
84 | 83 |
85 base::string16 AppActivityProxy::GetTitle() const { | 84 base::string16 AppActivityProxy::GetTitle() const { |
(...skipping 20 matching lines...) Expand all Loading... |
106 return content_proxy_->GetContentImage(); | 105 return content_proxy_->GetContentImage(); |
107 } | 106 } |
108 | 107 |
109 void AppActivityProxy::PrepareContentsForOverview() { | 108 void AppActivityProxy::PrepareContentsForOverview() { |
110 } | 109 } |
111 | 110 |
112 void AppActivityProxy::ResetContentsView() { | 111 void AppActivityProxy::ResetContentsView() { |
113 } | 112 } |
114 | 113 |
115 } // namespace athena | 114 } // namespace athena |
OLD | NEW |