OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "athena/content/app_activity_proxy.h" | |
6 | |
7 #include "athena/content/app_activity.h" | |
8 #include "athena/content/app_activity_registry.h" | |
9 #include "athena/wm/public/window_list_provider.h" | |
10 #include "athena/wm/public/window_manager.h" | |
11 #include "ui/aura/window.h" | |
12 #include "ui/views/view.h" | |
13 #include "ui/views/widget/widget.h" | |
14 | |
15 namespace athena { | |
16 | |
17 AppActivityProxy::AppActivityProxy(AppActivity* replaced_activity, | |
18 AppActivityRegistry* creator) : | |
19 app_activity_registry_(creator), | |
20 title_(replaced_activity->GetActivityViewModel()->GetTitle()), | |
21 color_(replaced_activity->GetActivityViewModel()->GetRepresentativeColor()), | |
22 replaced_activity_(replaced_activity), | |
23 view_(new views::View()), | |
24 restart_called_(false) { | |
25 } | |
26 | |
27 ActivityViewModel* AppActivityProxy::GetActivityViewModel() { | |
28 return this; | |
29 } | |
30 | |
31 void AppActivityProxy::SetCurrentState(ActivityState state) { | |
32 // We only restart the application when we are switching to visible, and only | |
33 // once. | |
34 if (state != ACTIVITY_VISIBLE || restart_called_) | |
35 return; | |
36 restart_called_ = true; | |
37 app_activity_registry_->RestartApplication(this); | |
38 // Note: This object is now destroyed. | |
39 } | |
40 | |
41 Activity::ActivityState AppActivityProxy::GetCurrentState() { | |
42 return ACTIVITY_UNLOADED; | |
43 } | |
44 | |
45 bool AppActivityProxy::IsVisible() { | |
46 return false; | |
47 } | |
48 | |
49 Activity::ActivityMediaState AppActivityProxy::GetMediaState() { | |
50 // This proxy has never any media playing. | |
51 return ACTIVITY_MEDIA_STATE_NONE; | |
52 } | |
53 | |
54 aura::Window* AppActivityProxy::GetWindow() { | |
55 return view_->GetWidget() ? view_->GetWidget()->GetNativeWindow() : nullptr; | |
56 } | |
57 | |
58 content::WebContents* AppActivityProxy::GetWebContents() { | |
59 return nullptr; | |
60 } | |
61 | |
62 void AppActivityProxy::Init() { | |
63 DCHECK(replaced_activity_); | |
64 // Get the content proxy to present the content. | |
65 content_proxy_ = replaced_activity_->GetContentProxy(); | |
66 WindowListProvider* window_list_provider = | |
67 WindowManager::Get()->GetWindowListProvider(); | |
68 window_list_provider->StackWindowBehindTo(GetWindow(), | |
69 replaced_activity_->GetWindow()); | |
70 // After the Init() function returns, the passed |replaced_activity_| might | |
71 // get destroyed. Since we do not need it anymore we reset it. | |
72 replaced_activity_ = nullptr; | |
73 } | |
74 | |
75 SkColor AppActivityProxy::GetRepresentativeColor() const { | |
76 return color_; | |
77 } | |
78 | |
79 base::string16 AppActivityProxy::GetTitle() const { | |
80 return title_; | |
81 } | |
82 | |
83 gfx::ImageSkia AppActivityProxy::GetIcon() const { | |
84 return gfx::ImageSkia(); | |
85 } | |
86 | |
87 void AppActivityProxy::SetActivityView(ActivityView* view) { | |
88 } | |
89 | |
90 bool AppActivityProxy::UsesFrame() const { | |
91 return true; | |
92 } | |
93 | |
94 views::View* AppActivityProxy::GetContentsView() { | |
95 return view_; | |
96 } | |
97 | |
98 gfx::ImageSkia AppActivityProxy::GetOverviewModeImage() { | |
99 return content_proxy_->GetContentImage(); | |
100 } | |
101 | |
102 void AppActivityProxy::PrepareContentsForOverview() { | |
103 } | |
104 | |
105 void AppActivityProxy::ResetContentsView() { | |
106 } | |
107 | |
108 AppActivityProxy::~AppActivityProxy() { | |
109 app_activity_registry_->ProxyDestroyed(this); | |
110 } | |
111 | |
112 } // namespace athena | |
OLD | NEW |