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/content_proxy.h" | 9 #include "athena/content/content_proxy.h" |
10 #include "athena/content/media_utils.h" | 10 #include "athena/content/media_utils.h" |
11 #include "athena/content/public/app_registry.h" | 11 #include "athena/content/public/app_registry.h" |
12 #include "athena/wm/public/window_list_provider.h" | 12 #include "athena/wm/public/window_list_provider.h" |
13 #include "athena/wm/public/window_manager.h" | 13 #include "athena/wm/public/window_manager.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
16 #include "ui/views/controls/webview/webview.h" | 16 #include "ui/views/controls/webview/webview.h" |
17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
18 #include "ui/wm/core/window_util.h" | 18 #include "ui/wm/core/window_util.h" |
19 | 19 |
20 namespace athena { | 20 namespace athena { |
21 | 21 |
22 // TODO(mukai): specifies the same accelerators of WebActivity. | 22 // TODO(mukai): specifies the same accelerators of WebActivity. |
23 AppActivity::AppActivity(const std::string& app_id, | 23 AppActivity::AppActivity(const std::string& app_id, views::WebView* web_view) |
24 views::WebView* web_view) | |
25 : app_id_(app_id), | 24 : app_id_(app_id), |
26 web_view_(web_view), | 25 web_view_(web_view), |
27 current_state_(ACTIVITY_UNLOADED), | 26 current_state_(ACTIVITY_UNLOADED), |
28 app_activity_registry_(NULL) { | 27 app_activity_registry_(nullptr) { |
29 Observe(web_view->GetWebContents()); | 28 Observe(web_view->GetWebContents()); |
30 } | 29 } |
31 | 30 |
32 scoped_ptr<ContentProxy> AppActivity::GetContentProxy() { | 31 scoped_ptr<ContentProxy> AppActivity::GetContentProxy() { |
33 // Note: After this call, the content is still valid because the contents | 32 // Note: After this call, the content is still valid because the contents |
34 // destruction will destroy this |AppActivity| object. | 33 // destruction will destroy this |AppActivity| object. |
35 if (content_proxy_.get()) | 34 if (content_proxy_.get()) |
36 content_proxy_->OnPreContentDestroyed(); | 35 content_proxy_->OnPreContentDestroyed(); |
37 return content_proxy_.Pass(); | 36 return content_proxy_.Pass(); |
38 } | 37 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 current_state_ != ACTIVITY_UNLOADED; | 86 current_state_ != ACTIVITY_UNLOADED; |
88 } | 87 } |
89 | 88 |
90 Activity::ActivityMediaState AppActivity::GetMediaState() { | 89 Activity::ActivityMediaState AppActivity::GetMediaState() { |
91 return current_state_ == ACTIVITY_UNLOADED ? | 90 return current_state_ == ACTIVITY_UNLOADED ? |
92 Activity::ACTIVITY_MEDIA_STATE_NONE : | 91 Activity::ACTIVITY_MEDIA_STATE_NONE : |
93 GetActivityMediaState(GetWebContents()); | 92 GetActivityMediaState(GetWebContents()); |
94 } | 93 } |
95 | 94 |
96 aura::Window* AppActivity::GetWindow() { | 95 aura::Window* AppActivity::GetWindow() { |
97 return !web_view_ ? NULL : web_view_->GetWidget()->GetNativeWindow(); | 96 return !web_view_ ? nullptr : web_view_->GetWidget()->GetNativeWindow(); |
98 } | 97 } |
99 | 98 |
100 content::WebContents* AppActivity::GetWebContents() { | 99 content::WebContents* AppActivity::GetWebContents() { |
101 return !web_view_ ? NULL : web_view_->GetWebContents(); | 100 return !web_view_ ? nullptr : web_view_->GetWebContents(); |
102 } | 101 } |
103 | 102 |
104 void AppActivity::Init() { | 103 void AppActivity::Init() { |
105 DCHECK(app_activity_registry_); | 104 DCHECK(app_activity_registry_); |
106 Activity* app_proxy = app_activity_registry_->unloaded_activity_proxy(); | 105 Activity* app_proxy = app_activity_registry_->unloaded_activity_proxy(); |
107 if (app_proxy) { | 106 if (app_proxy) { |
108 // Note: At this time the |AppActivity| did not get registered to the | 107 // Note: At this time the |AppActivity| did not get registered to the |
109 // |ResourceManager| - so we can move it around if needed. | 108 // |ResourceManager| - so we can move it around if needed. |
110 WindowListProvider* window_list_provider = | 109 WindowListProvider* window_list_provider = |
111 WindowManager::Get()->GetWindowListProvider(); | 110 WindowManager::Get()->GetWindowListProvider(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 // Turn on fast resizing to avoid re-laying out the web contents when | 190 // Turn on fast resizing to avoid re-laying out the web contents when |
192 // entering / exiting overview mode and the content is visible. | 191 // entering / exiting overview mode and the content is visible. |
193 if (!content_proxy_.get()) { | 192 if (!content_proxy_.get()) { |
194 web_view_->SetFastResize(false); | 193 web_view_->SetFastResize(false); |
195 web_view_->Layout(); | 194 web_view_->Layout(); |
196 } | 195 } |
197 } | 196 } |
198 | 197 |
199 AppActivity::AppActivity(const std::string& app_id) | 198 AppActivity::AppActivity(const std::string& app_id) |
200 : app_id_(app_id), | 199 : app_id_(app_id), |
201 web_view_(NULL), | 200 web_view_(nullptr), |
202 current_state_(ACTIVITY_UNLOADED), | 201 current_state_(ACTIVITY_UNLOADED), |
203 app_activity_registry_(NULL) { | 202 app_activity_registry_(nullptr) { |
204 } | 203 } |
205 | 204 |
206 AppActivity::~AppActivity() { | 205 AppActivity::~AppActivity() { |
207 // If this activity is registered, we unregister it now. | 206 // If this activity is registered, we unregister it now. |
208 if (app_activity_registry_) | 207 if (app_activity_registry_) |
209 app_activity_registry_->UnregisterAppActivity(this); | 208 app_activity_registry_->UnregisterAppActivity(this); |
210 } | 209 } |
211 | 210 |
212 void AppActivity::TitleWasSet(content::NavigationEntry* entry, | 211 void AppActivity::TitleWasSet(content::NavigationEntry* entry, |
213 bool explicit_set) { | 212 bool explicit_set) { |
(...skipping 22 matching lines...) Expand all Loading... |
236 void AppActivity::HideContentProxy() { | 235 void AppActivity::HideContentProxy() { |
237 content_proxy_.reset(); | 236 content_proxy_.reset(); |
238 } | 237 } |
239 | 238 |
240 void AppActivity::ShowContentProxy() { | 239 void AppActivity::ShowContentProxy() { |
241 if (!content_proxy_.get() && web_view_) | 240 if (!content_proxy_.get() && web_view_) |
242 content_proxy_.reset(new ContentProxy(web_view_)); | 241 content_proxy_.reset(new ContentProxy(web_view_)); |
243 } | 242 } |
244 | 243 |
245 } // namespace athena | 244 } // namespace athena |
OLD | NEW |