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

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

Issue 358003002: Additions to Activities to allow resource management (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « athena/content/app_activity.h ('k') | athena/content/web_activity.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 "apps/shell/browser/shell_app_window.h" 7 #include "apps/shell/browser/shell_app_window.h"
8 #include "athena/activity/public/activity_manager.h" 8 #include "athena/activity/public/activity_manager.h"
9 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
10 #include "ui/views/controls/webview/webview.h" 10 #include "ui/views/controls/webview/webview.h"
11 11
12 namespace athena { 12 namespace athena {
13 13
14 // TODO(mukai): specifies the same accelerators of WebActivity. 14 // TODO(mukai): specifies the same accelerators of WebActivity.
15 AppActivity::AppActivity(apps::ShellAppWindow* app_window) 15 AppActivity::AppActivity(apps::ShellAppWindow* app_window)
16 : app_window_(app_window), web_view_(NULL) { 16 : app_window_(app_window),
17 web_view_(NULL),
18 current_state_(ACTIVITY_UNLOADED) {
17 DCHECK(app_window_); 19 DCHECK(app_window_);
18 } 20 }
19 21
20 AppActivity::~AppActivity() { 22 AppActivity::~AppActivity() {
23 if (GetCurrentState() != ACTIVITY_UNLOADED)
24 SetCurrentState(ACTIVITY_UNLOADED);
21 } 25 }
22 26
23 ActivityViewModel* AppActivity::GetActivityViewModel() { 27 ActivityViewModel* AppActivity::GetActivityViewModel() {
24 return this; 28 return this;
25 } 29 }
26 30
31 void AppActivity::SetCurrentState(Activity::ActivityState state) {
32 switch (state) {
33 case ACTIVITY_VISIBLE:
34 // Fall through (for the moment).
35 case ACTIVITY_INVISIBLE:
36 // By clearing the overview mode image we allow the content to be shown.
37 overview_mode_image_ = gfx::ImageSkia();
38 // TODO(skuhne): Find out how to reload an app from the extension system.
39 break;
40 case ACTIVITY_BACKGROUND_LOW_PRIORITY:
41 DCHECK(ACTIVITY_VISIBLE == current_state_ ||
42 ACTIVITY_INVISIBLE == current_state_);
43 // TODO(skuhne): Do this.
44 break;
45 case ACTIVITY_PERSISTENT:
46 DCHECK_EQ(ACTIVITY_BACKGROUND_LOW_PRIORITY, current_state_);
47 // TODO(skuhne): Do this.
48 break;
49 case ACTIVITY_UNLOADED:
50 DCHECK_NE(ACTIVITY_UNLOADED, current_state_);
51 // TODO(skuhne): Find out how to evict an app from the extension system.
52 // web_view_->EvictContent();
53 break;
54 }
55 // Remember the last requested state.
56 current_state_ = state;
57 }
58
59 Activity::ActivityState AppActivity::GetCurrentState() {
60 // TODO(skuhne): Check here also eviction status.
61 if (!web_view_) {
62 DCHECK_EQ(ACTIVITY_UNLOADED, current_state_);
63 return ACTIVITY_UNLOADED;
64 }
65 // TODO(skuhne): This should be controlled by an observer and should not
66 // reside here.
67 if (IsVisible() && current_state_ != ACTIVITY_VISIBLE)
68 SetCurrentState(ACTIVITY_VISIBLE);
69 // Note: If the activity is not visible it does not necessarily mean that it
70 // does not have GPU compositor resources (yet).
71 return current_state_;
72 }
73
74 bool AppActivity::IsVisible() {
75 return web_view_ && web_view_->IsDrawn();
76 }
77
78 Activity::ActivityMediaState AppActivity::GetMediaState() {
79 // TODO(skuhne): The function GetTabMediaStateForContents(WebContents),
80 // and the AudioStreamMonitor needs to be moved from Chrome into contents to
81 // make it more modular and so that we can use it from here.
82 return Activity::ACTIVITY_MEDIA_STATE_NONE;
83 }
84
27 void AppActivity::Init() { 85 void AppActivity::Init() {
28 } 86 }
29 87
30 SkColor AppActivity::GetRepresentativeColor() const { 88 SkColor AppActivity::GetRepresentativeColor() const {
31 // TODO(sad): Compute the color from the favicon. 89 // TODO(sad): Compute the color from the favicon.
32 return SK_ColorGRAY; 90 return SK_ColorGRAY;
33 } 91 }
34 92
35 base::string16 AppActivity::GetTitle() const { 93 base::string16 AppActivity::GetTitle() const {
36 return web_view_->GetWebContents()->GetTitle(); 94 return web_view_->GetWebContents()->GetTitle();
37 } 95 }
38 96
39 bool AppActivity::UsesFrame() const { 97 bool AppActivity::UsesFrame() const {
40 return false; 98 return false;
41 } 99 }
42 100
43 views::View* AppActivity::GetContentsView() { 101 views::View* AppActivity::GetContentsView() {
44 if (!web_view_) { 102 if (!web_view_) {
45 // TODO(oshima): use apps::NativeAppWindowViews 103 // TODO(oshima): use apps::NativeAppWindowViews
46 content::WebContents* web_contents = 104 content::WebContents* web_contents =
47 app_window_->GetAssociatedWebContents(); 105 app_window_->GetAssociatedWebContents();
48 web_view_ = new views::WebView(web_contents->GetBrowserContext()); 106 web_view_ = new views::WebView(web_contents->GetBrowserContext());
49 web_view_->SetWebContents(web_contents); 107 web_view_->SetWebContents(web_contents);
108 SetCurrentState(ACTIVITY_INVISIBLE);
50 Observe(web_contents); 109 Observe(web_contents);
110 overview_mode_image_ = gfx::ImageSkia();
51 } 111 }
52 return web_view_; 112 return web_view_;
53 } 113 }
54 114
115 void AppActivity::CreateOverviewModeImage() {
116 // TODO(skuhne): Implement this!
117 }
118
119 gfx::ImageSkia AppActivity::GetOverviewModeImage() {
120 return overview_mode_image_;
121 }
122
55 void AppActivity::TitleWasSet(content::NavigationEntry* entry, 123 void AppActivity::TitleWasSet(content::NavigationEntry* entry,
56 bool explicit_set) { 124 bool explicit_set) {
57 ActivityManager::Get()->UpdateActivity(this); 125 ActivityManager::Get()->UpdateActivity(this);
58 } 126 }
59 127
60 void AppActivity::DidUpdateFaviconURL( 128 void AppActivity::DidUpdateFaviconURL(
61 const std::vector<content::FaviconURL>& candidates) { 129 const std::vector<content::FaviconURL>& candidates) {
62 ActivityManager::Get()->UpdateActivity(this); 130 ActivityManager::Get()->UpdateActivity(this);
63 } 131 }
64 132
65 } // namespace athena 133 } // namespace athena
OLDNEW
« no previous file with comments | « athena/content/app_activity.h ('k') | athena/content/web_activity.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698