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

Side by Side Diff: ash/common/system/chromeos/palette/palette_tray.cc

Issue 2557593009: Fix Chrome crashes on calling OnTrayVisibilityChange (Closed)
Patch Set: new approach Created 4 years 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ash/common/system/chromeos/palette/palette_tray.h" 5 #include "ash/common/system/chromeos/palette/palette_tray.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shelf/shelf_constants.h" 9 #include "ash/common/shelf/shelf_constants.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 SetIconBorderForShelfAlignment(); 197 SetIconBorderForShelfAlignment();
198 tray_container()->AddChildView(icon_); 198 tray_container()->AddChildView(icon_);
199 199
200 WmShell::Get()->AddShellObserver(this); 200 WmShell::Get()->AddShellObserver(this);
201 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); 201 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this);
202 if (WmShell::Get()->palette_delegate()) { 202 if (WmShell::Get()->palette_delegate()) {
203 WmShell::Get()->palette_delegate()->SetStylusStateChangedCallback( 203 WmShell::Get()->palette_delegate()->SetStylusStateChangedCallback(
204 base::Bind(&PaletteTray::OnStylusStateChanged, 204 base::Bind(&PaletteTray::OnStylusStateChanged,
205 weak_factory_.GetWeakPtr())); 205 weak_factory_.GetWeakPtr()));
206 } 206 }
207
208 // OnPaletteEnabledPrefChanged will get called with the initial pref value,
209 // which will take care of showing the palette.
210 palette_enabled_subscription_ =
211 WmShell::Get()->palette_delegate()->AddPaletteEnableListener(
212 base::Bind(&PaletteTray::OnPaletteEnabledPrefChanged,
213 weak_factory_.GetWeakPtr()));
214 } 207 }
215 208
216 PaletteTray::~PaletteTray() { 209 PaletteTray::~PaletteTray() {
217 if (bubble_) 210 if (bubble_)
218 bubble_->bubble_view()->reset_delegate(); 211 bubble_->bubble_view()->reset_delegate();
219 212
220 WmShell::Get()->RemoveShellObserver(this); 213 WmShell::Get()->RemoveShellObserver(this);
221 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this); 214 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this);
222 } 215 }
223 216
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 399
407 TrayBackgroundView::SetShelfAlignment(alignment); 400 TrayBackgroundView::SetShelfAlignment(alignment);
408 SetIconBorderForShelfAlignment(); 401 SetIconBorderForShelfAlignment();
409 } 402 }
410 403
411 void PaletteTray::AnchorUpdated() { 404 void PaletteTray::AnchorUpdated() {
412 if (bubble_) 405 if (bubble_)
413 bubble_->bubble_view()->UpdateBubble(); 406 bubble_->bubble_view()->UpdateBubble();
414 } 407 }
415 408
409 void PaletteTray::Initialize() {
410 // OnPaletteEnabledPrefChanged will get called with the initial pref value,
411 // which will take care of showing the palette.
412 palette_enabled_subscription_ =
413 WmShell::Get()->palette_delegate()->AddPaletteEnableListener(
414 base::Bind(&PaletteTray::OnPaletteEnabledPrefChanged,
415 weak_factory_.GetWeakPtr()));
416 }
417
416 void PaletteTray::SetIconBorderForShelfAlignment() { 418 void PaletteTray::SetIconBorderForShelfAlignment() {
417 // TODO(tdanderson): Ensure PaletteTray follows material design specs. See 419 // TODO(tdanderson): Ensure PaletteTray follows material design specs. See
418 // crbug.com/630464. 420 // crbug.com/630464.
419 if (IsHorizontalAlignment(shelf_alignment())) { 421 if (IsHorizontalAlignment(shelf_alignment())) {
420 icon_->SetBorder(views::CreateEmptyBorder(gfx::Insets( 422 icon_->SetBorder(views::CreateEmptyBorder(gfx::Insets(
421 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding))); 423 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding)));
422 } else { 424 } else {
423 icon_->SetBorder(views::CreateEmptyBorder(gfx::Insets( 425 icon_->SetBorder(views::CreateEmptyBorder(gfx::Insets(
424 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding))); 426 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding)));
425 } 427 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 } else { 466 } else {
465 UpdateIconVisibility(); 467 UpdateIconVisibility();
466 } 468 }
467 } 469 }
468 470
469 void PaletteTray::UpdateIconVisibility() { 471 void PaletteTray::UpdateIconVisibility() {
470 SetVisible(is_palette_enabled_ && IsInUserSession()); 472 SetVisible(is_palette_enabled_ && IsInUserSession());
471 } 473 }
472 474
473 } // namespace ash 475 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/palette/palette_tray.h ('k') | ash/common/system/status_area_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698