| 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/home/public/home_card.h" | 5 #include "athena/home/public/home_card.h" |
| 6 | 6 |
| 7 #include "athena/home/app_list_view_delegate.h" | 7 #include "athena/home/app_list_view_delegate.h" |
| 8 #include "athena/home/public/app_model_builder.h" |
| 8 #include "athena/screen/public/screen_manager.h" | 9 #include "athena/screen/public/screen_manager.h" |
| 9 #include "ui/app_list/pagination_model.h" | 10 #include "ui/app_list/pagination_model.h" |
| 10 #include "ui/app_list/views/app_list_view.h" | 11 #include "ui/app_list/views/app_list_view.h" |
| 11 #include "ui/aura/layout_manager.h" | 12 #include "ui/aura/layout_manager.h" |
| 12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 13 #include "ui/wm/core/visibility_controller.h" | 14 #include "ui/wm/core/visibility_controller.h" |
| 14 #include "ui/wm/core/window_animations.h" | 15 #include "ui/wm/core/window_animations.h" |
| 15 | 16 |
| 16 namespace athena { | 17 namespace athena { |
| 17 namespace { | 18 namespace { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 SetChildBoundsDirect(home_card, card_bounds); | 64 SetChildBoundsDirect(home_card, card_bounds); |
| 64 } | 65 } |
| 65 | 66 |
| 66 aura::Window* container_; | 67 aura::Window* container_; |
| 67 | 68 |
| 68 DISALLOW_COPY_AND_ASSIGN(HomeCardLayoutManager); | 69 DISALLOW_COPY_AND_ASSIGN(HomeCardLayoutManager); |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 class HomeCardImpl : public HomeCard { | 72 class HomeCardImpl : public HomeCard { |
| 72 public: | 73 public: |
| 73 HomeCardImpl(); | 74 HomeCardImpl(AppModelBuilder* model_builder); |
| 74 virtual ~HomeCardImpl(); | 75 virtual ~HomeCardImpl(); |
| 75 | 76 |
| 76 void Init(); | 77 void Init(); |
| 77 | 78 |
| 78 private: | 79 private: |
| 80 scoped_ptr<AppModelBuilder> model_builder_; |
| 81 |
| 79 views::Widget* home_card_widget_; | 82 views::Widget* home_card_widget_; |
| 80 | 83 |
| 81 DISALLOW_COPY_AND_ASSIGN(HomeCardImpl); | 84 DISALLOW_COPY_AND_ASSIGN(HomeCardImpl); |
| 82 }; | 85 }; |
| 83 | 86 |
| 84 HomeCardImpl::HomeCardImpl() | 87 HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder) |
| 85 : home_card_widget_(NULL) { | 88 : model_builder_(model_builder), |
| 89 home_card_widget_(NULL) { |
| 86 DCHECK(!instance); | 90 DCHECK(!instance); |
| 87 instance = this; | 91 instance = this; |
| 88 } | 92 } |
| 89 | 93 |
| 90 HomeCardImpl::~HomeCardImpl() { | 94 HomeCardImpl::~HomeCardImpl() { |
| 91 DCHECK(instance); | 95 DCHECK(instance); |
| 92 home_card_widget_->CloseNow(); | 96 home_card_widget_->CloseNow(); |
| 93 instance = NULL; | 97 instance = NULL; |
| 94 } | 98 } |
| 95 | 99 |
| 96 void HomeCardImpl::Init() { | 100 void HomeCardImpl::Init() { |
| 97 aura::Window* container = | 101 aura::Window* container = |
| 98 ScreenManager::Get()->CreateContainer("HomeCardContainer"); | 102 ScreenManager::Get()->CreateContainer("HomeCardContainer"); |
| 99 container->SetLayoutManager(new HomeCardLayoutManager(container)); | 103 container->SetLayoutManager(new HomeCardLayoutManager(container)); |
| 100 wm::SetChildWindowVisibilityChangesAnimated(container); | 104 wm::SetChildWindowVisibilityChangesAnimated(container); |
| 101 | 105 |
| 102 app_list::AppListView* view = new app_list::AppListView( | 106 app_list::AppListView* view = new app_list::AppListView( |
| 103 new AppListViewDelegate); | 107 new AppListViewDelegate(model_builder_.get())); |
| 104 view->InitAsBubbleAtFixedLocation( | 108 view->InitAsBubbleAtFixedLocation( |
| 105 container, | 109 container, |
| 106 0 /* initial_apps_page */, | 110 0 /* initial_apps_page */, |
| 107 gfx::Point(), | 111 gfx::Point(), |
| 108 views::BubbleBorder::FLOAT, | 112 views::BubbleBorder::FLOAT, |
| 109 true /* border_accepts_events */); | 113 true /* border_accepts_events */); |
| 110 home_card_widget_ = view->GetWidget(); | 114 home_card_widget_ = view->GetWidget(); |
| 111 view->ShowWhenReady(); | 115 view->ShowWhenReady(); |
| 112 } | 116 } |
| 113 | 117 |
| 114 } // namespace | 118 } // namespace |
| 115 | 119 |
| 116 // static | 120 // static |
| 117 HomeCard* HomeCard::Create() { | 121 HomeCard* HomeCard::Create(AppModelBuilder* model_builder) { |
| 118 (new HomeCardImpl())->Init(); | 122 (new HomeCardImpl(model_builder))->Init(); |
| 119 DCHECK(instance); | 123 DCHECK(instance); |
| 120 return instance; | 124 return instance; |
| 121 } | 125 } |
| 122 | 126 |
| 123 // static | 127 // static |
| 124 void HomeCard::Shutdown() { | 128 void HomeCard::Shutdown() { |
| 125 DCHECK(instance); | 129 DCHECK(instance); |
| 126 delete instance; | 130 delete instance; |
| 127 instance = NULL; | 131 instance = NULL; |
| 128 } | 132 } |
| 129 | 133 |
| 130 } // namespace athena | 134 } // namespace athena |
| OLD | NEW |