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

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

Issue 702473005: athena: Remove ActivityViewModel::CreateWidget(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « athena/content/app_activity.h ('k') | athena/content/app_activity_proxy.h » ('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"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 current_state_ != ACTIVITY_UNLOADED; 86 current_state_ != ACTIVITY_UNLOADED;
87 } 87 }
88 88
89 Activity::ActivityMediaState AppActivity::GetMediaState() { 89 Activity::ActivityMediaState AppActivity::GetMediaState() {
90 return current_state_ == ACTIVITY_UNLOADED ? 90 return current_state_ == ACTIVITY_UNLOADED ?
91 Activity::ACTIVITY_MEDIA_STATE_NONE : 91 Activity::ACTIVITY_MEDIA_STATE_NONE :
92 GetActivityMediaState(GetWebContents()); 92 GetActivityMediaState(GetWebContents());
93 } 93 }
94 94
95 aura::Window* AppActivity::GetWindow() { 95 aura::Window* AppActivity::GetWindow() {
96 return !web_view_ ? nullptr : web_view_->GetWidget()->GetNativeWindow(); 96 return web_view_ && web_view_->GetWidget()
97 ? web_view_->GetWidget()->GetNativeWindow()
98 : nullptr;
97 } 99 }
98 100
99 content::WebContents* AppActivity::GetWebContents() { 101 content::WebContents* AppActivity::GetWebContents() {
100 return !web_view_ ? nullptr : web_view_->GetWebContents(); 102 return !web_view_ ? nullptr : web_view_->GetWebContents();
101 } 103 }
102 104
103 void AppActivity::Init() { 105 void AppActivity::Init() {
106 // Before we remove the proxy, we have to register the activity and
107 // initialize its to move it to the proper activity list location.
108 RegisterActivity();
109
104 DCHECK(app_activity_registry_); 110 DCHECK(app_activity_registry_);
105 Activity* app_proxy = app_activity_registry_->unloaded_activity_proxy(); 111 Activity* app_proxy = app_activity_registry_->unloaded_activity_proxy();
106 if (app_proxy) { 112 if (app_proxy) {
107 // Note: At this time the |AppActivity| did not get registered to the 113 // Note: At this time the |AppActivity| did not get registered to the
108 // |ResourceManager| - so we can move it around if needed. 114 // |ResourceManager| - so we can move it around if needed.
109 WindowListProvider* window_list_provider = 115 WindowListProvider* window_list_provider =
110 WindowManager::Get()->GetWindowListProvider(); 116 WindowManager::Get()->GetWindowListProvider();
111 // TODO(skuhne): After the decision is made how we want to handle visibility 117 // TODO(skuhne): After the decision is made how we want to handle visibility
112 // transitions (issue 421680) this code might change. 118 // transitions (issue 421680) this code might change.
113 // If the proxy was the active window, its deletion will cause a window 119 // If the proxy was the active window, its deletion will cause a window
(...skipping 14 matching lines...) Expand all
128 } else { 134 } else {
129 // The app window goes in front of the proxy window (we need to first 135 // The app window goes in front of the proxy window (we need to first
130 // place the window before we can delete it). 136 // place the window before we can delete it).
131 window_list_provider->StackWindowFrontOf(GetWindow(), 137 window_list_provider->StackWindowFrontOf(GetWindow(),
132 app_proxy->GetWindow()); 138 app_proxy->GetWindow());
133 Activity::Delete(app_proxy); 139 Activity::Delete(app_proxy);
134 } 140 }
135 // The proxy should now be deleted. 141 // The proxy should now be deleted.
136 DCHECK(!app_activity_registry_->unloaded_activity_proxy()); 142 DCHECK(!app_activity_registry_->unloaded_activity_proxy());
137 } 143 }
144
145 // Make sure the content gets properly shown.
146 if (current_state_ == ACTIVITY_VISIBLE) {
147 HideContentProxy();
148 } else if (current_state_ == ACTIVITY_INVISIBLE) {
149 ShowContentProxy();
150 } else {
151 // If not previously specified, we change the state now to invisible..
152 SetCurrentState(ACTIVITY_INVISIBLE);
153 }
138 } 154 }
139 155
140 SkColor AppActivity::GetRepresentativeColor() const { 156 SkColor AppActivity::GetRepresentativeColor() const {
141 // TODO(sad): Compute the color from the favicon. 157 // TODO(sad): Compute the color from the favicon.
142 return SK_ColorGRAY; 158 return SK_ColorGRAY;
143 } 159 }
144 160
145 base::string16 AppActivity::GetTitle() const { 161 base::string16 AppActivity::GetTitle() const {
146 return web_view_->GetWebContents()->GetTitle(); 162 return web_view_->GetWebContents()->GetTitle();
147 } 163 }
148 164
149 gfx::ImageSkia AppActivity::GetIcon() const { 165 gfx::ImageSkia AppActivity::GetIcon() const {
150 return gfx::ImageSkia(); 166 return gfx::ImageSkia();
151 } 167 }
152 168
153 bool AppActivity::UsesFrame() const { 169 bool AppActivity::UsesFrame() const {
154 return false; 170 return false;
155 } 171 }
156 172
157 views::Widget* AppActivity::CreateWidget() {
158 // Before we remove the proxy, we have to register the activity and
159 // initialize its to move it to the proper activity list location.
160 RegisterActivity();
161 Init();
162 // Make sure the content gets properly shown.
163 if (current_state_ == ACTIVITY_VISIBLE) {
164 HideContentProxy();
165 } else if (current_state_ == ACTIVITY_INVISIBLE) {
166 ShowContentProxy();
167 } else {
168 // If not previously specified, we change the state now to invisible..
169 SetCurrentState(ACTIVITY_INVISIBLE);
170 }
171 return web_view_->GetWidget();
172 }
173
174 views::View* AppActivity::GetContentsView() { 173 views::View* AppActivity::GetContentsView() {
175 return web_view_; 174 return web_view_;
176 } 175 }
177 176
178 gfx::ImageSkia AppActivity::GetOverviewModeImage() { 177 gfx::ImageSkia AppActivity::GetOverviewModeImage() {
179 if (content_proxy_.get()) 178 if (content_proxy_.get())
180 return content_proxy_->GetContentImage(); 179 return content_proxy_->GetContentImage();
181 return gfx::ImageSkia(); 180 return gfx::ImageSkia();
182 } 181 }
183 182
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 void AppActivity::HideContentProxy() { 236 void AppActivity::HideContentProxy() {
238 content_proxy_.reset(); 237 content_proxy_.reset();
239 } 238 }
240 239
241 void AppActivity::ShowContentProxy() { 240 void AppActivity::ShowContentProxy() {
242 if (!content_proxy_.get() && web_view_) 241 if (!content_proxy_.get() && web_view_)
243 content_proxy_.reset(new ContentProxy(web_view_)); 242 content_proxy_.reset(new ContentProxy(web_view_));
244 } 243 }
245 244
246 } // namespace athena 245 } // namespace athena
OLDNEW
« no previous file with comments | « athena/content/app_activity.h ('k') | athena/content/app_activity_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698