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_registry.h" | 9 #include "athena/content/public/app_registry.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 11 #include "ui/aura/window.h" |
11 #include "ui/views/controls/webview/webview.h" | 12 #include "ui/views/controls/webview/webview.h" |
12 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
13 | 14 |
14 namespace athena { | 15 namespace athena { |
15 | 16 |
16 // TODO(mukai): specifies the same accelerators of WebActivity. | 17 // TODO(mukai): specifies the same accelerators of WebActivity. |
17 AppActivity::AppActivity(const std::string& app_id) | 18 AppActivity::AppActivity(const std::string& app_id) |
18 : app_id_(app_id), | 19 : app_id_(app_id), |
19 web_view_(NULL), | 20 web_view_(NULL), |
20 current_state_(ACTIVITY_UNLOADED), | 21 current_state_(ACTIVITY_UNLOADED), |
(...skipping 53 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 AppRegistry* app_registry = AppRegistry::Get(); | 156 AppRegistry* app_registry = AppRegistry::Get(); |
152 // Get the application's registry. | 157 // Get the application's registry. |
153 app_activity_registry_ = app_registry->GetAppActivityRegistry( | 158 app_activity_registry_ = app_registry->GetAppActivityRegistry( |
154 app_id_, web_contents->GetBrowserContext()); | 159 app_id_, web_contents->GetBrowserContext()); |
155 DCHECK(app_activity_registry_); | 160 DCHECK(app_activity_registry_); |
156 // Register the activity. | 161 // Register the activity. |
157 app_activity_registry_->RegisterAppActivity(this); | 162 app_activity_registry_->RegisterAppActivity(this); |
158 } | 163 } |
159 | 164 |
160 } // namespace athena | 165 } // namespace athena |
OLD | NEW |