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/activity/public/activity_view.h" | |
8 #include "athena/content/app_activity_registry.h" | 9 #include "athena/content/app_activity_registry.h" |
9 #include "athena/content/content_proxy.h" | 10 #include "athena/content/content_proxy.h" |
10 #include "athena/content/media_utils.h" | 11 #include "athena/content/media_utils.h" |
11 #include "athena/content/public/app_registry.h" | 12 #include "athena/content/public/app_registry.h" |
12 #include "athena/wm/public/window_list_provider.h" | 13 #include "athena/wm/public/window_list_provider.h" |
13 #include "athena/wm/public/window_manager.h" | 14 #include "athena/wm/public/window_manager.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
16 #include "ui/views/controls/webview/webview.h" | 17 #include "ui/views/controls/webview/webview.h" |
17 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
18 #include "ui/wm/core/window_util.h" | 19 #include "ui/wm/core/window_util.h" |
19 | 20 |
20 namespace athena { | 21 namespace athena { |
21 | 22 |
22 // TODO(mukai): specifies the same accelerators of WebActivity. | 23 // TODO(mukai): specifies the same accelerators of WebActivity. |
23 AppActivity::AppActivity(const std::string& app_id, views::WebView* web_view) | 24 AppActivity::AppActivity(const std::string& app_id, views::WebView* web_view) |
24 : app_id_(app_id), | 25 : app_id_(app_id), |
25 web_view_(web_view), | 26 web_view_(web_view), |
26 current_state_(ACTIVITY_UNLOADED), | 27 current_state_(ACTIVITY_UNLOADED), |
27 app_activity_registry_(nullptr) { | 28 app_activity_registry_(nullptr), |
29 activity_view_(nullptr) { | |
28 Observe(web_view->GetWebContents()); | 30 Observe(web_view->GetWebContents()); |
29 } | 31 } |
30 | 32 |
31 scoped_ptr<ContentProxy> AppActivity::GetContentProxy() { | 33 scoped_ptr<ContentProxy> AppActivity::GetContentProxy() { |
32 // Note: After this call, the content is still valid because the contents | 34 // Note: After this call, the content is still valid because the contents |
33 // destruction will destroy this |AppActivity| object. | 35 // destruction will destroy this |AppActivity| object. |
34 if (content_proxy_.get()) | 36 if (content_proxy_.get()) |
35 content_proxy_->OnPreContentDestroyed(); | 37 content_proxy_->OnPreContentDestroyed(); |
36 return content_proxy_.Pass(); | 38 return content_proxy_.Pass(); |
37 } | 39 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 } | 161 } |
160 | 162 |
161 base::string16 AppActivity::GetTitle() const { | 163 base::string16 AppActivity::GetTitle() const { |
162 return web_view_->GetWebContents()->GetTitle(); | 164 return web_view_->GetWebContents()->GetTitle(); |
163 } | 165 } |
164 | 166 |
165 gfx::ImageSkia AppActivity::GetIcon() const { | 167 gfx::ImageSkia AppActivity::GetIcon() const { |
166 return gfx::ImageSkia(); | 168 return gfx::ImageSkia(); |
167 } | 169 } |
168 | 170 |
171 void AppActivity::SetActivityView(ActivityView* view) { | |
oshima
2014/11/04 22:17:04
DCHECK(!activitY_view_) ?
sadrul
2014/11/04 23:26:08
Done.
| |
172 activity_view_ = view; | |
173 } | |
174 | |
169 bool AppActivity::UsesFrame() const { | 175 bool AppActivity::UsesFrame() const { |
170 return false; | 176 return false; |
171 } | 177 } |
172 | 178 |
173 views::View* AppActivity::GetContentsView() { | 179 views::View* AppActivity::GetContentsView() { |
174 return web_view_; | 180 return web_view_; |
175 } | 181 } |
176 | 182 |
177 gfx::ImageSkia AppActivity::GetOverviewModeImage() { | 183 gfx::ImageSkia AppActivity::GetOverviewModeImage() { |
178 if (content_proxy_.get()) | 184 if (content_proxy_.get()) |
(...skipping 25 matching lines...) Expand all Loading... | |
204 } | 210 } |
205 | 211 |
206 AppActivity::~AppActivity() { | 212 AppActivity::~AppActivity() { |
207 // If this activity is registered, we unregister it now. | 213 // If this activity is registered, we unregister it now. |
208 if (app_activity_registry_) | 214 if (app_activity_registry_) |
209 app_activity_registry_->UnregisterAppActivity(this); | 215 app_activity_registry_->UnregisterAppActivity(this); |
210 } | 216 } |
211 | 217 |
212 void AppActivity::TitleWasSet(content::NavigationEntry* entry, | 218 void AppActivity::TitleWasSet(content::NavigationEntry* entry, |
213 bool explicit_set) { | 219 bool explicit_set) { |
214 ActivityManager::Get()->UpdateActivity(this); | 220 if (activity_view_) |
221 activity_view_->UpdateTitle(); | |
215 } | 222 } |
216 | 223 |
217 void AppActivity::DidUpdateFaviconURL( | 224 void AppActivity::DidUpdateFaviconURL( |
218 const std::vector<content::FaviconURL>& candidates) { | 225 const std::vector<content::FaviconURL>& candidates) { |
219 ActivityManager::Get()->UpdateActivity(this); | 226 if (activity_view_) |
227 activity_view_->UpdateIcon(); | |
220 } | 228 } |
221 | 229 |
222 // Register an |activity| with an application. | 230 // Register an |activity| with an application. |
223 // Note: This should only get called once for an |app_window| of the | 231 // Note: This should only get called once for an |app_window| of the |
224 // |activity|. | 232 // |activity|. |
225 void AppActivity::RegisterActivity() { | 233 void AppActivity::RegisterActivity() { |
226 content::WebContents* web_contents = web_view_->GetWebContents(); | 234 content::WebContents* web_contents = web_view_->GetWebContents(); |
227 AppRegistry* app_registry = AppRegistry::Get(); | 235 AppRegistry* app_registry = AppRegistry::Get(); |
228 // Get the application's registry. | 236 // Get the application's registry. |
229 app_activity_registry_ = app_registry->GetAppActivityRegistry( | 237 app_activity_registry_ = app_registry->GetAppActivityRegistry( |
230 app_id_, web_contents->GetBrowserContext()); | 238 app_id_, web_contents->GetBrowserContext()); |
231 DCHECK(app_activity_registry_); | 239 DCHECK(app_activity_registry_); |
232 // Register the activity. | 240 // Register the activity. |
233 app_activity_registry_->RegisterAppActivity(this); | 241 app_activity_registry_->RegisterAppActivity(this); |
234 } | 242 } |
235 | 243 |
236 void AppActivity::HideContentProxy() { | 244 void AppActivity::HideContentProxy() { |
237 content_proxy_.reset(); | 245 content_proxy_.reset(); |
238 } | 246 } |
239 | 247 |
240 void AppActivity::ShowContentProxy() { | 248 void AppActivity::ShowContentProxy() { |
241 if (!content_proxy_.get() && web_view_) | 249 if (!content_proxy_.get() && web_view_) |
242 content_proxy_.reset(new ContentProxy(web_view_)); | 250 content_proxy_.reset(new ContentProxy(web_view_)); |
243 } | 251 } |
244 | 252 |
245 } // namespace athena | 253 } // namespace athena |
OLD | NEW |