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

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: . 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
« no previous file with comments | « no previous file | athena/content/app_activity_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // 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. Note that by deleting the
121 // proxy the activation will change to the next (activatable) object and
122 // thus we have to move the window in front at the end.
123 Activity::Delete(app_proxy);
124 window_list_provider->StackWindowFrontOf(
125 GetWindow(),
126 window_list_provider->GetWindowList().back());
127 } else {
128 // The app window goes in front of the proxy window (we need to first
129 // place the window before we can delete it).
130 window_list_provider->StackWindowFrontOf(GetWindow(),
131 app_proxy->GetWindow());
132 Activity::Delete(app_proxy);
133 }
134 // The proxy should now be deleted.
115 DCHECK(!app_activity_registry_->unloaded_activity_proxy()); 135 DCHECK(!app_activity_registry_->unloaded_activity_proxy());
116 } 136 }
117 } 137 }
118 138
119 SkColor AppActivity::GetRepresentativeColor() const { 139 SkColor AppActivity::GetRepresentativeColor() const {
120 // TODO(sad): Compute the color from the favicon. 140 // TODO(sad): Compute the color from the favicon.
121 return SK_ColorGRAY; 141 return SK_ColorGRAY;
122 } 142 }
123 143
124 base::string16 AppActivity::GetTitle() const { 144 base::string16 AppActivity::GetTitle() const {
125 return web_view_->GetWebContents()->GetTitle(); 145 return web_view_->GetWebContents()->GetTitle();
126 } 146 }
127 147
128 gfx::ImageSkia AppActivity::GetIcon() const { 148 gfx::ImageSkia AppActivity::GetIcon() const {
129 return gfx::ImageSkia(); 149 return gfx::ImageSkia();
130 } 150 }
131 151
132 bool AppActivity::UsesFrame() const { 152 bool AppActivity::UsesFrame() const {
133 return false; 153 return false;
134 } 154 }
135 155
136 views::Widget* AppActivity::CreateWidget() { 156 views::Widget* AppActivity::CreateWidget() {
157 // Before we remove the proxy, we have to register the activity and
158 // initialize its to move it to the proper activity list location.
159 RegisterActivity();
160 Init();
137 // Make sure the content gets properly shown. 161 // Make sure the content gets properly shown.
138 if (current_state_ == ACTIVITY_VISIBLE) { 162 if (current_state_ == ACTIVITY_VISIBLE) {
139 HideContentProxy(); 163 HideContentProxy();
140 } else if (current_state_ == ACTIVITY_INVISIBLE) { 164 } else if (current_state_ == ACTIVITY_INVISIBLE) {
141 ShowContentProxy(); 165 ShowContentProxy();
142 } else { 166 } else {
143 // If not previously specified, we change the state now to invisible.. 167 // If not previously specified, we change the state now to invisible..
144 SetCurrentState(ACTIVITY_INVISIBLE); 168 SetCurrentState(ACTIVITY_INVISIBLE);
145 } 169 }
146 RegisterActivity();
147 return web_view_->GetWidget(); 170 return web_view_->GetWidget();
148 } 171 }
149 172
150 views::View* AppActivity::GetContentsView() { 173 views::View* AppActivity::GetContentsView() {
151 return web_view_; 174 return web_view_;
152 } 175 }
153 176
154 gfx::ImageSkia AppActivity::GetOverviewModeImage() { 177 gfx::ImageSkia AppActivity::GetOverviewModeImage() {
155 if (content_proxy_.get()) 178 if (content_proxy_.get())
156 return content_proxy_->GetContentImage(); 179 return content_proxy_->GetContentImage();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 void AppActivity::HideContentProxy() { 236 void AppActivity::HideContentProxy() {
214 content_proxy_.reset(); 237 content_proxy_.reset();
215 } 238 }
216 239
217 void AppActivity::ShowContentProxy() { 240 void AppActivity::ShowContentProxy() {
218 if (!content_proxy_.get() && web_view_) 241 if (!content_proxy_.get() && web_view_)
219 content_proxy_.reset(new ContentProxy(web_view_)); 242 content_proxy_.reset(new ContentProxy(web_view_));
220 } 243 }
221 244
222 } // namespace athena 245 } // namespace athena
OLDNEW
« no previous file with comments | « no previous file | athena/content/app_activity_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698