| Index: athena/content/app_activity.cc
|
| diff --git a/athena/content/app_activity.cc b/athena/content/app_activity.cc
|
| index e25d9f32150ee89bbdd5fc35b51fe32404376099..79b1ca1f7a1bb15268513d70b1787a46acfef090 100644
|
| --- a/athena/content/app_activity.cc
|
| +++ b/athena/content/app_activity.cc
|
| @@ -13,17 +13,82 @@ namespace athena {
|
|
|
| // TODO(mukai): specifies the same accelerators of WebActivity.
|
| AppActivity::AppActivity(apps::ShellAppWindow* app_window)
|
| - : app_window_(app_window), web_view_(NULL) {
|
| + : app_window_(app_window),
|
| + web_view_(NULL),
|
| + last_requested_state_(ACTIVITY_UNLOAD) {
|
| DCHECK(app_window_);
|
| }
|
|
|
| AppActivity::~AppActivity() {
|
| + if (GetCurrentState() != ACTIVITY_STATE_UNLOADED)
|
| + SetCurrentState(ACTIVITY_UNLOAD);
|
| }
|
|
|
| ActivityViewModel* AppActivity::GetActivityViewModel() {
|
| return this;
|
| }
|
|
|
| +void AppActivity::SetCurrentState(Activity::ActivityStateTransition state) {
|
| + switch (state) {
|
| + case ACTIVITY_LOAD:
|
| + // By clearing the overview mode image we allow the content to be shown.
|
| + overview_mode_image_ = gfx::ImageSkia();
|
| +// TODO(skuhne): Find out how to reload an app from the extension system.
|
| +// If this does not work, the eviction needs to take place at a higher level.
|
| +// if (web_view_->IsContentEvicted()) {
|
| +// DCHECK_EQ(ACTIVITY_UNLOAD, last_requested_state_);
|
| +// web_view_->ReloadContent();
|
| +// }
|
| + break;
|
| + case ACTIVITY_DEEP_SLEEP_1:
|
| + DCHECK_EQ(ACTIVITY_LOAD, last_requested_state_);
|
| + // TODO(skuhne): Do this. As soon as the new resource management is
|
| + // agreed upon - or remove otherwise.
|
| + break;
|
| + case ACTIVITY_DEEP_SLEEP_2:
|
| + DCHECK_EQ(ACTIVITY_DEEP_SLEEP_1, last_requested_state_);
|
| + // TODO(skuhne): Do this. As soon as the new resource management is
|
| + // agreed upon - or remove otherwise.
|
| + break;
|
| + case ACTIVITY_UNLOAD:
|
| + DCHECK_NE(ACTIVITY_UNLOAD, last_requested_state_);
|
| +// TODO(skuhne): Find out how to evict an app from the extension system.
|
| +// web_view_->EvictContent();
|
| + break;
|
| + }
|
| + // Remember the last requested state.
|
| + last_requested_state_ = state;
|
| +}
|
| +
|
| +Activity::ActivityState AppActivity::GetCurrentState() {
|
| + if (!web_view_) {
|
| + DCHECK_EQ(ACTIVITY_UNLOAD, last_requested_state_);
|
| + return ACTIVITY_STATE_UNLOADED;
|
| + }
|
| +
|
| + switch(last_requested_state_) {
|
| + case ACTIVITY_LOAD:
|
| + if (web_view_->IsDrawn())
|
| + return ACTIVITY_STATE_VISIBLE;
|
| + /*
|
| + // TODO(skuhne): AudioStreamMonitor is currently a part of Chrome and
|
| + // needs to be moved some levels up.
|
| + AudioStreamMonitor* const audio_stream_monitor =
|
| + AudioStreamMonitor::FromWebContents(contents);
|
| + if (audio_stream_monitor && audio_stream_monitor->WasRecentlyAudible())
|
| + return ACTIVITY_STATE_BACKGROUND_ACTIVE;
|
| + */
|
| + return ACTIVITY_STATE_HIDDEN;
|
| + case ACTIVITY_DEEP_SLEEP_1:
|
| + return ACTIVITY_STATE_DEEP_SLEEP_1;
|
| + case ACTIVITY_DEEP_SLEEP_2:
|
| + return ACTIVITY_STATE_DEEP_SLEEP_2;
|
| + case ACTIVITY_UNLOAD:
|
| + return ACTIVITY_STATE_UNLOADED;
|
| + }
|
| + return ACTIVITY_STATE_UNLOADED;
|
| +}
|
| +
|
| void AppActivity::Init() {
|
| }
|
|
|
| @@ -42,11 +107,21 @@ views::View* AppActivity::GetContentsView() {
|
| app_window_->GetAssociatedWebContents();
|
| web_view_ = new views::WebView(web_contents->GetBrowserContext());
|
| web_view_->SetWebContents(web_contents);
|
| + SetCurrentState(ACTIVITY_LOAD);
|
| Observe(web_contents);
|
| + overview_mode_image_ = gfx::ImageSkia();
|
| }
|
| return web_view_;
|
| }
|
|
|
| +void AppActivity::CreateOverviewModeImage() {
|
| + // TODO(skuhne): Implement this!
|
| +}
|
| +
|
| +gfx::ImageSkia AppActivity::GetOverviewModeImage() {
|
| + return overview_mode_image_;
|
| +}
|
| +
|
| void AppActivity::TitleWasSet(content::NavigationEntry* entry,
|
| bool explicit_set) {
|
| ActivityManager::Get()->UpdateActivity(this);
|
|
|