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

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

Issue 516643005: Adds the test expectations of home card bounds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years, 3 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
« no previous file with comments | « athena/home/home_card_impl.h ('k') | athena/home/home_card_unittest.cc » ('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/home_card_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #include "athena/common/container_priorities.h" 10 #include "athena/common/container_priorities.h"
11 #include "athena/env/public/athena_env.h" 11 #include "athena/env/public/athena_env.h"
12 #include "athena/home/app_list_view_delegate.h" 12 #include "athena/home/app_list_view_delegate.h"
13 #include "athena/home/athena_start_page_view.h" 13 #include "athena/home/athena_start_page_view.h"
14 #include "athena/home/home_card_constants.h" 14 #include "athena/home/home_card_constants.h"
15 #include "athena/home/home_card_gesture_manager.h"
16 #include "athena/home/minimized_home.h" 15 #include "athena/home/minimized_home.h"
17 #include "athena/home/public/app_model_builder.h" 16 #include "athena/home/public/app_model_builder.h"
18 #include "athena/input/public/accelerator_manager.h"
19 #include "athena/screen/public/screen_manager.h" 17 #include "athena/screen/public/screen_manager.h"
20 #include "athena/wm/public/window_manager.h" 18 #include "athena/wm/public/window_manager.h"
21 #include "athena/wm/public/window_manager_observer.h"
22 #include "ui/app_list/search_provider.h" 19 #include "ui/app_list/search_provider.h"
23 #include "ui/app_list/views/app_list_main_view.h" 20 #include "ui/app_list/views/app_list_main_view.h"
24 #include "ui/app_list/views/contents_view.h" 21 #include "ui/app_list/views/contents_view.h"
25 #include "ui/aura/layout_manager.h" 22 #include "ui/aura/layout_manager.h"
26 #include "ui/aura/window.h" 23 #include "ui/aura/window.h"
27 #include "ui/compositor/layer.h" 24 #include "ui/compositor/layer.h"
28 #include "ui/compositor/layer_owner.h"
29 #include "ui/compositor/scoped_layer_animation_settings.h" 25 #include "ui/compositor/scoped_layer_animation_settings.h"
30 #include "ui/views/layout/fill_layout.h" 26 #include "ui/views/layout/fill_layout.h"
31 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
32 #include "ui/views/widget/widget_delegate.h" 28 #include "ui/views/widget/widget_delegate.h"
33 #include "ui/wm/core/shadow_types.h" 29 #include "ui/wm/core/shadow_types.h"
34 #include "ui/wm/core/visibility_controller.h" 30 #include "ui/wm/core/visibility_controller.h"
35 #include "ui/wm/public/activation_change_observer.h"
36 #include "ui/wm/public/activation_client.h" 31 #include "ui/wm/public/activation_client.h"
37 32
38 namespace athena { 33 namespace athena {
39 namespace { 34 namespace {
40 35
41 HomeCard* instance = NULL; 36 HomeCard* instance = NULL;
42 37
43 gfx::Rect GetBoundsForState(const gfx::Rect& screen_bounds, 38 gfx::Rect GetBoundsForState(const gfx::Rect& screen_bounds,
44 HomeCard::State state) { 39 HomeCard::State state) {
45 switch (state) { 40 switch (state) {
(...skipping 14 matching lines...) Expand all
60 return gfx::Rect(0, 55 return gfx::Rect(0,
61 screen_bounds.bottom() - kHomeCardMinimizedHeight, 56 screen_bounds.bottom() - kHomeCardMinimizedHeight,
62 screen_bounds.width(), 57 screen_bounds.width(),
63 screen_bounds.height()); 58 screen_bounds.height());
64 } 59 }
65 60
66 NOTREACHED(); 61 NOTREACHED();
67 return gfx::Rect(); 62 return gfx::Rect();
68 } 63 }
69 64
65 } // namespace
66
70 // Makes sure the homecard is center-aligned horizontally and bottom-aligned 67 // Makes sure the homecard is center-aligned horizontally and bottom-aligned
71 // vertically. 68 // vertically.
72 class HomeCardLayoutManager : public aura::LayoutManager { 69 class HomeCardLayoutManager : public aura::LayoutManager {
73 public: 70 public:
74 HomeCardLayoutManager() 71 HomeCardLayoutManager()
75 : home_card_(NULL), 72 : home_card_(NULL),
76 minimized_layer_(NULL) {} 73 minimized_layer_(NULL) {}
77 74
78 virtual ~HomeCardLayoutManager() {} 75 virtual ~HomeCardLayoutManager() {}
79 76
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return this; 216 return this;
220 } 217 }
221 218
222 AthenaStartPageView* main_view_; 219 AthenaStartPageView* main_view_;
223 scoped_ptr<HomeCardGestureManager> gesture_manager_; 220 scoped_ptr<HomeCardGestureManager> gesture_manager_;
224 HomeCardGestureManager::Delegate* gesture_delegate_; 221 HomeCardGestureManager::Delegate* gesture_delegate_;
225 222
226 DISALLOW_COPY_AND_ASSIGN(HomeCardView); 223 DISALLOW_COPY_AND_ASSIGN(HomeCardView);
227 }; 224 };
228 225
229 class HomeCardImpl : public HomeCard,
230 public AcceleratorHandler,
231 public HomeCardGestureManager::Delegate,
232 public WindowManagerObserver,
233 public aura::client::ActivationChangeObserver {
234 public:
235 explicit HomeCardImpl(AppModelBuilder* model_builder);
236 virtual ~HomeCardImpl();
237
238 void Init();
239
240 private:
241 enum Command {
242 COMMAND_SHOW_HOME_CARD,
243 };
244 void InstallAccelerators();
245 void UpdateMinimizedHomeBounds();
246
247 // Overridden from HomeCard:
248 virtual void SetState(State state) OVERRIDE;
249 virtual State GetState() OVERRIDE;
250 virtual void RegisterSearchProvider(
251 app_list::SearchProvider* search_provider) OVERRIDE;
252 virtual void UpdateVirtualKeyboardBounds(
253 const gfx::Rect& bounds) OVERRIDE;
254
255 // AcceleratorHandler:
256 virtual bool IsCommandEnabled(int command_id) const OVERRIDE { return true; }
257 virtual bool OnAcceleratorFired(int command_id,
258 const ui::Accelerator& accelerator) OVERRIDE;
259
260 // HomeCardGestureManager::Delegate:
261 virtual void OnGestureEnded(State final_state) OVERRIDE;
262 virtual void OnGestureProgressed(
263 State from_state, State to_state, float progress) OVERRIDE;
264
265 // WindowManagerObserver:
266 virtual void OnOverviewModeEnter() OVERRIDE;
267 virtual void OnOverviewModeExit() OVERRIDE;
268 virtual void OnActivityOrderHasChanged() OVERRIDE;
269
270 // aura::client::ActivationChangeObserver:
271 virtual void OnWindowActivated(aura::Window* gained_active,
272 aura::Window* lost_active) OVERRIDE;
273
274 scoped_ptr<AppModelBuilder> model_builder_;
275
276 HomeCard::State state_;
277
278 // original_state_ is the state which the home card should go back to after
279 // the virtual keyboard is hidden.
280 HomeCard::State original_state_;
281
282 views::Widget* home_card_widget_;
283 HomeCardView* home_card_view_;
284 scoped_ptr<AppListViewDelegate> view_delegate_;
285 HomeCardLayoutManager* layout_manager_;
286 aura::client::ActivationClient* activation_client_; // Not owned
287 scoped_ptr<ui::LayerOwner> minimized_home_;
288
289 // Right now HomeCard allows only one search provider.
290 // TODO(mukai): port app-list's SearchController and Mixer.
291 scoped_ptr<app_list::SearchProvider> search_provider_;
292
293 DISALLOW_COPY_AND_ASSIGN(HomeCardImpl);
294 };
295
296 HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder) 226 HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder)
297 : model_builder_(model_builder), 227 : model_builder_(model_builder),
298 state_(HIDDEN), 228 state_(HIDDEN),
299 original_state_(VISIBLE_MINIMIZED), 229 original_state_(VISIBLE_MINIMIZED),
300 home_card_widget_(NULL), 230 home_card_widget_(NULL),
301 home_card_view_(NULL), 231 home_card_view_(NULL),
302 layout_manager_(NULL), 232 layout_manager_(NULL),
303 activation_client_(NULL) { 233 activation_client_(NULL) {
304 DCHECK(!instance); 234 DCHECK(!instance);
305 instance = this; 235 instance = this;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 283
354 activation_client_ = 284 activation_client_ =
355 aura::client::GetActivationClient(container->GetRootWindow()); 285 aura::client::GetActivationClient(container->GetRootWindow());
356 if (activation_client_) 286 if (activation_client_)
357 activation_client_->AddObserver(this); 287 activation_client_->AddObserver(this);
358 288
359 AthenaEnv::Get()->SetDisplayWorkAreaInsets( 289 AthenaEnv::Get()->SetDisplayWorkAreaInsets(
360 gfx::Insets(0, 0, kHomeCardMinimizedHeight, 0)); 290 gfx::Insets(0, 0, kHomeCardMinimizedHeight, 0));
361 } 291 }
362 292
293 aura::Window* HomeCardImpl::GetHomeCardWindowForTest() const {
294 return home_card_widget_ ? home_card_widget_->GetNativeWindow() : NULL;
295 }
296
363 void HomeCardImpl::InstallAccelerators() { 297 void HomeCardImpl::InstallAccelerators() {
364 const AcceleratorData accelerator_data[] = { 298 const AcceleratorData accelerator_data[] = {
365 {TRIGGER_ON_PRESS, ui::VKEY_L, ui::EF_CONTROL_DOWN, 299 {TRIGGER_ON_PRESS, ui::VKEY_L, ui::EF_CONTROL_DOWN,
366 COMMAND_SHOW_HOME_CARD, AF_NONE}, 300 COMMAND_SHOW_HOME_CARD, AF_NONE},
367 }; 301 };
368 AcceleratorManager::Get()->RegisterAccelerators( 302 AcceleratorManager::Get()->RegisterAccelerators(
369 accelerator_data, arraysize(accelerator_data), this); 303 accelerator_data, arraysize(accelerator_data), this);
370 } 304 }
371 305
372 void HomeCardImpl::SetState(HomeCard::State state) { 306 void HomeCardImpl::SetState(HomeCard::State state) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 SetState(HIDDEN); 353 SetState(HIDDEN);
420 original_state_ = VISIBLE_MINIMIZED; 354 original_state_ = VISIBLE_MINIMIZED;
421 } else if (state_ == VISIBLE_BOTTOM && !bounds.IsEmpty()) { 355 } else if (state_ == VISIBLE_BOTTOM && !bounds.IsEmpty()) {
422 SetState(VISIBLE_CENTERED); 356 SetState(VISIBLE_CENTERED);
423 original_state_ = VISIBLE_BOTTOM; 357 original_state_ = VISIBLE_BOTTOM;
424 } else if (state_ != original_state_ && bounds.IsEmpty()) { 358 } else if (state_ != original_state_ && bounds.IsEmpty()) {
425 SetState(original_state_); 359 SetState(original_state_);
426 } 360 }
427 } 361 }
428 362
363 bool HomeCardImpl::IsCommandEnabled(int command_id) const {
364 return true;
365 }
366
429 bool HomeCardImpl::OnAcceleratorFired(int command_id, 367 bool HomeCardImpl::OnAcceleratorFired(int command_id,
430 const ui::Accelerator& accelerator) { 368 const ui::Accelerator& accelerator) {
431 DCHECK_EQ(COMMAND_SHOW_HOME_CARD, command_id); 369 DCHECK_EQ(COMMAND_SHOW_HOME_CARD, command_id);
432 370
433 if (state_ == VISIBLE_CENTERED && original_state_ != VISIBLE_BOTTOM) 371 if (state_ == VISIBLE_CENTERED && original_state_ != VISIBLE_BOTTOM)
434 SetState(VISIBLE_MINIMIZED); 372 SetState(VISIBLE_MINIMIZED);
435 else if (state_ == VISIBLE_MINIMIZED) 373 else if (state_ == VISIBLE_MINIMIZED)
436 SetState(VISIBLE_CENTERED); 374 SetState(VISIBLE_CENTERED);
437 return true; 375 return true;
438 } 376 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 } 422 }
485 423
486 void HomeCardImpl::OnWindowActivated(aura::Window* gained_active, 424 void HomeCardImpl::OnWindowActivated(aura::Window* gained_active,
487 aura::Window* lost_active) { 425 aura::Window* lost_active) {
488 if (state_ != HIDDEN && 426 if (state_ != HIDDEN &&
489 gained_active != home_card_widget_->GetNativeWindow()) { 427 gained_active != home_card_widget_->GetNativeWindow()) {
490 SetState(VISIBLE_MINIMIZED); 428 SetState(VISIBLE_MINIMIZED);
491 } 429 }
492 } 430 }
493 431
494 } // namespace
495
496 // static 432 // static
497 HomeCard* HomeCard::Create(AppModelBuilder* model_builder) { 433 HomeCard* HomeCard::Create(AppModelBuilder* model_builder) {
498 (new HomeCardImpl(model_builder))->Init(); 434 (new HomeCardImpl(model_builder))->Init();
499 DCHECK(instance); 435 DCHECK(instance);
500 return instance; 436 return instance;
501 } 437 }
502 438
503 // static 439 // static
504 void HomeCard::Shutdown() { 440 void HomeCard::Shutdown() {
505 DCHECK(instance); 441 DCHECK(instance);
506 delete instance; 442 delete instance;
507 instance = NULL; 443 instance = NULL;
508 } 444 }
509 445
510 // static 446 // static
511 HomeCard* HomeCard::Get() { 447 HomeCard* HomeCard::Get() {
512 DCHECK(instance); 448 DCHECK(instance);
513 return instance; 449 return instance;
514 } 450 }
515 451
516 } // namespace athena 452 } // namespace athena
OLDNEW
« no previous file with comments | « athena/home/home_card_impl.h ('k') | athena/home/home_card_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698