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

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

Issue 694413005: athena: Introduce ActivityView. (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/activity/public/activity_view.h"
8 #include "athena/content/app_activity_registry.h" 9 #include "athena/content/app_activity_registry.h"
9 #include "athena/content/content_proxy.h" 10 #include "athena/content/content_proxy.h"
10 #include "athena/content/media_utils.h" 11 #include "athena/content/media_utils.h"
11 #include "athena/content/public/app_registry.h" 12 #include "athena/content/public/app_registry.h"
12 #include "athena/wm/public/window_list_provider.h" 13 #include "athena/wm/public/window_list_provider.h"
13 #include "athena/wm/public/window_manager.h" 14 #include "athena/wm/public/window_manager.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
16 #include "ui/views/controls/webview/webview.h" 17 #include "ui/views/controls/webview/webview.h"
17 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
18 #include "ui/wm/core/window_util.h" 19 #include "ui/wm/core/window_util.h"
19 20
20 namespace athena { 21 namespace athena {
21 22
22 // TODO(mukai): specifies the same accelerators of WebActivity. 23 // TODO(mukai): specifies the same accelerators of WebActivity.
23 AppActivity::AppActivity(const std::string& app_id, views::WebView* web_view) 24 AppActivity::AppActivity(const std::string& app_id, 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_(nullptr) { 28 app_activity_registry_(nullptr),
29 activity_view_(nullptr) {
28 Observe(web_view->GetWebContents()); 30 Observe(web_view->GetWebContents());
29 } 31 }
30 32
31 scoped_ptr<ContentProxy> AppActivity::GetContentProxy() { 33 scoped_ptr<ContentProxy> AppActivity::GetContentProxy() {
32 // Note: After this call, the content is still valid because the contents 34 // Note: After this call, the content is still valid because the contents
33 // destruction will destroy this |AppActivity| object. 35 // destruction will destroy this |AppActivity| object.
34 if (content_proxy_.get()) 36 if (content_proxy_.get())
35 content_proxy_->OnPreContentDestroyed(); 37 content_proxy_->OnPreContentDestroyed();
36 return content_proxy_.Pass(); 38 return content_proxy_.Pass();
37 } 39 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 161 }
160 162
161 base::string16 AppActivity::GetTitle() const { 163 base::string16 AppActivity::GetTitle() const {
162 return web_view_->GetWebContents()->GetTitle(); 164 return web_view_->GetWebContents()->GetTitle();
163 } 165 }
164 166
165 gfx::ImageSkia AppActivity::GetIcon() const { 167 gfx::ImageSkia AppActivity::GetIcon() const {
166 return gfx::ImageSkia(); 168 return gfx::ImageSkia();
167 } 169 }
168 170
171 void AppActivity::SetActivityView(ActivityView* view) {
172 DCHECK(!activity_view_);
173 activity_view_ = view;
174 }
175
169 bool AppActivity::UsesFrame() const { 176 bool AppActivity::UsesFrame() const {
170 return false; 177 return false;
171 } 178 }
172 179
173 views::View* AppActivity::GetContentsView() { 180 views::View* AppActivity::GetContentsView() {
174 return web_view_; 181 return web_view_;
175 } 182 }
176 183
177 gfx::ImageSkia AppActivity::GetOverviewModeImage() { 184 gfx::ImageSkia AppActivity::GetOverviewModeImage() {
178 if (content_proxy_.get()) 185 if (content_proxy_.get())
(...skipping 14 matching lines...) Expand all
193 if (!content_proxy_.get()) { 200 if (!content_proxy_.get()) {
194 web_view_->SetFastResize(false); 201 web_view_->SetFastResize(false);
195 web_view_->Layout(); 202 web_view_->Layout();
196 } 203 }
197 } 204 }
198 205
199 AppActivity::AppActivity(const std::string& app_id) 206 AppActivity::AppActivity(const std::string& app_id)
200 : app_id_(app_id), 207 : app_id_(app_id),
201 web_view_(nullptr), 208 web_view_(nullptr),
202 current_state_(ACTIVITY_UNLOADED), 209 current_state_(ACTIVITY_UNLOADED),
203 app_activity_registry_(nullptr) { 210 app_activity_registry_(nullptr),
211 activity_view_(nullptr) {
204 } 212 }
205 213
206 AppActivity::~AppActivity() { 214 AppActivity::~AppActivity() {
207 // If this activity is registered, we unregister it now. 215 // If this activity is registered, we unregister it now.
208 if (app_activity_registry_) 216 if (app_activity_registry_)
209 app_activity_registry_->UnregisterAppActivity(this); 217 app_activity_registry_->UnregisterAppActivity(this);
210 } 218 }
211 219
212 void AppActivity::TitleWasSet(content::NavigationEntry* entry, 220 void AppActivity::TitleWasSet(content::NavigationEntry* entry,
213 bool explicit_set) { 221 bool explicit_set) {
214 ActivityManager::Get()->UpdateActivity(this); 222 if (activity_view_)
223 activity_view_->UpdateTitle();
215 } 224 }
216 225
217 void AppActivity::DidUpdateFaviconURL( 226 void AppActivity::DidUpdateFaviconURL(
218 const std::vector<content::FaviconURL>& candidates) { 227 const std::vector<content::FaviconURL>& candidates) {
219 ActivityManager::Get()->UpdateActivity(this); 228 if (activity_view_)
229 activity_view_->UpdateIcon();
220 } 230 }
221 231
222 // Register an |activity| with an application. 232 // Register an |activity| with an application.
223 // Note: This should only get called once for an |app_window| of the 233 // Note: This should only get called once for an |app_window| of the
224 // |activity|. 234 // |activity|.
225 void AppActivity::RegisterActivity() { 235 void AppActivity::RegisterActivity() {
226 content::WebContents* web_contents = web_view_->GetWebContents(); 236 content::WebContents* web_contents = web_view_->GetWebContents();
227 AppRegistry* app_registry = AppRegistry::Get(); 237 AppRegistry* app_registry = AppRegistry::Get();
228 // Get the application's registry. 238 // Get the application's registry.
229 app_activity_registry_ = app_registry->GetAppActivityRegistry( 239 app_activity_registry_ = app_registry->GetAppActivityRegistry(
230 app_id_, web_contents->GetBrowserContext()); 240 app_id_, web_contents->GetBrowserContext());
231 DCHECK(app_activity_registry_); 241 DCHECK(app_activity_registry_);
232 // Register the activity. 242 // Register the activity.
233 app_activity_registry_->RegisterAppActivity(this); 243 app_activity_registry_->RegisterAppActivity(this);
234 } 244 }
235 245
236 void AppActivity::HideContentProxy() { 246 void AppActivity::HideContentProxy() {
237 content_proxy_.reset(); 247 content_proxy_.reset();
238 } 248 }
239 249
240 void AppActivity::ShowContentProxy() { 250 void AppActivity::ShowContentProxy() {
241 if (!content_proxy_.get() && web_view_) 251 if (!content_proxy_.get() && web_view_)
242 content_proxy_.reset(new ContentProxy(web_view_)); 252 content_proxy_.reset(new ContentProxy(web_view_));
243 } 253 }
244 254
245 } // namespace athena 255 } // 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