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

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

Issue 631333003: Adding application lifetime tests to athena, allowing to override focus request for applciations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed activation Created 6 years, 2 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
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.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
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
112 GetWindow()); 113 // If the proxy was the active window, its deletion will cause a window
oshima 2014/10/08 19:02:30 Since the window may not be visible when created,
Mr4D (OOO till 08-26) 2014/10/08 23:48:16 As stated in the next comment - the visibility wil
oshima 2014/10/09 04:53:32 Acknowledged.
113 Activity::Delete(app_proxy); 114 // reordering since the next activatable window in line will move up to the
114 // With the removal the object, the proxy should be deleted. 115 // front. Since the application window is still hidden at this time, it is
116 // not yet activatable and the window behind it will move to the front.
117 if (wm::IsActiveWindow(app_proxy->GetWindow())) {
118 // Delete the proxy window first and then move the new window to the top
119 // of the stack, replacing the proxy window.
120 Activity::Delete(app_proxy);
121 window_list_provider->StackWindowFrontOf(
122 GetWindow(),
123 window_list_provider->GetWindowList().back());
oshima 2014/10/08 19:02:30 If the app_proxy's window was active, shouldn't we
Mr4D (OOO till 08-26) 2014/10/08 23:48:16 A hidden window cannot be activated. As you have p
oshima 2014/10/09 04:53:32 Acknowledged.
124 } else {
125 // The app window goes in front of the proxy window.
126 window_list_provider->StackWindowFrontOf(GetWindow(),
127 app_proxy->GetWindow());
128 Activity::Delete(app_proxy);
oshima 2014/10/08 19:02:30 how about something like bool was_active = wm::Is
Mr4D (OOO till 08-26) 2014/10/08 23:48:16 As stated above already - the window might neither
129 }
130 // The proxy should now be deleted.
115 DCHECK(!app_activity_registry_->unloaded_activity_proxy()); 131 DCHECK(!app_activity_registry_->unloaded_activity_proxy());
116 } 132 }
117 } 133 }
118 134
119 SkColor AppActivity::GetRepresentativeColor() const { 135 SkColor AppActivity::GetRepresentativeColor() const {
120 // TODO(sad): Compute the color from the favicon. 136 // TODO(sad): Compute the color from the favicon.
121 return SK_ColorGRAY; 137 return SK_ColorGRAY;
122 } 138 }
123 139
124 base::string16 AppActivity::GetTitle() const { 140 base::string16 AppActivity::GetTitle() const {
125 return web_view_->GetWebContents()->GetTitle(); 141 return web_view_->GetWebContents()->GetTitle();
126 } 142 }
127 143
128 gfx::ImageSkia AppActivity::GetIcon() const { 144 gfx::ImageSkia AppActivity::GetIcon() const {
129 return gfx::ImageSkia(); 145 return gfx::ImageSkia();
130 } 146 }
131 147
132 bool AppActivity::UsesFrame() const { 148 bool AppActivity::UsesFrame() const {
133 return false; 149 return false;
134 } 150 }
135 151
136 views::Widget* AppActivity::CreateWidget() { 152 views::Widget* AppActivity::CreateWidget() {
153 // Before we remove the proxy, we have to register the activity and
154 // initialize its to move it to the proper activity list location.
155 RegisterActivity();
156 Init();
137 // Make sure the content gets properly shown. 157 // Make sure the content gets properly shown.
138 if (current_state_ == ACTIVITY_VISIBLE) { 158 if (current_state_ == ACTIVITY_VISIBLE) {
139 HideContentProxy(); 159 HideContentProxy();
140 } else if (current_state_ == ACTIVITY_INVISIBLE) { 160 } else if (current_state_ == ACTIVITY_INVISIBLE) {
141 ShowContentProxy(); 161 ShowContentProxy();
142 } else { 162 } else {
143 // If not previously specified, we change the state now to invisible.. 163 // If not previously specified, we change the state now to invisible..
144 SetCurrentState(ACTIVITY_INVISIBLE); 164 SetCurrentState(ACTIVITY_INVISIBLE);
145 } 165 }
146 RegisterActivity();
147 return web_view_->GetWidget(); 166 return web_view_->GetWidget();
148 } 167 }
149 168
150 views::View* AppActivity::GetContentsView() { 169 views::View* AppActivity::GetContentsView() {
151 return web_view_; 170 return web_view_;
152 } 171 }
153 172
154 gfx::ImageSkia AppActivity::GetOverviewModeImage() { 173 gfx::ImageSkia AppActivity::GetOverviewModeImage() {
155 if (content_proxy_.get()) 174 if (content_proxy_.get())
156 return content_proxy_->GetContentImage(); 175 return content_proxy_->GetContentImage();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 void AppActivity::HideContentProxy() { 232 void AppActivity::HideContentProxy() {
214 content_proxy_.reset(); 233 content_proxy_.reset();
215 } 234 }
216 235
217 void AppActivity::ShowContentProxy() { 236 void AppActivity::ShowContentProxy() {
218 if (!content_proxy_.get() && web_view_) 237 if (!content_proxy_.get() && web_view_)
219 content_proxy_.reset(new ContentProxy(web_view_)); 238 content_proxy_.reset(new ContentProxy(web_view_));
220 } 239 }
221 240
222 } // namespace athena 241 } // namespace athena
OLDNEW
« no previous file with comments | « no previous file | athena/content/app_activity_browsertest.cc » ('j') | athena/content/app_activity_browsertest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698