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

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

Issue 653563004: NULL -> nullptr under athena/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 6 years, 2 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/athena_start_page_view.cc ('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/home_card_impl.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/env/public/athena_env.h" 10 #include "athena/env/public/athena_env.h"
(...skipping 14 matching lines...) Expand all
25 #include "ui/gfx/animation/tween.h" 25 #include "ui/gfx/animation/tween.h"
26 #include "ui/views/layout/fill_layout.h" 26 #include "ui/views/layout/fill_layout.h"
27 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
28 #include "ui/views/widget/widget_delegate.h" 28 #include "ui/views/widget/widget_delegate.h"
29 #include "ui/wm/core/shadow_types.h" 29 #include "ui/wm/core/shadow_types.h"
30 #include "ui/wm/core/visibility_controller.h" 30 #include "ui/wm/core/visibility_controller.h"
31 31
32 namespace athena { 32 namespace athena {
33 namespace { 33 namespace {
34 34
35 HomeCard* instance = NULL; 35 HomeCard* instance = nullptr;
36 36
37 gfx::Rect GetBoundsForState(const gfx::Rect& screen_bounds, 37 gfx::Rect GetBoundsForState(const gfx::Rect& screen_bounds,
38 HomeCard::State state) { 38 HomeCard::State state) {
39 switch (state) { 39 switch (state) {
40 case HomeCard::HIDDEN: 40 case HomeCard::HIDDEN:
41 break; 41 break;
42 42
43 case HomeCard::VISIBLE_CENTERED: 43 case HomeCard::VISIBLE_CENTERED:
44 return screen_bounds; 44 return screen_bounds;
45 45
(...skipping 14 matching lines...) Expand all
60 NOTREACHED(); 60 NOTREACHED();
61 return gfx::Rect(); 61 return gfx::Rect();
62 } 62 }
63 63
64 } // namespace 64 } // namespace
65 65
66 // Makes sure the homecard is center-aligned horizontally and bottom-aligned 66 // Makes sure the homecard is center-aligned horizontally and bottom-aligned
67 // vertically. 67 // vertically.
68 class HomeCardLayoutManager : public aura::LayoutManager { 68 class HomeCardLayoutManager : public aura::LayoutManager {
69 public: 69 public:
70 HomeCardLayoutManager() 70 HomeCardLayoutManager() : home_card_(nullptr), minimized_layer_(nullptr) {}
71 : home_card_(NULL),
72 minimized_layer_(NULL) {}
73 71
74 virtual ~HomeCardLayoutManager() {} 72 virtual ~HomeCardLayoutManager() {}
75 73
76 void Layout(bool animate, gfx::Tween::Type tween_type) { 74 void Layout(bool animate, gfx::Tween::Type tween_type) {
77 // |home_card| could be detached from the root window (e.g. when it is being 75 // |home_card| could be detached from the root window (e.g. when it is being
78 // destroyed). 76 // destroyed).
79 if (!home_card_ || !home_card_->IsVisible() || !home_card_->GetRootWindow()) 77 if (!home_card_ || !home_card_->IsVisible() || !home_card_->GetRootWindow())
80 return; 78 return;
81 79
82 scoped_ptr<ui::ScopedLayerAnimationSettings> settings; 80 scoped_ptr<ui::ScopedLayerAnimationSettings> settings;
(...skipping 26 matching lines...) Expand all
109 UpdateMinimizedHomeBounds(); 107 UpdateMinimizedHomeBounds();
110 } 108 }
111 virtual void OnWindowAddedToLayout(aura::Window* child) override { 109 virtual void OnWindowAddedToLayout(aura::Window* child) override {
112 if (!home_card_) { 110 if (!home_card_) {
113 home_card_ = child; 111 home_card_ = child;
114 Layout(false, gfx::Tween::LINEAR); 112 Layout(false, gfx::Tween::LINEAR);
115 } 113 }
116 } 114 }
117 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) override { 115 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) override {
118 if (home_card_ == child) 116 if (home_card_ == child)
119 home_card_ = NULL; 117 home_card_ = nullptr;
120 } 118 }
121 virtual void OnWindowRemovedFromLayout(aura::Window* child) override { 119 virtual void OnWindowRemovedFromLayout(aura::Window* child) override {
122 } 120 }
123 virtual void OnChildWindowVisibilityChanged(aura::Window* child, 121 virtual void OnChildWindowVisibilityChanged(aura::Window* child,
124 bool visible) override { 122 bool visible) override {
125 if (home_card_ == child) 123 if (home_card_ == child)
126 Layout(false, gfx::Tween::LINEAR); 124 Layout(false, gfx::Tween::LINEAR);
127 } 125 }
128 virtual void SetChildBounds(aura::Window* child, 126 virtual void SetChildBounds(aura::Window* child,
129 const gfx::Rect& requested_bounds) override { 127 const gfx::Rect& requested_bounds) override {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 227
230 DISALLOW_COPY_AND_ASSIGN(HomeCardView); 228 DISALLOW_COPY_AND_ASSIGN(HomeCardView);
231 }; 229 };
232 230
233 HomeCardImpl::HomeCardImpl(scoped_ptr<AppModelBuilder> model_builder, 231 HomeCardImpl::HomeCardImpl(scoped_ptr<AppModelBuilder> model_builder,
234 scoped_ptr<SearchControllerFactory> search_factory) 232 scoped_ptr<SearchControllerFactory> search_factory)
235 : model_builder_(model_builder.Pass()), 233 : model_builder_(model_builder.Pass()),
236 search_factory_(search_factory.Pass()), 234 search_factory_(search_factory.Pass()),
237 state_(HIDDEN), 235 state_(HIDDEN),
238 original_state_(VISIBLE_MINIMIZED), 236 original_state_(VISIBLE_MINIMIZED),
239 home_card_widget_(NULL), 237 home_card_widget_(nullptr),
240 home_card_view_(NULL), 238 home_card_view_(nullptr),
241 layout_manager_(NULL) { 239 layout_manager_(nullptr) {
242 DCHECK(!instance); 240 DCHECK(!instance);
243 instance = this; 241 instance = this;
244 WindowManager::Get()->AddObserver(this); 242 WindowManager::Get()->AddObserver(this);
245 } 243 }
246 244
247 HomeCardImpl::~HomeCardImpl() { 245 HomeCardImpl::~HomeCardImpl() {
248 DCHECK(instance); 246 DCHECK(instance);
249 WindowManager::Get()->RemoveObserver(this); 247 WindowManager::Get()->RemoveObserver(this);
250 home_card_widget_->CloseNow(); 248 home_card_widget_->CloseNow();
251 249
252 // Reset the view delegate first as it access search provider during 250 // Reset the view delegate first as it access search provider during
253 // shutdown. 251 // shutdown.
254 view_delegate_.reset(); 252 view_delegate_.reset();
255 instance = NULL; 253 instance = nullptr;
256 } 254 }
257 255
258 void HomeCardImpl::Init() { 256 void HomeCardImpl::Init() {
259 InstallAccelerators(); 257 InstallAccelerators();
260 ScreenManager::ContainerParams params("HomeCardContainer", CP_HOME_CARD); 258 ScreenManager::ContainerParams params("HomeCardContainer", CP_HOME_CARD);
261 params.can_activate_children = true; 259 params.can_activate_children = true;
262 aura::Window* container = ScreenManager::Get()->CreateContainer(params); 260 aura::Window* container = ScreenManager::Get()->CreateContainer(params);
263 layout_manager_ = new HomeCardLayoutManager(); 261 layout_manager_ = new HomeCardLayoutManager();
264 262
265 container->SetLayoutManager(layout_manager_); 263 container->SetLayoutManager(layout_manager_);
(...skipping 17 matching lines...) Expand all
283 layout_manager_->SetMinimizedLayer(minimized_home_->layer()); 281 layout_manager_->SetMinimizedLayer(minimized_home_->layer());
284 282
285 SetState(VISIBLE_MINIMIZED); 283 SetState(VISIBLE_MINIMIZED);
286 home_card_view_->Layout(); 284 home_card_view_->Layout();
287 285
288 AthenaEnv::Get()->SetDisplayWorkAreaInsets( 286 AthenaEnv::Get()->SetDisplayWorkAreaInsets(
289 gfx::Insets(0, 0, kHomeCardMinimizedHeight, 0)); 287 gfx::Insets(0, 0, kHomeCardMinimizedHeight, 0));
290 } 288 }
291 289
292 aura::Window* HomeCardImpl::GetHomeCardWindowForTest() const { 290 aura::Window* HomeCardImpl::GetHomeCardWindowForTest() const {
293 return home_card_widget_ ? home_card_widget_->GetNativeWindow() : NULL; 291 return home_card_widget_ ? home_card_widget_->GetNativeWindow() : nullptr;
294 } 292 }
295 293
296 void HomeCardImpl::InstallAccelerators() { 294 void HomeCardImpl::InstallAccelerators() {
297 const AcceleratorData accelerator_data[] = { 295 const AcceleratorData accelerator_data[] = {
298 {TRIGGER_ON_PRESS, ui::VKEY_L, ui::EF_CONTROL_DOWN, 296 {TRIGGER_ON_PRESS, ui::VKEY_L, ui::EF_CONTROL_DOWN,
299 COMMAND_SHOW_HOME_CARD, AF_NONE}, 297 COMMAND_SHOW_HOME_CARD, AF_NONE},
300 }; 298 };
301 AcceleratorManager::Get()->RegisterAccelerators( 299 AcceleratorManager::Get()->RegisterAccelerators(
302 accelerator_data, arraysize(accelerator_data), this); 300 accelerator_data, arraysize(accelerator_data), this);
303 } 301 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 scoped_ptr<SearchControllerFactory> search_factory) { 430 scoped_ptr<SearchControllerFactory> search_factory) {
433 (new HomeCardImpl(model_builder.Pass(), search_factory.Pass()))->Init(); 431 (new HomeCardImpl(model_builder.Pass(), search_factory.Pass()))->Init();
434 DCHECK(instance); 432 DCHECK(instance);
435 return instance; 433 return instance;
436 } 434 }
437 435
438 // static 436 // static
439 void HomeCard::Shutdown() { 437 void HomeCard::Shutdown() {
440 DCHECK(instance); 438 DCHECK(instance);
441 delete instance; 439 delete instance;
442 instance = NULL; 440 instance = nullptr;
443 } 441 }
444 442
445 // static 443 // static
446 HomeCard* HomeCard::Get() { 444 HomeCard* HomeCard::Get() {
447 DCHECK(instance); 445 DCHECK(instance);
448 return instance; 446 return instance;
449 } 447 }
450 448
451 } // namespace athena 449 } // namespace athena
OLDNEW
« no previous file with comments | « athena/home/athena_start_page_view.cc ('k') | athena/home/home_card_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698