| OLD | NEW |
| 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 "chrome/browser/extensions/extension_storage_monitor.h" | 5 #include "chrome/browser/extensions/extension_storage_monitor.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 433 |
| 434 gfx::Image notification_image(image); | 434 gfx::Image notification_image(image); |
| 435 if (notification_image.IsEmpty()) { | 435 if (notification_image.IsEmpty()) { |
| 436 notification_image = | 436 notification_image = |
| 437 extension->is_app() ? gfx::Image(util::GetDefaultAppIcon()) | 437 extension->is_app() ? gfx::Image(util::GetDefaultAppIcon()) |
| 438 : gfx::Image(util::GetDefaultExtensionIcon()); | 438 : gfx::Image(util::GetDefaultExtensionIcon()); |
| 439 } | 439 } |
| 440 | 440 |
| 441 scoped_ptr<message_center::Notification> notification; | 441 scoped_ptr<message_center::Notification> notification; |
| 442 notification.reset(new message_center::Notification( | 442 notification.reset(new message_center::Notification( |
| 443 message_center::NOTIFICATION_TYPE_SIMPLE, | 443 message_center::NOTIFICATION_TYPE_SIMPLE, notification_id, |
| 444 notification_id, | |
| 445 l10n_util::GetStringUTF16(IDS_EXTENSION_STORAGE_MONITOR_TITLE), | 444 l10n_util::GetStringUTF16(IDS_EXTENSION_STORAGE_MONITOR_TITLE), |
| 446 l10n_util::GetStringFUTF16( | 445 l10n_util::GetStringFUTF16(IDS_EXTENSION_STORAGE_MONITOR_TEXT, |
| 447 IDS_EXTENSION_STORAGE_MONITOR_TEXT, | 446 base::UTF8ToUTF16(extension->name()), |
| 448 base::UTF8ToUTF16(extension->name()), | 447 base::IntToString16(current_usage / kMBytes)), |
| 449 base::IntToString16(current_usage / kMBytes)), | 448 notification_image, base::string16() /* display source */, GURL(), |
| 450 notification_image, | 449 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
| 451 base::string16() /* display source */, | 450 kSystemNotifierId), |
| 452 message_center::NotifierId( | |
| 453 message_center::NotifierId::SYSTEM_COMPONENT, kSystemNotifierId), | |
| 454 notification_data, | 451 notification_data, |
| 455 new message_center::HandleNotificationButtonClickDelegate(base::Bind( | 452 new message_center::HandleNotificationButtonClickDelegate( |
| 456 &ExtensionStorageMonitor::OnNotificationButtonClick, | 453 base::Bind(&ExtensionStorageMonitor::OnNotificationButtonClick, |
| 457 weak_ptr_factory_.GetWeakPtr(), | 454 weak_ptr_factory_.GetWeakPtr(), extension_id)))); |
| 458 extension_id)))); | |
| 459 notification->SetSystemPriority(); | 455 notification->SetSystemPriority(); |
| 460 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 456 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); |
| 461 | 457 |
| 462 notified_extension_ids_.insert(extension_id); | 458 notified_extension_ids_.insert(extension_id); |
| 463 } | 459 } |
| 464 | 460 |
| 465 void ExtensionStorageMonitor::OnNotificationButtonClick( | 461 void ExtensionStorageMonitor::OnNotificationButtonClick( |
| 466 const std::string& extension_id, int button_index) { | 462 const std::string& extension_id, int button_index) { |
| 467 switch (button_index) { | 463 switch (button_index) { |
| 468 case BUTTON_DISABLE_NOTIFICATION: { | 464 case BUTTON_DISABLE_NOTIFICATION: { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 void ExtensionStorageMonitor::SetStorageNotificationEnabled( | 663 void ExtensionStorageMonitor::SetStorageNotificationEnabled( |
| 668 const std::string& extension_id, | 664 const std::string& extension_id, |
| 669 bool enable_notifications) { | 665 bool enable_notifications) { |
| 670 extension_prefs_->UpdateExtensionPref( | 666 extension_prefs_->UpdateExtensionPref( |
| 671 extension_id, | 667 extension_id, |
| 672 kPrefDisableStorageNotifications, | 668 kPrefDisableStorageNotifications, |
| 673 enable_notifications ? NULL : new base::FundamentalValue(true)); | 669 enable_notifications ? NULL : new base::FundamentalValue(true)); |
| 674 } | 670 } |
| 675 | 671 |
| 676 } // namespace extensions | 672 } // namespace extensions |
| OLD | NEW |