Chromium Code Reviews| 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 <limits> | |
| 8 | |
| 7 #include "athena/home/app_list_view_delegate.h" | 9 #include "athena/home/app_list_view_delegate.h" |
| 10 #include "athena/home/bottom_home_view.h" | |
| 8 #include "athena/home/minimized_home.h" | 11 #include "athena/home/minimized_home.h" |
| 9 #include "athena/home/public/app_model_builder.h" | 12 #include "athena/home/public/app_model_builder.h" |
| 10 #include "athena/input/public/accelerator_manager.h" | 13 #include "athena/input/public/accelerator_manager.h" |
| 11 #include "athena/screen/public/screen_manager.h" | 14 #include "athena/screen/public/screen_manager.h" |
| 12 #include "athena/wm/public/window_manager.h" | 15 #include "athena/wm/public/window_manager.h" |
| 13 #include "athena/wm/public/window_manager_observer.h" | 16 #include "athena/wm/public/window_manager_observer.h" |
| 14 #include "base/bind.h" | 17 #include "base/bind.h" |
| 18 #include "base/command_line.h" | |
| 19 #include "ui/app_list/app_list_switches.h" | |
| 15 #include "ui/app_list/search_provider.h" | 20 #include "ui/app_list/search_provider.h" |
| 16 #include "ui/app_list/views/app_list_view.h" | 21 #include "ui/app_list/views/app_list_main_view.h" |
| 22 #include "ui/app_list/views/contents_view.h" | |
| 17 #include "ui/aura/layout_manager.h" | 23 #include "ui/aura/layout_manager.h" |
| 18 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 25 #include "ui/views/background.h" | |
| 19 #include "ui/views/layout/box_layout.h" | 26 #include "ui/views/layout/box_layout.h" |
| 27 #include "ui/views/widget/widget.h" | |
| 28 #include "ui/views/widget/widget_delegate.h" | |
| 20 #include "ui/wm/core/visibility_controller.h" | 29 #include "ui/wm/core/visibility_controller.h" |
| 21 #include "ui/wm/core/window_animations.h" | 30 #include "ui/wm/core/window_animations.h" |
| 22 | 31 |
| 23 namespace athena { | 32 namespace athena { |
| 24 namespace { | 33 namespace { |
| 25 | 34 |
| 26 HomeCard* instance = NULL; | 35 HomeCard* instance = NULL; |
| 27 | 36 |
| 28 // Makes sure the homecard is center-aligned horizontally and bottom-aligned | 37 // Makes sure the homecard is center-aligned horizontally and bottom-aligned |
| 29 // vertically. | 38 // vertically. |
| 30 class HomeCardLayoutManager : public aura::LayoutManager { | 39 class HomeCardLayoutManager : public aura::LayoutManager { |
| 31 public: | 40 public: |
| 32 class Delegate { | 41 class Delegate { |
| 33 public: | 42 public: |
| 34 virtual ~Delegate() {} | 43 virtual ~Delegate() {} |
| 35 | 44 |
| 36 virtual int GetHomeCardHeight() const = 0; | 45 virtual int GetHomeCardHeight() const = 0; |
| 37 | 46 |
| 38 virtual int GetHorizontalMargin() const = 0; | 47 virtual int GetHorizontalMargin() const = 0; |
| 39 | 48 |
| 40 // TODO(mukai): Remove this when bubble is no longer used for | |
| 41 // VISIBLE_CENTERED or VISIBLE_BOTTOM states. | |
| 42 virtual bool HasShadow() const = 0; | |
| 43 | |
| 44 virtual aura::Window* GetNativeWindow() = 0; | 49 virtual aura::Window* GetNativeWindow() = 0; |
| 45 }; | 50 }; |
| 46 | 51 |
| 47 explicit HomeCardLayoutManager(Delegate* delegate) | 52 explicit HomeCardLayoutManager(Delegate* delegate) |
| 48 : delegate_(delegate) {} | 53 : delegate_(delegate) {} |
| 54 | |
| 49 virtual ~HomeCardLayoutManager() {} | 55 virtual ~HomeCardLayoutManager() {} |
| 50 | 56 |
| 51 void UpdateVirtualKeyboardBounds(const gfx::Rect& bounds) { | 57 void Layout() { |
| 52 virtual_keyboard_bounds_ = bounds; | 58 aura::Window* home_card = delegate_->GetNativeWindow(); |
| 53 Layout(); | 59 // |home_card| could be detached from the root window (e.g. when it is being |
| 60 // destroyed). | |
| 61 if (!home_card || !home_card->GetRootWindow()) | |
| 62 return; | |
| 63 | |
| 64 int height = delegate_->GetHomeCardHeight(); | |
| 65 int horiz_margin = delegate_->GetHorizontalMargin(); | |
| 66 gfx::Rect screen_bounds = home_card->GetRootWindow()->bounds(); | |
| 67 height = std::min(height, screen_bounds.height()); | |
| 68 gfx::Rect card_bounds = screen_bounds; | |
| 69 card_bounds.Inset(horiz_margin, screen_bounds.height() - height, | |
| 70 horiz_margin, 0); | |
| 71 | |
| 72 SetChildBoundsDirect(home_card, card_bounds); | |
| 54 } | 73 } |
| 55 | 74 |
| 56 private: | 75 private: |
| 57 // aura::LayoutManager: | 76 // aura::LayoutManager: |
| 58 virtual void OnWindowResized() OVERRIDE { Layout(); } | 77 virtual void OnWindowResized() OVERRIDE { Layout(); } |
| 59 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE { Layout(); } | 78 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE { Layout(); } |
| 60 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {} | 79 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {} |
| 61 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE { | 80 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE { |
| 62 Layout(); | 81 Layout(); |
| 63 } | 82 } |
| 64 virtual void OnChildWindowVisibilityChanged(aura::Window* child, | 83 virtual void OnChildWindowVisibilityChanged(aura::Window* child, |
| 65 bool visible) OVERRIDE { | 84 bool visible) OVERRIDE { |
| 66 Layout(); | 85 Layout(); |
| 67 } | 86 } |
| 68 virtual void SetChildBounds(aura::Window* child, | 87 virtual void SetChildBounds(aura::Window* child, |
| 69 const gfx::Rect& requested_bounds) OVERRIDE { | 88 const gfx::Rect& requested_bounds) OVERRIDE { |
| 70 SetChildBoundsDirect(child, gfx::Rect(requested_bounds.size())); | 89 SetChildBoundsDirect(child, gfx::Rect(requested_bounds.size())); |
| 71 } | 90 } |
| 72 | 91 |
| 73 void Layout() { | |
| 74 int height = delegate_->GetHomeCardHeight(); | |
| 75 int horiz_margin = delegate_->GetHorizontalMargin(); | |
| 76 aura::Window* home_card = delegate_->GetNativeWindow(); | |
| 77 // |home_card| could be detached from the root window (e.g. when it is being | |
| 78 // destroyed). | |
| 79 if (!home_card || !home_card->GetRootWindow()) | |
| 80 return; | |
| 81 | |
| 82 gfx::Rect screen_bounds = home_card->GetRootWindow()->bounds(); | |
| 83 if (!virtual_keyboard_bounds_.IsEmpty()) | |
| 84 screen_bounds.set_height(virtual_keyboard_bounds_.y()); | |
| 85 gfx::Rect card_bounds = screen_bounds; | |
| 86 card_bounds.Inset(horiz_margin, screen_bounds.height() - height, | |
| 87 horiz_margin, 0); | |
| 88 | |
| 89 if (delegate_->HasShadow()) { | |
| 90 // Currently the home card is provided as a bubble and the bounds has to | |
| 91 // be increased to cancel the shadow. | |
| 92 // TODO(mukai): stops using the bubble and remove this. | |
| 93 const int kHomeCardShadowWidth = 30; | |
| 94 card_bounds.Inset(-kHomeCardShadowWidth, -kHomeCardShadowWidth); | |
| 95 } | |
| 96 SetChildBoundsDirect(home_card, card_bounds); | |
| 97 } | |
| 98 | |
| 99 Delegate* delegate_; | 92 Delegate* delegate_; |
| 100 gfx::Rect virtual_keyboard_bounds_; | |
| 101 | 93 |
| 102 DISALLOW_COPY_AND_ASSIGN(HomeCardLayoutManager); | 94 DISALLOW_COPY_AND_ASSIGN(HomeCardLayoutManager); |
| 103 }; | 95 }; |
| 104 | 96 |
| 97 // The container view of home card contents of each state. | |
| 98 class HomeCardView : public views::WidgetDelegateView { | |
| 99 public: | |
| 100 HomeCardView(app_list::AppListViewDelegate* view_delegate, | |
| 101 aura::Window* container, | |
| 102 MinimizedHomeDragDelegate* minimized_delegate) { | |
| 103 set_background(views::Background::CreateSolidBackground(SK_ColorWHITE)); | |
| 104 views::BoxLayout* layout = new views::BoxLayout( | |
| 105 views::BoxLayout::kHorizontal, 0, 0, 0); | |
| 106 layout->set_main_axis_alignment( | |
| 107 views::BoxLayout::MAIN_AXIS_ALIGNMENT_FILL); | |
| 108 layout->set_cross_axis_alignment( | |
| 109 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); | |
| 110 SetLayoutManager(layout); | |
| 111 | |
| 112 bottom_view_ = new BottomHomeView(view_delegate); | |
| 113 AddChildView(bottom_view_); | |
| 114 | |
| 115 main_view_ = new app_list::AppListMainView( | |
| 116 view_delegate, 0 /* initial_apps_page */, container); | |
| 117 AddChildView(main_view_); | |
| 118 | |
| 119 minimized_view_ = CreateMinimizedHome(minimized_delegate); | |
| 120 AddChildView(minimized_view_); | |
| 121 } | |
| 122 | |
| 123 void SetState(HomeCard::State state) { | |
| 124 bottom_view_->SetVisible(state == HomeCard::VISIBLE_BOTTOM); | |
| 125 main_view_->SetVisible(state == HomeCard::VISIBLE_CENTERED); | |
| 126 minimized_view_->SetVisible(state == HomeCard::VISIBLE_MINIMIZED); | |
| 127 if (state == HomeCard::VISIBLE_CENTERED) { | |
| 128 app_list::ContentsView* contents_view = main_view_->contents_view(); | |
| 129 contents_view->SetActivePage(contents_view->GetPageIndexForNamedPage( | |
| 130 app_list::ContentsView::NAMED_PAGE_START)); | |
| 131 } | |
| 132 Layout(); | |
|
sadrul
2014/07/18 15:32:36
Does this call to Layout() make sure the widget is
Jun Mukai
2014/07/18 20:27:40
Right, and it seems this is not necessary. Moved
| |
| 133 } | |
| 134 | |
| 135 private: | |
| 136 // views::WidgetDelegate: | |
| 137 virtual views::View* GetContentsView() OVERRIDE { | |
| 138 return this; | |
| 139 } | |
| 140 | |
| 141 app_list::AppListMainView* main_view_; | |
| 142 BottomHomeView* bottom_view_; | |
| 143 views::View* minimized_view_; | |
| 144 | |
| 145 DISALLOW_COPY_AND_ASSIGN(HomeCardView); | |
| 146 }; | |
| 147 | |
| 105 class HomeCardImpl : public HomeCard, | 148 class HomeCardImpl : public HomeCard, |
| 106 public AcceleratorHandler, | 149 public AcceleratorHandler, |
| 107 public HomeCardLayoutManager::Delegate, | 150 public HomeCardLayoutManager::Delegate, |
| 108 public MinimizedHomeDragDelegate, | 151 public MinimizedHomeDragDelegate, |
| 109 public WindowManagerObserver { | 152 public WindowManagerObserver { |
| 110 public: | 153 public: |
| 111 explicit HomeCardImpl(AppModelBuilder* model_builder); | 154 explicit HomeCardImpl(AppModelBuilder* model_builder); |
| 112 virtual ~HomeCardImpl(); | 155 virtual ~HomeCardImpl(); |
| 113 | 156 |
| 114 void Init(); | 157 void Init(); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 135 SetState(VISIBLE_CENTERED); | 178 SetState(VISIBLE_CENTERED); |
| 136 else | 179 else |
| 137 SetState(HIDDEN); | 180 SetState(HIDDEN); |
| 138 return true; | 181 return true; |
| 139 } | 182 } |
| 140 | 183 |
| 141 // HomeCardLayoutManager::Delegate: | 184 // HomeCardLayoutManager::Delegate: |
| 142 virtual int GetHomeCardHeight() const OVERRIDE { | 185 virtual int GetHomeCardHeight() const OVERRIDE { |
| 143 const int kHomeCardHeight = 150; | 186 const int kHomeCardHeight = 150; |
| 144 const int kHomeCardMinimizedHeight = 8; | 187 const int kHomeCardMinimizedHeight = 8; |
| 145 CHECK_NE(HIDDEN, state_); | 188 |
| 146 return state_ == VISIBLE_MINIMIZED ? kHomeCardMinimizedHeight : | 189 switch (state_) { |
| 147 kHomeCardHeight; | 190 case VISIBLE_CENTERED: |
| 191 // Span the screen fully. | |
| 192 return std::numeric_limits<int>::max(); | |
| 193 case VISIBLE_BOTTOM: | |
| 194 return kHomeCardHeight; | |
| 195 case VISIBLE_MINIMIZED: | |
| 196 return kHomeCardMinimizedHeight; | |
| 197 case HIDDEN: | |
| 198 NOTREACHED(); | |
| 199 return -1; | |
| 200 } | |
| 148 } | 201 } |
| 149 | 202 |
| 150 virtual int GetHorizontalMargin() const OVERRIDE { | 203 virtual int GetHorizontalMargin() const OVERRIDE { |
| 151 CHECK_NE(HIDDEN, state_); | 204 CHECK_NE(HIDDEN, state_); |
| 152 const int kHomeCardHorizontalMargin = 50; | 205 const int kHomeCardHorizontalMargin = 50; |
| 153 return state_ == VISIBLE_MINIMIZED ? 0 : kHomeCardHorizontalMargin; | 206 return state_ == VISIBLE_BOTTOM ? kHomeCardHorizontalMargin : 0; |
| 154 } | |
| 155 | |
| 156 virtual bool HasShadow() const OVERRIDE { | |
| 157 CHECK_NE(HIDDEN, state_); | |
| 158 return state_ != VISIBLE_MINIMIZED; | |
| 159 } | 207 } |
| 160 | 208 |
| 161 virtual aura::Window* GetNativeWindow() OVERRIDE { | 209 virtual aura::Window* GetNativeWindow() OVERRIDE { |
| 162 switch (state_) { | 210 if (state_ == HIDDEN) |
| 163 case HIDDEN: | 211 return NULL; |
| 164 return NULL; | 212 |
| 165 case VISIBLE_MINIMIZED: | 213 return home_card_widget_ ? home_card_widget_->GetNativeWindow() : NULL; |
| 166 return minimized_widget_ ? minimized_widget_->GetNativeWindow() : NULL; | |
| 167 case VISIBLE_CENTERED: | |
| 168 case VISIBLE_BOTTOM: | |
| 169 return home_card_widget_ ? home_card_widget_->GetNativeWindow() : NULL; | |
| 170 } | |
| 171 return NULL; | |
| 172 } | 214 } |
| 173 | 215 |
| 174 // MinimizedHomeDragDelegate: | 216 // MinimizedHomeDragDelegate: |
| 175 virtual void OnDragUpCompleted() OVERRIDE { | 217 virtual void OnDragUpCompleted() OVERRIDE { |
| 176 WindowManager::GetInstance()->ToggleOverview(); | 218 WindowManager::GetInstance()->ToggleOverview(); |
| 177 } | 219 } |
| 178 | 220 |
| 179 // WindowManagerObserver: | 221 // WindowManagerObserver: |
| 180 virtual void OnOverviewModeEnter() OVERRIDE { | 222 virtual void OnOverviewModeEnter() OVERRIDE { |
| 181 SetState(VISIBLE_BOTTOM); | 223 SetState(VISIBLE_BOTTOM); |
| 182 } | 224 } |
| 183 | 225 |
| 184 virtual void OnOverviewModeExit() OVERRIDE { | 226 virtual void OnOverviewModeExit() OVERRIDE { |
| 185 SetState(VISIBLE_MINIMIZED); | 227 SetState(VISIBLE_MINIMIZED); |
| 186 } | 228 } |
| 187 | 229 |
| 188 scoped_ptr<AppModelBuilder> model_builder_; | 230 scoped_ptr<AppModelBuilder> model_builder_; |
| 189 | 231 |
| 190 HomeCard::State state_; | 232 HomeCard::State state_; |
| 191 | 233 |
| 234 // original_state_ is the state which the home card should go back to after | |
| 235 // the virtual keyboard is hidden. | |
| 236 HomeCard::State original_state_; | |
| 237 | |
| 192 views::Widget* home_card_widget_; | 238 views::Widget* home_card_widget_; |
| 193 views::Widget* minimized_widget_; | 239 HomeCardView* home_card_view_; |
| 194 AppListViewDelegate* view_delegate_; | 240 scoped_ptr<AppListViewDelegate> view_delegate_; |
| 195 HomeCardLayoutManager* layout_manager_; | 241 HomeCardLayoutManager* layout_manager_; |
| 196 | 242 |
| 197 // Right now HomeCard allows only one search provider. | 243 // Right now HomeCard allows only one search provider. |
| 198 // TODO(mukai): port app-list's SearchController and Mixer. | 244 // TODO(mukai): port app-list's SearchController and Mixer. |
| 199 scoped_ptr<app_list::SearchProvider> search_provider_; | 245 scoped_ptr<app_list::SearchProvider> search_provider_; |
| 200 | 246 |
| 201 DISALLOW_COPY_AND_ASSIGN(HomeCardImpl); | 247 DISALLOW_COPY_AND_ASSIGN(HomeCardImpl); |
| 202 }; | 248 }; |
| 203 | 249 |
| 204 HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder) | 250 HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder) |
| 205 : model_builder_(model_builder), | 251 : model_builder_(model_builder), |
| 206 state_(VISIBLE_MINIMIZED), | 252 state_(VISIBLE_MINIMIZED), |
| 253 original_state_(VISIBLE_MINIMIZED), | |
| 207 home_card_widget_(NULL), | 254 home_card_widget_(NULL), |
| 208 minimized_widget_(NULL), | 255 home_card_view_(NULL), |
| 209 layout_manager_(NULL) { | 256 layout_manager_(NULL) { |
| 210 DCHECK(!instance); | 257 DCHECK(!instance); |
| 211 instance = this; | 258 instance = this; |
| 212 WindowManager::GetInstance()->AddObserver(this); | 259 WindowManager::GetInstance()->AddObserver(this); |
| 213 } | 260 } |
| 214 | 261 |
| 215 HomeCardImpl::~HomeCardImpl() { | 262 HomeCardImpl::~HomeCardImpl() { |
| 216 DCHECK(instance); | 263 DCHECK(instance); |
| 217 WindowManager::GetInstance()->RemoveObserver(this); | 264 WindowManager::GetInstance()->RemoveObserver(this); |
| 218 home_card_widget_->CloseNow(); | 265 home_card_widget_->CloseNow(); |
| 219 minimized_widget_->CloseNow(); | |
| 220 view_delegate_ = NULL; | |
| 221 instance = NULL; | 266 instance = NULL; |
| 222 } | 267 } |
| 223 | 268 |
| 224 void HomeCardImpl::SetState(HomeCard::State state) { | 269 void HomeCardImpl::SetState(HomeCard::State state) { |
| 225 // Update |state_| before changing the visibility of the widgets, so that | 270 // Update |state_| before changing the visibility of the widgets, so that |
| 226 // LayoutManager callbacks get the correct state. | 271 // LayoutManager callbacks get the correct state. |
| 227 state_ = state; | 272 state_ = state; |
| 228 switch (state_) { | 273 original_state_ = state; |
| 229 case VISIBLE_MINIMIZED: | 274 if (state_ == HIDDEN) { |
| 230 home_card_widget_->Hide(); | 275 home_card_widget_->Hide(); |
| 231 minimized_widget_->Show(); | 276 } else { |
| 232 break; | 277 home_card_widget_->Show(); |
| 233 case HIDDEN: | 278 home_card_view_->SetState(state); |
| 234 home_card_widget_->Hide(); | 279 layout_manager_->Layout(); |
| 235 minimized_widget_->Hide(); | |
| 236 break; | |
| 237 case VISIBLE_BOTTOM: | |
| 238 case VISIBLE_CENTERED: | |
| 239 home_card_widget_->Show(); | |
| 240 minimized_widget_->Hide(); | |
| 241 break; | |
| 242 } | 280 } |
| 243 } | 281 } |
| 244 | 282 |
| 245 void HomeCardImpl::RegisterSearchProvider( | 283 void HomeCardImpl::RegisterSearchProvider( |
| 246 app_list::SearchProvider* search_provider) { | 284 app_list::SearchProvider* search_provider) { |
| 247 DCHECK(!search_provider_); | 285 DCHECK(!search_provider_); |
| 248 search_provider_.reset(search_provider); | 286 search_provider_.reset(search_provider); |
| 249 view_delegate_->RegisterSearchProvider(search_provider_.get()); | 287 view_delegate_->RegisterSearchProvider(search_provider_.get()); |
| 250 } | 288 } |
| 251 | 289 |
| 252 void HomeCardImpl::UpdateVirtualKeyboardBounds( | 290 void HomeCardImpl::UpdateVirtualKeyboardBounds( |
| 253 const gfx::Rect& bounds) { | 291 const gfx::Rect& bounds) { |
| 254 if (state_ == VISIBLE_MINIMIZED) { | 292 if (state_ == VISIBLE_MINIMIZED && !bounds.IsEmpty()) { |
| 255 if (bounds.IsEmpty()) | 293 SetState(HIDDEN); |
| 256 minimized_widget_->Show(); | 294 original_state_ = VISIBLE_MINIMIZED; |
| 257 else | 295 } else if (state_ == VISIBLE_BOTTOM && !bounds.IsEmpty()) { |
| 258 minimized_widget_->Hide(); | 296 SetState(VISIBLE_CENTERED); |
| 297 original_state_ = VISIBLE_BOTTOM; | |
| 298 } else if (state_ != original_state_ && bounds.IsEmpty()) { | |
| 299 SetState(original_state_); | |
| 259 } | 300 } |
| 260 layout_manager_->UpdateVirtualKeyboardBounds(bounds); | |
| 261 } | 301 } |
| 262 | 302 |
| 263 void HomeCardImpl::Init() { | 303 void HomeCardImpl::Init() { |
| 264 InstallAccelerators(); | 304 InstallAccelerators(); |
| 265 | 305 |
| 266 aura::Window* container = | 306 aura::Window* container = |
| 267 ScreenManager::Get()->CreateContainer("HomeCardContainer"); | 307 ScreenManager::Get()->CreateContainer("HomeCardContainer"); |
| 268 layout_manager_ = new HomeCardLayoutManager(this); | 308 layout_manager_ = new HomeCardLayoutManager(this); |
| 269 container->SetLayoutManager(layout_manager_); | 309 container->SetLayoutManager(layout_manager_); |
| 270 wm::SetChildWindowVisibilityChangesAnimated(container); | 310 wm::SetChildWindowVisibilityChangesAnimated(container); |
| 271 | 311 |
| 272 view_delegate_ = new AppListViewDelegate(model_builder_.get()); | 312 view_delegate_.reset(new AppListViewDelegate(model_builder_.get())); |
| 273 if (search_provider_) | 313 if (search_provider_) |
| 274 view_delegate_->RegisterSearchProvider(search_provider_.get()); | 314 view_delegate_->RegisterSearchProvider(search_provider_.get()); |
| 275 app_list::AppListView* view = new app_list::AppListView(view_delegate_); | |
| 276 view->InitAsBubbleAtFixedLocation( | |
| 277 container, | |
| 278 0 /* initial_apps_page */, | |
| 279 gfx::Point(), | |
| 280 views::BubbleBorder::FLOAT, | |
| 281 true /* border_accepts_events */); | |
| 282 home_card_widget_ = view->GetWidget(); | |
| 283 | 315 |
| 284 // Start off in the minimized state. | 316 // Force showing in the experimental app-list view. |
| 285 minimized_widget_ = CreateMinimizedHome(container, this); | 317 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 318 app_list::switches::kEnableExperimentalAppList); | |
| 319 | |
| 320 home_card_view_ = new HomeCardView(view_delegate_.get(), container, this); | |
| 321 home_card_widget_ = new views::Widget(); | |
| 322 views::Widget::InitParams params( | |
| 323 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | |
| 324 params.parent = container; | |
| 325 params.delegate = home_card_view_; | |
| 326 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | |
| 327 home_card_widget_->Init(params); | |
| 328 | |
| 286 SetState(VISIBLE_MINIMIZED); | 329 SetState(VISIBLE_MINIMIZED); |
| 287 } | 330 } |
| 288 | 331 |
| 289 void HomeCardImpl::InstallAccelerators() { | 332 void HomeCardImpl::InstallAccelerators() { |
| 290 const AcceleratorData accelerator_data[] = { | 333 const AcceleratorData accelerator_data[] = { |
| 291 {TRIGGER_ON_PRESS, ui::VKEY_L, ui::EF_CONTROL_DOWN, | 334 {TRIGGER_ON_PRESS, ui::VKEY_L, ui::EF_CONTROL_DOWN, |
| 292 COMMAND_SHOW_HOME_CARD, AF_NONE}, | 335 COMMAND_SHOW_HOME_CARD, AF_NONE}, |
| 293 }; | 336 }; |
| 294 AcceleratorManager::Get()->RegisterAccelerators( | 337 AcceleratorManager::Get()->RegisterAccelerators( |
| 295 accelerator_data, arraysize(accelerator_data), this); | 338 accelerator_data, arraysize(accelerator_data), this); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 311 instance = NULL; | 354 instance = NULL; |
| 312 } | 355 } |
| 313 | 356 |
| 314 // static | 357 // static |
| 315 HomeCard* HomeCard::Get() { | 358 HomeCard* HomeCard::Get() { |
| 316 DCHECK(instance); | 359 DCHECK(instance); |
| 317 return instance; | 360 return instance; |
| 318 } | 361 } |
| 319 | 362 |
| 320 } // namespace athena | 363 } // namespace athena |
| OLD | NEW |