Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Side by Side Diff: athena/home/home_card_impl.cc

Issue 311113005: AppModelBuilder to athena. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « athena/home/app_list_view_delegate.cc ('k') | athena/home/public/app_model_builder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/input/public/accelerator_manager.h" 9 #include "athena/input/public/accelerator_manager.h"
9 #include "athena/screen/public/screen_manager.h" 10 #include "athena/screen/public/screen_manager.h"
10 #include "ui/app_list/pagination_model.h" 11 #include "ui/app_list/pagination_model.h"
11 #include "ui/app_list/views/app_list_view.h" 12 #include "ui/app_list/views/app_list_view.h"
12 #include "ui/aura/layout_manager.h" 13 #include "ui/aura/layout_manager.h"
13 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
14 #include "ui/wm/core/visibility_controller.h" 15 #include "ui/wm/core/visibility_controller.h"
15 #include "ui/wm/core/window_animations.h" 16 #include "ui/wm/core/window_animations.h"
16 17
17 namespace athena { 18 namespace athena {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 SetChildBoundsDirect(home_card, card_bounds); 65 SetChildBoundsDirect(home_card, card_bounds);
65 } 66 }
66 67
67 aura::Window* container_; 68 aura::Window* container_;
68 69
69 DISALLOW_COPY_AND_ASSIGN(HomeCardLayoutManager); 70 DISALLOW_COPY_AND_ASSIGN(HomeCardLayoutManager);
70 }; 71 };
71 72
72 class HomeCardImpl : public HomeCard, public AcceleratorHandler { 73 class HomeCardImpl : public HomeCard, public AcceleratorHandler {
73 public: 74 public:
74 HomeCardImpl(); 75 explicit HomeCardImpl(AppModelBuilder* model_builder);
75 virtual ~HomeCardImpl(); 76 virtual ~HomeCardImpl();
76 77
77 void Init(); 78 void Init();
78 79
79 private: 80 private:
80 enum Command { 81 enum Command {
81 COMMAND_SHOW_HOME_CARD, 82 COMMAND_SHOW_HOME_CARD,
82 }; 83 };
83 void InstallAccelerators(); 84 void InstallAccelerators();
84 85
85 // AcceleratorHandler: 86 // AcceleratorHandler:
86 virtual bool IsCommandEnabled(int command_id) const OVERRIDE { return true; } 87 virtual bool IsCommandEnabled(int command_id) const OVERRIDE { return true; }
87 virtual bool OnAcceleratorFired(int command_id, 88 virtual bool OnAcceleratorFired(int command_id,
88 const ui::Accelerator& accelerator) OVERRIDE { 89 const ui::Accelerator& accelerator) OVERRIDE {
89 DCHECK_EQ(COMMAND_SHOW_HOME_CARD, command_id); 90 DCHECK_EQ(COMMAND_SHOW_HOME_CARD, command_id);
90 home_card_widget_->Show(); 91 home_card_widget_->Show();
91 return true; 92 return true;
92 } 93 }
93 94
95 scoped_ptr<AppModelBuilder> model_builder_;
96
94 views::Widget* home_card_widget_; 97 views::Widget* home_card_widget_;
95 98
96 DISALLOW_COPY_AND_ASSIGN(HomeCardImpl); 99 DISALLOW_COPY_AND_ASSIGN(HomeCardImpl);
97 }; 100 };
98 101
99 HomeCardImpl::HomeCardImpl() 102 HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder)
100 : home_card_widget_(NULL) { 103 : model_builder_(model_builder),
104 home_card_widget_(NULL) {
101 DCHECK(!instance); 105 DCHECK(!instance);
102 instance = this; 106 instance = this;
103 } 107 }
104 108
105 HomeCardImpl::~HomeCardImpl() { 109 HomeCardImpl::~HomeCardImpl() {
106 DCHECK(instance); 110 DCHECK(instance);
107 home_card_widget_->CloseNow(); 111 home_card_widget_->CloseNow();
108 instance = NULL; 112 instance = NULL;
109 } 113 }
110 114
111 void HomeCardImpl::Init() { 115 void HomeCardImpl::Init() {
112 InstallAccelerators(); 116 InstallAccelerators();
113 117
114 aura::Window* container = 118 aura::Window* container =
115 ScreenManager::Get()->CreateContainer("HomeCardContainer"); 119 ScreenManager::Get()->CreateContainer("HomeCardContainer");
116 container->SetLayoutManager(new HomeCardLayoutManager(container)); 120 container->SetLayoutManager(new HomeCardLayoutManager(container));
117 wm::SetChildWindowVisibilityChangesAnimated(container); 121 wm::SetChildWindowVisibilityChangesAnimated(container);
118 122
119 app_list::AppListView* view = new app_list::AppListView( 123 app_list::AppListView* view = new app_list::AppListView(
120 new AppListViewDelegate); 124 new AppListViewDelegate(model_builder_.get()));
121 view->InitAsBubbleAtFixedLocation( 125 view->InitAsBubbleAtFixedLocation(
122 container, 126 container,
123 0 /* initial_apps_page */, 127 0 /* initial_apps_page */,
124 gfx::Point(), 128 gfx::Point(),
125 views::BubbleBorder::FLOAT, 129 views::BubbleBorder::FLOAT,
126 true /* border_accepts_events */); 130 true /* border_accepts_events */);
127 home_card_widget_ = view->GetWidget(); 131 home_card_widget_ = view->GetWidget();
128 view->ShowWhenReady(); 132 view->ShowWhenReady();
129 } 133 }
130 134
131 void HomeCardImpl::InstallAccelerators() { 135 void HomeCardImpl::InstallAccelerators() {
132 const AcceleratorData accelerator_data[] = { 136 const AcceleratorData accelerator_data[] = {
133 {TRIGGER_ON_PRESS, ui::VKEY_L, ui::EF_CONTROL_DOWN, 137 {TRIGGER_ON_PRESS, ui::VKEY_L, ui::EF_CONTROL_DOWN,
134 COMMAND_SHOW_HOME_CARD, AF_NONE}, 138 COMMAND_SHOW_HOME_CARD, AF_NONE},
135 }; 139 };
136 AcceleratorManager::Get()->RegisterAccelerators( 140 AcceleratorManager::Get()->RegisterAccelerators(
137 accelerator_data, arraysize(accelerator_data), this); 141 accelerator_data, arraysize(accelerator_data), this);
138 } 142 }
139 143
140 } // namespace 144 } // namespace
141 145
142 // static 146 // static
143 HomeCard* HomeCard::Create() { 147 HomeCard* HomeCard::Create(AppModelBuilder* model_builder) {
144 (new HomeCardImpl())->Init(); 148 (new HomeCardImpl(model_builder))->Init();
145 DCHECK(instance); 149 DCHECK(instance);
146 return instance; 150 return instance;
147 } 151 }
148 152
149 // static 153 // static
150 void HomeCard::Shutdown() { 154 void HomeCard::Shutdown() {
151 DCHECK(instance); 155 DCHECK(instance);
152 delete instance; 156 delete instance;
153 instance = NULL; 157 instance = NULL;
154 } 158 }
155 159
156 } // namespace athena 160 } // namespace athena
OLDNEW
« no previous file with comments | « athena/home/app_list_view_delegate.cc ('k') | athena/home/public/app_model_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698