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

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

Issue 497013002: Revert 291221 "Athena: Adding basic resource management framewor..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 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 | « trunk/src/athena/content/app_activity.h ('k') | trunk/src/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"
9 #include "athena/content/public/app_content_control_delegate.h"
10 #include "athena/content/public/app_registry.h"
11 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
12 #include "extensions/shell/browser/shell_app_window.h" 9 #include "extensions/shell/browser/shell_app_window.h"
13 #include "ui/views/controls/webview/webview.h" 10 #include "ui/views/controls/webview/webview.h"
14 #include "ui/views/widget/widget.h"
15 11
16 namespace athena { 12 namespace athena {
17 13
18 // TODO(mukai): specifies the same accelerators of WebActivity. 14 // TODO(mukai): specifies the same accelerators of WebActivity.
19 AppActivity::AppActivity(extensions::ShellAppWindow* app_window) 15 AppActivity::AppActivity(extensions::ShellAppWindow* app_window)
20 : app_window_(app_window), 16 : app_window_(app_window),
21 web_view_(NULL), 17 web_view_(NULL),
22 current_state_(ACTIVITY_UNLOADED), 18 current_state_(ACTIVITY_UNLOADED) {
23 app_activity_registry_(NULL) { 19 DCHECK(app_window_);
24 } 20 }
25 21
26 AppActivity::~AppActivity() { 22 AppActivity::~AppActivity() {
27 // If this activity is registered, we unregister it now. 23 if (GetCurrentState() != ACTIVITY_UNLOADED)
28 if (app_activity_registry_) 24 SetCurrentState(ACTIVITY_UNLOADED);
29 app_activity_registry_->UnregisterAppActivity(this);
30 } 25 }
31 26
32 ActivityViewModel* AppActivity::GetActivityViewModel() { 27 ActivityViewModel* AppActivity::GetActivityViewModel() {
33 return this; 28 return this;
34 } 29 }
35 30
36 void AppActivity::SetCurrentState(Activity::ActivityState state) { 31 void AppActivity::SetCurrentState(Activity::ActivityState state) {
37 ActivityState current_state = state;
38 // Remember the last requested state now so that a call to GetCurrentState()
39 // returns the new state.
40 current_state_ = state;
41
42 switch (state) { 32 switch (state) {
43 case ACTIVITY_VISIBLE: 33 case ACTIVITY_VISIBLE:
44 // Fall through (for the moment). 34 // Fall through (for the moment).
45 case ACTIVITY_INVISIBLE: 35 case ACTIVITY_INVISIBLE:
46 // By clearing the overview mode image we allow the content to be shown. 36 // By clearing the overview mode image we allow the content to be shown.
47 overview_mode_image_ = gfx::ImageSkia(); 37 overview_mode_image_ = gfx::ImageSkia();
48 // Note: A reload from the unloaded state will be performed through the 38 // TODO(skuhne): Find out how to reload an app from the extension system.
49 // |AppActivityProxy| object and no further action isn't necessary here.
50 break; 39 break;
51 case ACTIVITY_BACKGROUND_LOW_PRIORITY: 40 case ACTIVITY_BACKGROUND_LOW_PRIORITY:
52 DCHECK(ACTIVITY_VISIBLE == current_state || 41 DCHECK(ACTIVITY_VISIBLE == current_state_ ||
53 ACTIVITY_INVISIBLE == current_state); 42 ACTIVITY_INVISIBLE == current_state_);
54 // TODO(skuhne): Do this. 43 // TODO(skuhne): Do this.
55 break; 44 break;
56 case ACTIVITY_PERSISTENT: 45 case ACTIVITY_PERSISTENT:
57 DCHECK_EQ(ACTIVITY_BACKGROUND_LOW_PRIORITY, current_state); 46 DCHECK_EQ(ACTIVITY_BACKGROUND_LOW_PRIORITY, current_state_);
58 // TODO(skuhne): Do this. 47 // TODO(skuhne): Do this.
59 break; 48 break;
60 case ACTIVITY_UNLOADED: 49 case ACTIVITY_UNLOADED:
61 DCHECK_NE(ACTIVITY_UNLOADED, current_state); 50 DCHECK_NE(ACTIVITY_UNLOADED, current_state_);
62 // This will cause the application to shut down, close its windows and 51 // TODO(skuhne): Find out how to evict an app from the extension system.
63 // delete this object. Instead a |AppActivityProxy| will be created as 52 // web_view_->EvictContent();
64 // place holder.
65 if (app_activity_registry_)
66 app_activity_registry_->Unload();
67 break; 53 break;
68 } 54 }
55 // Remember the last requested state.
56 current_state_ = state;
69 } 57 }
70 58
71 Activity::ActivityState AppActivity::GetCurrentState() { 59 Activity::ActivityState AppActivity::GetCurrentState() {
60 // TODO(skuhne): Check here also eviction status.
72 if (!web_view_) { 61 if (!web_view_) {
73 DCHECK_EQ(ACTIVITY_UNLOADED, current_state_); 62 DCHECK_EQ(ACTIVITY_UNLOADED, current_state_);
74 return ACTIVITY_UNLOADED; 63 return ACTIVITY_UNLOADED;
75 } 64 }
76 // TODO(skuhne): This should be controlled by an observer and should not 65 // TODO(skuhne): This should be controlled by an observer and should not
77 // reside here. 66 // reside here.
78 if (IsVisible() && current_state_ != ACTIVITY_VISIBLE) 67 if (IsVisible() && current_state_ != ACTIVITY_VISIBLE)
79 SetCurrentState(ACTIVITY_VISIBLE); 68 SetCurrentState(ACTIVITY_VISIBLE);
80 // Note: If the activity is not visible it does not necessarily mean that it 69 // Note: If the activity is not visible it does not necessarily mean that it
81 // does not have GPU compositor resources (yet). 70 // does not have GPU compositor resources (yet).
82 return current_state_; 71 return current_state_;
83 } 72 }
84 73
85 bool AppActivity::IsVisible() { 74 bool AppActivity::IsVisible() {
86 return web_view_ && web_view_->IsDrawn(); 75 return web_view_ && web_view_->IsDrawn();
87 } 76 }
88 77
89 Activity::ActivityMediaState AppActivity::GetMediaState() { 78 Activity::ActivityMediaState AppActivity::GetMediaState() {
90 // TODO(skuhne): The function GetTabMediaStateForContents(WebContents), 79 // TODO(skuhne): The function GetTabMediaStateForContents(WebContents),
91 // and the AudioStreamMonitor needs to be moved from Chrome into contents to 80 // and the AudioStreamMonitor needs to be moved from Chrome into contents to
92 // make it more modular and so that we can use it from here. 81 // make it more modular and so that we can use it from here.
93 return Activity::ACTIVITY_MEDIA_STATE_NONE; 82 return Activity::ACTIVITY_MEDIA_STATE_NONE;
94 } 83 }
95 84
96 aura::Window* AppActivity::GetWindow() {
97 return !web_view_ ? NULL : web_view_->GetWidget()->GetNativeWindow();
98 }
99
100 void AppActivity::Init() { 85 void AppActivity::Init() {
101 } 86 }
102 87
103 SkColor AppActivity::GetRepresentativeColor() const { 88 SkColor AppActivity::GetRepresentativeColor() const {
104 // TODO(sad): Compute the color from the favicon. 89 // TODO(sad): Compute the color from the favicon.
105 return SK_ColorGRAY; 90 return SK_ColorGRAY;
106 } 91 }
107 92
108 base::string16 AppActivity::GetTitle() const { 93 base::string16 AppActivity::GetTitle() const {
109 return web_view_->GetWebContents()->GetTitle(); 94 return web_view_->GetWebContents()->GetTitle();
(...skipping 28 matching lines...) Expand all
138 void AppActivity::TitleWasSet(content::NavigationEntry* entry, 123 void AppActivity::TitleWasSet(content::NavigationEntry* entry,
139 bool explicit_set) { 124 bool explicit_set) {
140 ActivityManager::Get()->UpdateActivity(this); 125 ActivityManager::Get()->UpdateActivity(this);
141 } 126 }
142 127
143 void AppActivity::DidUpdateFaviconURL( 128 void AppActivity::DidUpdateFaviconURL(
144 const std::vector<content::FaviconURL>& candidates) { 129 const std::vector<content::FaviconURL>& candidates) {
145 ActivityManager::Get()->UpdateActivity(this); 130 ActivityManager::Get()->UpdateActivity(this);
146 } 131 }
147 132
148 void AppActivity::DidStartNavigationToPendingEntry(
149 const GURL& url,
150 content::NavigationController::ReloadType reload_type) {
151 if (!app_activity_registry_)
152 RegisterActivity();
153 }
154
155 // Register an |activity| with an application.
156 // Note: This should only get called once for an |app_window| of the
157 // |activity|.
158 void AppActivity::RegisterActivity() {
159 content::WebContents* web_contents = app_window_->GetAssociatedWebContents();
160 AppRegistry* app_registry = AppRegistry::Get();
161 // Get the application's registry.
162 app_activity_registry_ = app_registry->GetAppActivityRegistry(
163 app_registry->GetDelegate()->GetApplicationID(web_contents),
164 web_contents->GetBrowserContext());
165 DCHECK(app_activity_registry_);
166 // Register the activity.
167 app_activity_registry_->RegisterAppActivity(this);
168 }
169
170 } // namespace athena 133 } // namespace athena
OLDNEW
« no previous file with comments | « trunk/src/athena/content/app_activity.h ('k') | trunk/src/athena/content/app_activity_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698