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.h" | 5 #include "athena/content/app_activity.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_registry.h" | 8 #include "athena/content/app_activity_registry.h" |
9 #include "athena/content/content_proxy.h" | 9 #include "athena/content/content_proxy.h" |
10 #include "athena/content/media_utils.h" | 10 #include "athena/content/media_utils.h" |
11 #include "athena/content/public/app_registry.h" | 11 #include "athena/content/public/app_registry.h" |
12 #include "athena/wm/public/window_list_provider.h" | 12 #include "athena/wm/public/window_list_provider.h" |
13 #include "athena/wm/public/window_manager.h" | 13 #include "athena/wm/public/window_manager.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
16 #include "ui/views/controls/webview/webview.h" | 16 #include "ui/views/controls/webview/webview.h" |
17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
18 #include "ui/wm/core/window_util.h" | |
18 | 19 |
19 namespace athena { | 20 namespace athena { |
20 | 21 |
21 // TODO(mukai): specifies the same accelerators of WebActivity. | 22 // TODO(mukai): specifies the same accelerators of WebActivity. |
22 AppActivity::AppActivity(const std::string& app_id, | 23 AppActivity::AppActivity(const std::string& app_id, |
23 views::WebView* web_view) | 24 views::WebView* web_view) |
24 : app_id_(app_id), | 25 : app_id_(app_id), |
25 web_view_(web_view), | 26 web_view_(web_view), |
26 current_state_(ACTIVITY_UNLOADED), | 27 current_state_(ACTIVITY_UNLOADED), |
27 app_activity_registry_(NULL) { | 28 app_activity_registry_(NULL) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 } | 102 } |
102 | 103 |
103 void AppActivity::Init() { | 104 void AppActivity::Init() { |
104 DCHECK(app_activity_registry_); | 105 DCHECK(app_activity_registry_); |
105 Activity* app_proxy = app_activity_registry_->unloaded_activity_proxy(); | 106 Activity* app_proxy = app_activity_registry_->unloaded_activity_proxy(); |
106 if (app_proxy) { | 107 if (app_proxy) { |
107 // Note: At this time the |AppActivity| did not get registered to the | 108 // Note: At this time the |AppActivity| did not get registered to the |
108 // |ResourceManager| - so we can move it around if needed. | 109 // |ResourceManager| - so we can move it around if needed. |
109 WindowListProvider* window_list_provider = | 110 WindowListProvider* window_list_provider = |
110 WindowManager::Get()->GetWindowListProvider(); | 111 WindowManager::Get()->GetWindowListProvider(); |
111 window_list_provider->StackWindowFrontOf(app_proxy->GetWindow(), | 112 // TODO(skuhne): After the decision is made how we want to handle visibility |
112 GetWindow()); | 113 // transitions (issue 421680) this code might change. |
113 Activity::Delete(app_proxy); | 114 // If the proxy was the active window, its deletion will cause a window |
114 // With the removal the object, the proxy should be deleted. | 115 // reordering since the next activatable window in line will move up to the |
116 // front. Since the application window is still hidden at this time, it is | |
117 // not yet activatable and the window behind it will move to the front. | |
118 if (wm::IsActiveWindow(app_proxy->GetWindow())) { | |
119 // Delete the proxy window first and then move the new window to the top | |
120 // of the stack, replacing the proxy window. | |
121 Activity::Delete(app_proxy); | |
122 window_list_provider->StackWindowFrontOf( | |
123 GetWindow(), | |
124 window_list_provider->GetWindowList().back()); | |
125 } else { | |
126 // The app window goes in front of the proxy window. | |
127 window_list_provider->StackWindowFrontOf(GetWindow(), | |
128 app_proxy->GetWindow()); | |
129 Activity::Delete(app_proxy); | |
oshima
2014/10/09 04:53:33
Can you move Activity::Delegate(app_proxy) before
Mr4D (OOO till 08-26)
2014/10/09 14:46:44
That is what I tried to tell you yesterday - no th
oshima
2014/10/09 16:06:43
I see, in that case, can you update the comment wh
Mr4D (OOO till 08-26)
2014/10/09 17:28:03
Done.
| |
130 } | |
131 // The proxy should now be deleted. | |
115 DCHECK(!app_activity_registry_->unloaded_activity_proxy()); | 132 DCHECK(!app_activity_registry_->unloaded_activity_proxy()); |
116 } | 133 } |
117 } | 134 } |
118 | 135 |
119 SkColor AppActivity::GetRepresentativeColor() const { | 136 SkColor AppActivity::GetRepresentativeColor() const { |
120 // TODO(sad): Compute the color from the favicon. | 137 // TODO(sad): Compute the color from the favicon. |
121 return SK_ColorGRAY; | 138 return SK_ColorGRAY; |
122 } | 139 } |
123 | 140 |
124 base::string16 AppActivity::GetTitle() const { | 141 base::string16 AppActivity::GetTitle() const { |
125 return web_view_->GetWebContents()->GetTitle(); | 142 return web_view_->GetWebContents()->GetTitle(); |
126 } | 143 } |
127 | 144 |
128 gfx::ImageSkia AppActivity::GetIcon() const { | 145 gfx::ImageSkia AppActivity::GetIcon() const { |
129 return gfx::ImageSkia(); | 146 return gfx::ImageSkia(); |
130 } | 147 } |
131 | 148 |
132 bool AppActivity::UsesFrame() const { | 149 bool AppActivity::UsesFrame() const { |
133 return false; | 150 return false; |
134 } | 151 } |
135 | 152 |
136 views::Widget* AppActivity::CreateWidget() { | 153 views::Widget* AppActivity::CreateWidget() { |
154 // Before we remove the proxy, we have to register the activity and | |
155 // initialize its to move it to the proper activity list location. | |
156 RegisterActivity(); | |
157 Init(); | |
137 // Make sure the content gets properly shown. | 158 // Make sure the content gets properly shown. |
138 if (current_state_ == ACTIVITY_VISIBLE) { | 159 if (current_state_ == ACTIVITY_VISIBLE) { |
139 HideContentProxy(); | 160 HideContentProxy(); |
140 } else if (current_state_ == ACTIVITY_INVISIBLE) { | 161 } else if (current_state_ == ACTIVITY_INVISIBLE) { |
141 ShowContentProxy(); | 162 ShowContentProxy(); |
142 } else { | 163 } else { |
143 // If not previously specified, we change the state now to invisible.. | 164 // If not previously specified, we change the state now to invisible.. |
144 SetCurrentState(ACTIVITY_INVISIBLE); | 165 SetCurrentState(ACTIVITY_INVISIBLE); |
145 } | 166 } |
146 RegisterActivity(); | |
147 return web_view_->GetWidget(); | 167 return web_view_->GetWidget(); |
148 } | 168 } |
149 | 169 |
150 views::View* AppActivity::GetContentsView() { | 170 views::View* AppActivity::GetContentsView() { |
151 return web_view_; | 171 return web_view_; |
152 } | 172 } |
153 | 173 |
154 gfx::ImageSkia AppActivity::GetOverviewModeImage() { | 174 gfx::ImageSkia AppActivity::GetOverviewModeImage() { |
155 if (content_proxy_.get()) | 175 if (content_proxy_.get()) |
156 return content_proxy_->GetContentImage(); | 176 return content_proxy_->GetContentImage(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 void AppActivity::HideContentProxy() { | 233 void AppActivity::HideContentProxy() { |
214 content_proxy_.reset(); | 234 content_proxy_.reset(); |
215 } | 235 } |
216 | 236 |
217 void AppActivity::ShowContentProxy() { | 237 void AppActivity::ShowContentProxy() { |
218 if (!content_proxy_.get() && web_view_) | 238 if (!content_proxy_.get() && web_view_) |
219 content_proxy_.reset(new ContentProxy(web_view_)); | 239 content_proxy_.reset(new ContentProxy(web_view_)); |
220 } | 240 } |
221 | 241 |
222 } // namespace athena | 242 } // namespace athena |
OLD | NEW |