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

Side by Side Diff: ash/system/tray_accessibility.cc

Issue 10269017: Remove scoped_ptr for system tray views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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 | « ash/system/tray_accessibility.h ('k') | ash/system/tray_caps_lock.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/system/tray_accessibility.h" 5 #include "ash/system/tray_accessibility.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray_delegate.h" 8 #include "ash/system/tray/system_tray_delegate.h"
9 #include "ash/system/tray/tray_constants.h" 9 #include "ash/system/tray/tray_constants.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
11 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/gfx/image/image.h" 12 #include "ui/gfx/image/image.h"
13 #include "ui/views/controls/image_view.h" 13 #include "ui/views/controls/image_view.h"
14 #include "ui/views/controls/label.h" 14 #include "ui/views/controls/label.h"
15 #include "ui/views/layout/box_layout.h" 15 #include "ui/views/layout/box_layout.h"
16 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
17 17
18 namespace ash { 18 namespace ash {
19 namespace internal { 19 namespace internal {
20 20
21 TrayAccessibility::TrayAccessibility() 21 TrayAccessibility::TrayAccessibility()
22 : TrayImageItem(IDR_AURA_UBER_TRAY_ACCESSIBILITY), 22 : TrayImageItem(IDR_AURA_UBER_TRAY_ACCESSIBILITY),
23 detailed_(NULL),
23 string_id_(0) { 24 string_id_(0) {
24 } 25 }
25 26
26 TrayAccessibility::~TrayAccessibility() {} 27 TrayAccessibility::~TrayAccessibility() {}
27 28
28 bool TrayAccessibility::GetInitialVisibility() { 29 bool TrayAccessibility::GetInitialVisibility() {
29 return ash::Shell::GetInstance()->tray_delegate()->IsInAccessibilityMode(); 30 return ash::Shell::GetInstance()->tray_delegate()->IsInAccessibilityMode();
30 } 31 }
31 32
32 views::View* TrayAccessibility::CreateDetailedView(user::LoginStatus status) { 33 views::View* TrayAccessibility::CreateDetailedView(user::LoginStatus status) {
33 DCHECK(string_id_); 34 DCHECK(string_id_);
34 detailed_.reset(new views::View); 35 CHECK(detailed_ == NULL);
36 detailed_ = new views::View;
35 37
36 detailed_->SetLayoutManager(new 38 detailed_->SetLayoutManager(new
37 views::BoxLayout(views::BoxLayout::kHorizontal, 39 views::BoxLayout(views::BoxLayout::kHorizontal,
38 kTrayPopupPaddingHorizontal, 10, kTrayPopupPaddingBetweenItems)); 40 kTrayPopupPaddingHorizontal, 10, kTrayPopupPaddingBetweenItems));
39 41
40 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 42 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
41 views::ImageView* image = new views::ImageView; 43 views::ImageView* image = new views::ImageView;
42 image->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_ACCESSIBILITY). 44 image->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_ACCESSIBILITY).
43 ToSkBitmap()); 45 ToSkBitmap());
44 46
45 detailed_->AddChildView(image); 47 detailed_->AddChildView(image);
46 detailed_->AddChildView(new views::Label( 48 detailed_->AddChildView(new views::Label(
47 bundle.GetLocalizedString(string_id_))); 49 bundle.GetLocalizedString(string_id_)));
48 50
49 return detailed_.get(); 51 return detailed_;
50 } 52 }
51 53
52 void TrayAccessibility::DestroyDetailedView() { 54 void TrayAccessibility::DestroyDetailedView() {
53 detailed_.reset(); 55 detailed_ = NULL;
54 } 56 }
55 57
56 void TrayAccessibility::OnAccessibilityModeChanged(bool enabled, 58 void TrayAccessibility::OnAccessibilityModeChanged(bool enabled,
57 int string_id) { 59 int string_id) {
58 if (tray_view()) 60 if (tray_view())
59 tray_view()->SetVisible(enabled); 61 tray_view()->SetVisible(enabled);
60 62
61 if (enabled) { 63 if (enabled) {
62 string_id_ = string_id; 64 string_id_ = string_id;
63 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); 65 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false);
64 } else if (detailed_.get()) { 66 } else if (detailed_) {
65 string_id_ = 0; 67 string_id_ = 0;
66 detailed_->GetWidget()->Close(); 68 detailed_->GetWidget()->Close();
67 } 69 }
68 } 70 }
69 71
70 } // namespace internal 72 } // namespace internal
71 } // namespace ash 73 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray_accessibility.h ('k') | ash/system/tray_caps_lock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698