| 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_proxy.h" | 5 #include "athena/content/app_activity_proxy.h" |
| 6 | 6 |
| 7 #include "athena/content/app_activity.h" |
| 7 #include "athena/content/app_activity_registry.h" | 8 #include "athena/content/app_activity_registry.h" |
| 8 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 9 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
| 10 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 11 | 12 |
| 12 namespace athena { | 13 namespace athena { |
| 13 | 14 |
| 14 AppActivityProxy::AppActivityProxy(Activity* replaced_activity, | 15 AppActivityProxy::AppActivityProxy(AppActivity* replaced_activity, |
| 15 AppActivityRegistry* creator) : | 16 AppActivityRegistry* creator) : |
| 16 app_activity_registry_(creator), | 17 app_activity_registry_(creator), |
| 17 title_(replaced_activity->GetActivityViewModel()->GetTitle()), | 18 title_(replaced_activity->GetActivityViewModel()->GetTitle()), |
| 18 image_(replaced_activity->GetActivityViewModel()->GetOverviewModeImage()), | |
| 19 color_(replaced_activity->GetActivityViewModel()->GetRepresentativeColor()), | 19 color_(replaced_activity->GetActivityViewModel()->GetRepresentativeColor()), |
| 20 replaced_activity_(replaced_activity), | 20 replaced_activity_(replaced_activity), |
| 21 // TODO(skuhne): We probably need to do something better with the view | |
| 22 // (e.g. showing the passed image / layer). | |
| 23 view_(new views::View()) { | 21 view_(new views::View()) { |
| 24 } | 22 } |
| 25 | 23 |
| 26 AppActivityProxy::~AppActivityProxy() { | 24 AppActivityProxy::~AppActivityProxy() { |
| 27 app_activity_registry_->ProxyDestroyed(this); | 25 app_activity_registry_->ProxyDestroyed(this); |
| 28 } | 26 } |
| 29 | 27 |
| 30 ActivityViewModel* AppActivityProxy::GetActivityViewModel() { | 28 ActivityViewModel* AppActivityProxy::GetActivityViewModel() { |
| 31 return this; | 29 return this; |
| 32 } | 30 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 55 aura::Window* AppActivityProxy::GetWindow() { | 53 aura::Window* AppActivityProxy::GetWindow() { |
| 56 return view_->GetWidget()->GetNativeWindow(); | 54 return view_->GetWidget()->GetNativeWindow(); |
| 57 } | 55 } |
| 58 | 56 |
| 59 void AppActivityProxy::Init() { | 57 void AppActivityProxy::Init() { |
| 60 DCHECK(replaced_activity_); | 58 DCHECK(replaced_activity_); |
| 61 // TODO(skuhne): This should call the WindowListProvider to re-arrange. | 59 // TODO(skuhne): This should call the WindowListProvider to re-arrange. |
| 62 // At this point we can move the Activity to its proper Activity location. | 60 // At this point we can move the Activity to its proper Activity location. |
| 63 aura::Window* relative_window = replaced_activity_->GetWindow(); | 61 aura::Window* relative_window = replaced_activity_->GetWindow(); |
| 64 relative_window->parent()->StackChildBelow(GetWindow(), relative_window); | 62 relative_window->parent()->StackChildBelow(GetWindow(), relative_window); |
| 65 // We moved. | 63 // Get the content proxy to present the content. |
| 64 content_proxy_ = replaced_activity_->GetContentProxy(GetWindow()); |
| 65 // After the Init() function returns, the passed |replaced_activity_| might |
| 66 // get destroyed. Since we do not need it anymore we reset it. |
| 66 replaced_activity_ = NULL; | 67 replaced_activity_ = NULL; |
| 67 } | 68 } |
| 68 | 69 |
| 69 SkColor AppActivityProxy::GetRepresentativeColor() const { | 70 SkColor AppActivityProxy::GetRepresentativeColor() const { |
| 70 return color_; | 71 return color_; |
| 71 } | 72 } |
| 72 | 73 |
| 73 base::string16 AppActivityProxy::GetTitle() const { | 74 base::string16 AppActivityProxy::GetTitle() const { |
| 74 return title_; | 75 return title_; |
| 75 } | 76 } |
| 76 | 77 |
| 77 bool AppActivityProxy::UsesFrame() const { | 78 bool AppActivityProxy::UsesFrame() const { |
| 78 return true; | 79 return true; |
| 79 } | 80 } |
| 80 | 81 |
| 81 views::View* AppActivityProxy::GetContentsView() { | 82 views::View* AppActivityProxy::GetContentsView() { |
| 82 return view_; | 83 return view_; |
| 83 } | 84 } |
| 84 | 85 |
| 85 void AppActivityProxy::CreateOverviewModeImage() { | |
| 86 // Nothing we can do here. | |
| 87 } | |
| 88 | |
| 89 gfx::ImageSkia AppActivityProxy::GetOverviewModeImage() { | 86 gfx::ImageSkia AppActivityProxy::GetOverviewModeImage() { |
| 90 return image_; | 87 return content_proxy_->GetContentImage(); |
| 91 } | 88 } |
| 92 | 89 |
| 93 void AppActivityProxy::PrepareContentsForOverview() { | 90 void AppActivityProxy::PrepareContentsForOverview() { |
| 94 } | 91 } |
| 95 | 92 |
| 96 void AppActivityProxy::ResetContentsView() { | 93 void AppActivityProxy::ResetContentsView() { |
| 97 } | 94 } |
| 98 | 95 |
| 99 } // namespace athena | 96 } // namespace athena |
| OLD | NEW |