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