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_registry.h" | 5 #include "athena/content/app_activity_registry.h" |
6 | 6 |
7 #include "athena/activity/public/activity_manager.h" | 7 #include "athena/activity/public/activity_manager.h" |
8 #include "athena/content/app_activity.h" | 8 #include "athena/content/app_activity.h" |
9 #include "athena/content/app_activity_proxy.h" | 9 #include "athena/content/app_activity_proxy.h" |
10 #include "athena/content/public/app_content_control_delegate.h" | |
11 #include "athena/content/public/app_registry.h" | 10 #include "athena/content/public/app_registry.h" |
| 11 #include "athena/extensions/public/extensions_delegate.h" |
12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
13 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
14 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
15 | 15 |
16 namespace athena { | 16 namespace athena { |
17 | 17 |
18 AppActivityRegistry::AppActivityRegistry( | 18 AppActivityRegistry::AppActivityRegistry( |
19 const std::string& app_id, | 19 const std::string& app_id, |
20 content::BrowserContext* browser_context) : | 20 content::BrowserContext* browser_context) : |
21 app_id_(app_id), | 21 app_id_(app_id), |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 unloaded_activity_proxy_ = | 84 unloaded_activity_proxy_ = |
85 new AppActivityProxy(activity_list_[0]->GetActivityViewModel(), this); | 85 new AppActivityProxy(activity_list_[0]->GetActivityViewModel(), this); |
86 ActivityManager::Get()->AddActivity(unloaded_activity_proxy_); | 86 ActivityManager::Get()->AddActivity(unloaded_activity_proxy_); |
87 // The new activity should be in the place of the most recently used app | 87 // The new activity should be in the place of the most recently used app |
88 // window. To get it there, we get the most recently used application window | 88 // window. To get it there, we get the most recently used application window |
89 // and place the proxy activities window in front or behind, so that when the | 89 // and place the proxy activities window in front or behind, so that when the |
90 // activity disappears it takes its place. | 90 // activity disappears it takes its place. |
91 MoveBeforeMruApplicationWindow(unloaded_activity_proxy_->GetWindow()); | 91 MoveBeforeMruApplicationWindow(unloaded_activity_proxy_->GetWindow()); |
92 | 92 |
93 // Unload the application. This operation will be asynchronous. | 93 // Unload the application. This operation will be asynchronous. |
94 if (!AppRegistry::Get()->GetDelegate()->UnloadApplication(app_id_, | 94 if (!ExtensionsDelegate::Get(browser_context_)->UnloadApp(app_id_)) { |
95 browser_context_)) { | |
96 while(!activity_list_.empty()) | 95 while(!activity_list_.empty()) |
97 delete activity_list_.back(); | 96 delete activity_list_.back(); |
98 } | 97 } |
99 } | 98 } |
100 | 99 |
101 void AppActivityRegistry::ProxyDestroyed(AppActivityProxy* proxy) { | 100 void AppActivityRegistry::ProxyDestroyed(AppActivityProxy* proxy) { |
102 DCHECK_EQ(unloaded_activity_proxy_, proxy); | 101 DCHECK_EQ(unloaded_activity_proxy_, proxy); |
103 unloaded_activity_proxy_ = NULL; | 102 unloaded_activity_proxy_ = NULL; |
104 if (activity_list_.empty()) { | 103 if (activity_list_.empty()) { |
105 AppRegistry::Get()->RemoveAppActivityRegistry(this); | 104 AppRegistry::Get()->RemoveAppActivityRegistry(this); |
106 // |This| is gone now. | 105 // |This| is gone now. |
107 } | 106 } |
108 } | 107 } |
109 | 108 |
110 void AppActivityRegistry::RestartApplication(AppActivityProxy* proxy) { | 109 void AppActivityRegistry::RestartApplication(AppActivityProxy* proxy) { |
111 DCHECK_EQ(unloaded_activity_proxy_, proxy); | 110 DCHECK_EQ(unloaded_activity_proxy_, proxy); |
112 // Restart the application. | 111 // Restart the application. |
113 AppRegistry::Get()->GetDelegate()->RestartApplication(app_id_, | 112 ExtensionsDelegate::Get(browser_context_)->LaunchApp(app_id_); |
114 browser_context_); | |
115 // Remove the activity from the Activity manager. | 113 // Remove the activity from the Activity manager. |
116 ActivityManager::Get()->RemoveActivity(unloaded_activity_proxy_); | 114 ActivityManager::Get()->RemoveActivity(unloaded_activity_proxy_); |
117 delete unloaded_activity_proxy_; // Will call ProxyDestroyed. | 115 delete unloaded_activity_proxy_; // Will call ProxyDestroyed. |
118 // After this call |this| might be gone if the app did not open a window yet. | 116 // After this call |this| might be gone if the app did not open a window yet. |
119 } | 117 } |
120 | 118 |
121 void AppActivityRegistry::MoveBeforeMruApplicationWindow(aura::Window* window) { | 119 void AppActivityRegistry::MoveBeforeMruApplicationWindow(aura::Window* window) { |
122 DCHECK(activity_list_.size()); | 120 DCHECK(activity_list_.size()); |
123 // TODO(skuhne): This needs to be changed to some kind of delegate which | 121 // TODO(skuhne): This needs to be changed to some kind of delegate which |
124 // resides in the window manager. | 122 // resides in the window manager. |
(...skipping 12 matching lines...) Expand all Loading... |
137 window->parent()->StackChildBelow(window, *child_iterator); | 135 window->parent()->StackChildBelow(window, *child_iterator); |
138 window->parent()->StackChildBelow(*child_iterator, window); | 136 window->parent()->StackChildBelow(*child_iterator, window); |
139 return; | 137 return; |
140 } | 138 } |
141 } | 139 } |
142 } | 140 } |
143 NOTREACHED() << "The application does not get tracked by the mru list"; | 141 NOTREACHED() << "The application does not get tracked by the mru list"; |
144 } | 142 } |
145 | 143 |
146 } // namespace athena | 144 } // namespace athena |
OLD | NEW |