| Index: athena/content/app_activity.cc
|
| diff --git a/athena/content/app_activity.cc b/athena/content/app_activity.cc
|
| index cd32be889deb4e4ed1f89eb2adb1d5685f94b6ec..3a4cb693cc738d920c21e0b6bfa4c4e9658281b7 100644
|
| --- a/athena/content/app_activity.cc
|
| +++ b/athena/content/app_activity.cc
|
| @@ -13,17 +13,75 @@ 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),
|
| + current_state_(ACTIVITY_UNLOADED) {
|
| DCHECK(app_window_);
|
| }
|
|
|
| AppActivity::~AppActivity() {
|
| + if (GetCurrentState() != ACTIVITY_UNLOADED)
|
| + SetCurrentState(ACTIVITY_UNLOADED);
|
| }
|
|
|
| ActivityViewModel* AppActivity::GetActivityViewModel() {
|
| return this;
|
| }
|
|
|
| +void AppActivity::SetCurrentState(Activity::ActivityState state) {
|
| + switch (state) {
|
| + case ACTIVITY_VISIBLE:
|
| + // Fall through (for the moment).
|
| + case ACTIVITY_INVISIBLE:
|
| + // 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.
|
| + break;
|
| + case ACTIVITY_BACKGROUND_LOW_PRIORITY:
|
| + DCHECK(ACTIVITY_VISIBLE == current_state_ ||
|
| + ACTIVITY_INVISIBLE == current_state_);
|
| + // TODO(skuhne): Do this.
|
| + break;
|
| + case ACTIVITY_PERSISTENT:
|
| + DCHECK_EQ(ACTIVITY_BACKGROUND_LOW_PRIORITY, current_state_);
|
| + // TODO(skuhne): Do this.
|
| + break;
|
| + case ACTIVITY_UNLOADED:
|
| + DCHECK_NE(ACTIVITY_UNLOADED, current_state_);
|
| + // TODO(skuhne): Find out how to evict an app from the extension system.
|
| + // web_view_->EvictContent();
|
| + break;
|
| + }
|
| + // Remember the last requested state.
|
| + current_state_ = state;
|
| +}
|
| +
|
| +Activity::ActivityState AppActivity::GetCurrentState() {
|
| + // TODO(skuhne): Check here also eviction status.
|
| + if (!web_view_) {
|
| + DCHECK_EQ(ACTIVITY_UNLOADED, current_state_);
|
| + return ACTIVITY_UNLOADED;
|
| + }
|
| + // TODO(skuhne): This should be controlled by an observer and should not
|
| + // reside here.
|
| + if (IsVisible() && current_state_ != ACTIVITY_VISIBLE)
|
| + SetCurrentState(ACTIVITY_VISIBLE);
|
| + // Note: If the activity is not visible it does not necessarily mean that it
|
| + // does not have GPU compositor resources (yet).
|
| + return current_state_;
|
| +}
|
| +
|
| +bool AppActivity::IsVisible() {
|
| + return web_view_ && web_view_->IsDrawn();
|
| +}
|
| +
|
| +Activity::ActivityMediaState AppActivity::GetMediaState() {
|
| + // TODO(skuhne): The function GetTabMediaStateForContents(WebContents),
|
| + // and the AudioStreamMonitor needs to be moved from Chrome into contents to
|
| + // make it more modular and so that we can use it from here.
|
| + return Activity::ACTIVITY_MEDIA_STATE_NONE;
|
| +}
|
| +
|
| void AppActivity::Init() {
|
| }
|
|
|
| @@ -47,11 +105,21 @@ views::View* AppActivity::GetContentsView() {
|
| app_window_->GetAssociatedWebContents();
|
| web_view_ = new views::WebView(web_contents->GetBrowserContext());
|
| web_view_->SetWebContents(web_contents);
|
| + SetCurrentState(ACTIVITY_INVISIBLE);
|
| 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);
|
|
|