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

Side by Side Diff: ash/system/update/tray_update.cc

Issue 2925893002: [Merge to M60] Fix crash of update-over-cellular icon (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | chrome/browser/chromeos/upgrade_detector_chromeos.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 (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/update/tray_update.h" 5 #include "ash/system/update/tray_update.h"
6 6
7 #include "ash/metrics/user_metrics_action.h" 7 #include "ash/metrics/user_metrics_action.h"
8 #include "ash/public/interfaces/update.mojom.h" 8 #include "ash/public/interfaces/update.mojom.h"
9 #include "ash/resources/vector_icons/vector_icons.h" 9 #include "ash/resources/vector_icons/vector_icons.h"
10 #include "ash/session/session_controller.h"
10 #include "ash/shell.h" 11 #include "ash/shell.h"
11 #include "ash/shell_port.h" 12 #include "ash/shell_port.h"
12 #include "ash/strings/grit/ash_strings.h" 13 #include "ash/strings/grit/ash_strings.h"
13 #include "ash/system/tray/system_tray.h" 14 #include "ash/system/tray/system_tray.h"
14 #include "ash/system/tray/system_tray_controller.h" 15 #include "ash/system/tray/system_tray_controller.h"
15 #include "ash/system/tray/system_tray_delegate.h" 16 #include "ash/system/tray/system_tray_delegate.h"
16 #include "ash/system/tray/tray_constants.h" 17 #include "ash/system/tray/tray_constants.h"
17 #include "ash/system/tray/tray_popup_item_style.h" 18 #include "ash/system/tray/tray_popup_item_style.h"
18 #include "ash/system/tray/tray_popup_utils.h" 19 #include "ash/system/tray/tray_popup_utils.h"
19 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 76 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
76 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); 77 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView();
77 AddChildView(tri_view); 78 AddChildView(tri_view);
78 views::ImageView* image = TrayPopupUtils::CreateMainImageView(); 79 views::ImageView* image = TrayPopupUtils::CreateMainImageView();
79 image->SetImage(gfx::CreateVectorIcon( 80 image->SetImage(gfx::CreateVectorIcon(
80 kSystemMenuUpdateIcon, 81 kSystemMenuUpdateIcon,
81 IconColorForUpdateSeverity(owner->severity_, true))); 82 IconColorForUpdateSeverity(owner->severity_, true)));
82 tri_view->AddView(TriView::Container::START, image); 83 tri_view->AddView(TriView::Container::START, image);
83 84
84 base::string16 label_text; 85 base::string16 label_text;
86 update_label_ = TrayPopupUtils::CreateDefaultLabel();
85 if (owner->factory_reset_required_) { 87 if (owner->factory_reset_required_) {
86 label_text = bundle.GetLocalizedString( 88 label_text = bundle.GetLocalizedString(
87 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE); 89 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE);
88 } else if (owner->update_type_ == mojom::UpdateType::FLASH) { 90 } else if (owner->update_type_ == mojom::UpdateType::FLASH) {
89 label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE_FLASH); 91 label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE_FLASH);
90 } else if (!owner->update_required_ && 92 } else if (!owner->update_required_ &&
91 owner->update_over_cellular_available_) { 93 owner->update_over_cellular_available_) {
92 label_text = bundle.GetLocalizedString( 94 label_text = bundle.GetLocalizedString(
93 IDS_ASH_STATUS_TRAY_UPDATE_OVER_CELLULAR_AVAILABLE); 95 IDS_ASH_STATUS_TRAY_UPDATE_OVER_CELLULAR_AVAILABLE);
96 if (!Shell::Get()->session_controller()->ShouldEnableSettings()) {
97 // Disables the view if settings page is not enabled.
98 tri_view->SetEnabled(false);
99 update_label_->SetEnabled(false);
100 }
94 } else { 101 } else {
95 label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE); 102 label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE);
96 } 103 }
97 104
98 SetAccessibleName(label_text); 105 SetAccessibleName(label_text);
99 update_label_ = TrayPopupUtils::CreateDefaultLabel();
100 update_label_->SetText(label_text); 106 update_label_->SetText(label_text);
101 107
102 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); 108 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
103 style.SetupLabel(update_label_); 109 style.SetupLabel(update_label_);
104 tri_view->AddView(TriView::Container::CENTER, update_label_); 110 tri_view->AddView(TriView::Container::CENTER, update_label_);
105 111
106 SetInkDropMode(InkDropHostView::InkDropMode::ON); 112 SetInkDropMode(InkDropHostView::InkDropMode::ON);
107 } 113 }
108 114
109 ~UpdateView() override {} 115 ~UpdateView() override {}
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 update_over_cellular_available_ = true; 181 update_over_cellular_available_ = true;
176 182
177 // TODO(weidongg/691108): adjust severity according the amount of time passing 183 // TODO(weidongg/691108): adjust severity according the amount of time passing
178 // after update is available over cellular connection. 184 // after update is available over cellular connection.
179 // Use low severity for update available over cellular connection. 185 // Use low severity for update available over cellular connection.
180 SetIconColor(IconColorForUpdateSeverity(mojom::UpdateSeverity::LOW, false)); 186 SetIconColor(IconColorForUpdateSeverity(mojom::UpdateSeverity::LOW, false));
181 tray_view()->SetVisible(true); 187 tray_view()->SetVisible(true);
182 } 188 }
183 189
184 } // namespace ash 190 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/upgrade_detector_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698