| OLD | NEW |
| 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" | 8 #include "athena/content/app_activity_registry.h" |
| 9 #include "athena/content/public/app_content_control_delegate.h" | 9 #include "athena/content/public/app_content_control_delegate.h" |
| 10 #include "athena/content/public/app_registry.h" | 10 #include "athena/content/public/app_registry.h" |
| 11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "ui/aura/window.h" |
| 12 #include "ui/views/controls/webview/webview.h" | 13 #include "ui/views/controls/webview/webview.h" |
| 13 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
| 14 | 15 |
| 15 namespace athena { | 16 namespace athena { |
| 16 | 17 |
| 17 // TODO(mukai): specifies the same accelerators of WebActivity. | 18 // TODO(mukai): specifies the same accelerators of WebActivity. |
| 18 AppActivity::AppActivity() | 19 AppActivity::AppActivity() |
| 19 : web_view_(NULL), | 20 : web_view_(NULL), |
| 20 current_state_(ACTIVITY_UNLOADED), | 21 current_state_(ACTIVITY_UNLOADED), |
| 21 app_activity_registry_(NULL) { | 22 app_activity_registry_(NULL) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // TODO(skuhne): This should be controlled by an observer and should not | 75 // TODO(skuhne): This should be controlled by an observer and should not |
| 75 // reside here. | 76 // reside here. |
| 76 if (IsVisible() && current_state_ != ACTIVITY_VISIBLE) | 77 if (IsVisible() && current_state_ != ACTIVITY_VISIBLE) |
| 77 SetCurrentState(ACTIVITY_VISIBLE); | 78 SetCurrentState(ACTIVITY_VISIBLE); |
| 78 // Note: If the activity is not visible it does not necessarily mean that it | 79 // Note: If the activity is not visible it does not necessarily mean that it |
| 79 // does not have GPU compositor resources (yet). | 80 // does not have GPU compositor resources (yet). |
| 80 return current_state_; | 81 return current_state_; |
| 81 } | 82 } |
| 82 | 83 |
| 83 bool AppActivity::IsVisible() { | 84 bool AppActivity::IsVisible() { |
| 84 return web_view_ && web_view_->IsDrawn(); | 85 return web_view_ && |
| 86 web_view_->IsDrawn() && |
| 87 current_state_ != ACTIVITY_UNLOADED && |
| 88 GetWindow() && |
| 89 GetWindow()->IsVisible(); |
| 85 } | 90 } |
| 86 | 91 |
| 87 Activity::ActivityMediaState AppActivity::GetMediaState() { | 92 Activity::ActivityMediaState AppActivity::GetMediaState() { |
| 88 // TODO(skuhne): The function GetTabMediaStateForContents(WebContents), | 93 // TODO(skuhne): The function GetTabMediaStateForContents(WebContents), |
| 89 // and the AudioStreamMonitor needs to be moved from Chrome into contents to | 94 // and the AudioStreamMonitor needs to be moved from Chrome into contents to |
| 90 // make it more modular and so that we can use it from here. | 95 // make it more modular and so that we can use it from here. |
| 91 return Activity::ACTIVITY_MEDIA_STATE_NONE; | 96 return Activity::ACTIVITY_MEDIA_STATE_NONE; |
| 92 } | 97 } |
| 93 | 98 |
| 94 aura::Window* AppActivity::GetWindow() { | 99 aura::Window* AppActivity::GetWindow() { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // Get the application's registry. | 163 // Get the application's registry. |
| 159 app_activity_registry_ = app_registry->GetAppActivityRegistry( | 164 app_activity_registry_ = app_registry->GetAppActivityRegistry( |
| 160 app_registry->GetDelegate()->GetApplicationID(web_contents), | 165 app_registry->GetDelegate()->GetApplicationID(web_contents), |
| 161 web_contents->GetBrowserContext()); | 166 web_contents->GetBrowserContext()); |
| 162 DCHECK(app_activity_registry_); | 167 DCHECK(app_activity_registry_); |
| 163 // Register the activity. | 168 // Register the activity. |
| 164 app_activity_registry_->RegisterAppActivity(this); | 169 app_activity_registry_->RegisterAppActivity(this); |
| 165 } | 170 } |
| 166 | 171 |
| 167 } // namespace athena | 172 } // namespace athena |
| OLD | NEW |