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 #include <utility> |
8 | 9 |
9 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/extensions/extension_storage_monitor_factory.h" | 16 #include "chrome/browser/extensions/extension_storage_monitor_factory.h" |
16 #include "chrome/browser/extensions/extension_util.h" | 17 #include "chrome/browser/extensions/extension_util.h" |
17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 base::UTF8ToUTF16(extension->name()), | 441 base::UTF8ToUTF16(extension->name()), |
441 base::Int64ToString16(current_usage / kMBytes)), | 442 base::Int64ToString16(current_usage / kMBytes)), |
442 notification_image, base::string16() /* display source */, GURL(), | 443 notification_image, base::string16() /* display source */, GURL(), |
443 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, | 444 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
444 kSystemNotifierId), | 445 kSystemNotifierId), |
445 notification_data, | 446 notification_data, |
446 new message_center::HandleNotificationButtonClickDelegate( | 447 new message_center::HandleNotificationButtonClickDelegate( |
447 base::Bind(&ExtensionStorageMonitor::OnNotificationButtonClick, | 448 base::Bind(&ExtensionStorageMonitor::OnNotificationButtonClick, |
448 weak_ptr_factory_.GetWeakPtr(), extension_id)))); | 449 weak_ptr_factory_.GetWeakPtr(), extension_id)))); |
449 notification->SetSystemPriority(); | 450 notification->SetSystemPriority(); |
450 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 451 message_center::MessageCenter::Get()->AddNotification( |
| 452 std::move(notification)); |
451 | 453 |
452 notified_extension_ids_.insert(extension_id); | 454 notified_extension_ids_.insert(extension_id); |
453 } | 455 } |
454 | 456 |
455 void ExtensionStorageMonitor::OnNotificationButtonClick( | 457 void ExtensionStorageMonitor::OnNotificationButtonClick( |
456 const std::string& extension_id, int button_index) { | 458 const std::string& extension_id, int button_index) { |
457 switch (button_index) { | 459 switch (button_index) { |
458 case BUTTON_DISABLE_NOTIFICATION: { | 460 case BUTTON_DISABLE_NOTIFICATION: { |
459 DisableStorageMonitoring(extension_id); | 461 DisableStorageMonitoring(extension_id); |
460 break; | 462 break; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 void ExtensionStorageMonitor::SetStorageNotificationEnabled( | 653 void ExtensionStorageMonitor::SetStorageNotificationEnabled( |
652 const std::string& extension_id, | 654 const std::string& extension_id, |
653 bool enable_notifications) { | 655 bool enable_notifications) { |
654 extension_prefs_->UpdateExtensionPref( | 656 extension_prefs_->UpdateExtensionPref( |
655 extension_id, | 657 extension_id, |
656 kPrefDisableStorageNotifications, | 658 kPrefDisableStorageNotifications, |
657 enable_notifications ? NULL : new base::FundamentalValue(true)); | 659 enable_notifications ? NULL : new base::FundamentalValue(true)); |
658 } | 660 } |
659 | 661 |
660 } // namespace extensions | 662 } // namespace extensions |
OLD | NEW |