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

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

Issue 587953002: [Athena: Cleanup] consolidate ChromeAppActivity and ShellAppActivity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « athena/content/app_activity.h ('k') | athena/content/app_activity_unittest.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/public/app_registry.h" 10 #include "athena/content/public/app_registry.h"
11 #include "athena/wm/public/window_list_provider.h" 11 #include "athena/wm/public/window_list_provider.h"
12 #include "athena/wm/public/window_manager.h" 12 #include "athena/wm/public/window_manager.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "extensions/browser/app_window/app_window.h"
14 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
15 #include "ui/views/controls/webview/webview.h" 16 #include "ui/views/controls/webview/webview.h"
16 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
17 18
18 namespace athena { 19 namespace athena {
19 20
20 // TODO(mukai): specifies the same accelerators of WebActivity. 21 // TODO(mukai): specifies the same accelerators of WebActivity.
21 AppActivity::AppActivity(const std::string& app_id) 22 AppActivity::AppActivity(extensions::AppWindow* app_window,
22 : app_id_(app_id), 23 views::WebView* web_view)
23 web_view_(NULL), 24 : app_id_(app_window->extension_id()),
25 web_view_(web_view),
24 current_state_(ACTIVITY_UNLOADED), 26 current_state_(ACTIVITY_UNLOADED),
25 app_activity_registry_(NULL) { 27 app_activity_registry_(NULL) {
28 DCHECK_EQ(app_window->web_contents(), web_view->GetWebContents());
29 Observe(app_window->web_contents());
26 } 30 }
27 31
28 scoped_ptr<ContentProxy> AppActivity::GetContentProxy(aura::Window* window) { 32 scoped_ptr<ContentProxy> AppActivity::GetContentProxy(aura::Window* window) {
29 if (content_proxy_.get()) 33 if (content_proxy_.get())
30 content_proxy_->Reparent(window); 34 content_proxy_->Reparent(window);
31 return content_proxy_.Pass(); 35 return content_proxy_.Pass();
32 } 36 }
33 37
34 ActivityViewModel* AppActivity::GetActivityViewModel() { 38 ActivityViewModel* AppActivity::GetActivityViewModel() {
35 return this; 39 return this;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 122 }
119 123
120 gfx::ImageSkia AppActivity::GetIcon() const { 124 gfx::ImageSkia AppActivity::GetIcon() const {
121 return gfx::ImageSkia(); 125 return gfx::ImageSkia();
122 } 126 }
123 127
124 bool AppActivity::UsesFrame() const { 128 bool AppActivity::UsesFrame() const {
125 return false; 129 return false;
126 } 130 }
127 131
132 views::Widget* AppActivity::CreateWidget() {
133 // Make sure the content gets properly shown.
134 if (current_state_ == ACTIVITY_VISIBLE) {
135 HideContentProxy();
136 } else if (current_state_ == ACTIVITY_INVISIBLE) {
137 ShowContentProxy();
138 } else {
139 // If not previously specified, we change the state now to invisible..
140 SetCurrentState(ACTIVITY_INVISIBLE);
141 }
142 RegisterActivity();
143 return web_view_->GetWidget();
144 }
145
128 views::View* AppActivity::GetContentsView() { 146 views::View* AppActivity::GetContentsView() {
129 if (!web_view_) {
130 web_view_ = GetWebView();
131 // Make sure the content gets properly shown.
132 if (current_state_ == ACTIVITY_VISIBLE) {
133 HideContentProxy();
134 } else if (current_state_ == ACTIVITY_INVISIBLE) {
135 ShowContentProxy();
136 } else {
137 // If not previously specified, we change the state now to invisible..
138 SetCurrentState(ACTIVITY_INVISIBLE);
139 }
140 RegisterActivity();
141 }
142 return web_view_; 147 return web_view_;
143 } 148 }
144 149
145 gfx::ImageSkia AppActivity::GetOverviewModeImage() { 150 gfx::ImageSkia AppActivity::GetOverviewModeImage() {
146 if (content_proxy_.get()) 151 if (content_proxy_.get())
147 return content_proxy_->GetContentImage(); 152 return content_proxy_->GetContentImage();
148 return gfx::ImageSkia(); 153 return gfx::ImageSkia();
149 } 154 }
150 155
151 void AppActivity::PrepareContentsForOverview() { 156 void AppActivity::PrepareContentsForOverview() {
152 // Turn on fast resizing to avoid re-laying out the web contents when 157 // Turn on fast resizing to avoid re-laying out the web contents when
153 // entering / exiting overview mode and the content is visible. 158 // entering / exiting overview mode and the content is visible.
154 if (!content_proxy_.get()) 159 if (!content_proxy_.get())
155 web_view_->SetFastResize(true); 160 web_view_->SetFastResize(true);
156 } 161 }
157 162
158 void AppActivity::ResetContentsView() { 163 void AppActivity::ResetContentsView() {
159 // Turn on fast resizing to avoid re-laying out the web contents when 164 // Turn on fast resizing to avoid re-laying out the web contents when
160 // entering / exiting overview mode and the content is visible. 165 // entering / exiting overview mode and the content is visible.
161 if (!content_proxy_.get()) { 166 if (!content_proxy_.get()) {
162 web_view_->SetFastResize(false); 167 web_view_->SetFastResize(false);
163 web_view_->Layout(); 168 web_view_->Layout();
164 } 169 }
165 } 170 }
166 171
172 AppActivity::AppActivity(const std::string& app_id)
173 : app_id_(app_id),
174 web_view_(NULL),
175 current_state_(ACTIVITY_UNLOADED),
176 app_activity_registry_(NULL) {
177 }
178
167 AppActivity::~AppActivity() { 179 AppActivity::~AppActivity() {
168 // If this activity is registered, we unregister it now. 180 // If this activity is registered, we unregister it now.
169 if (app_activity_registry_) 181 if (app_activity_registry_)
170 app_activity_registry_->UnregisterAppActivity(this); 182 app_activity_registry_->UnregisterAppActivity(this);
171 } 183 }
172 184
173 void AppActivity::TitleWasSet(content::NavigationEntry* entry, 185 void AppActivity::TitleWasSet(content::NavigationEntry* entry,
174 bool explicit_set) { 186 bool explicit_set) {
175 ActivityManager::Get()->UpdateActivity(this); 187 ActivityManager::Get()->UpdateActivity(this);
176 } 188 }
(...skipping 20 matching lines...) Expand all
197 void AppActivity::HideContentProxy() { 209 void AppActivity::HideContentProxy() {
198 content_proxy_.reset(); 210 content_proxy_.reset();
199 } 211 }
200 212
201 void AppActivity::ShowContentProxy() { 213 void AppActivity::ShowContentProxy() {
202 if (!content_proxy_.get() && web_view_) 214 if (!content_proxy_.get() && web_view_)
203 content_proxy_.reset(new ContentProxy(web_view_, this)); 215 content_proxy_.reset(new ContentProxy(web_view_, this));
204 } 216 }
205 217
206 } // namespace athena 218 } // namespace athena
OLDNEW
« no previous file with comments | « athena/content/app_activity.h ('k') | athena/content/app_activity_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698