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

Side by Side Diff: chrome/browser/extensions/extension_storage_monitor.cc

Issue 314113010: Remove deprecated permissions functions from Extension (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
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/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_storage_monitor_factory.h" 14 #include "chrome/browser/extensions/extension_storage_monitor_factory.h"
15 #include "chrome/browser/extensions/extension_util.h" 15 #include "chrome/browser/extensions/extension_util.h"
16 #include "chrome/browser/extensions/image_loader.h" 16 #include "chrome/browser/extensions/image_loader.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 18 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
19 #include "content/public/browser/browser_context.h" 19 #include "content/public/browser/browser_context.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/notification_details.h" 21 #include "content/public/browser/notification_details.h"
22 #include "content/public/browser/notification_source.h" 22 #include "content/public/browser/notification_source.h"
23 #include "content/public/browser/storage_partition.h" 23 #include "content/public/browser/storage_partition.h"
24 #include "extensions/browser/extension_prefs.h" 24 #include "extensions/browser/extension_prefs.h"
25 #include "extensions/browser/extension_registry.h" 25 #include "extensions/browser/extension_registry.h"
26 #include "extensions/browser/extension_system.h" 26 #include "extensions/browser/extension_system.h"
27 #include "extensions/common/extension.h" 27 #include "extensions/common/extension.h"
28 #include "extensions/common/manifest_handlers/icons_handler.h" 28 #include "extensions/common/manifest_handlers/icons_handler.h"
29 #include "extensions/common/permissions/permissions_data.h"
29 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
30 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
31 #include "ui/message_center/message_center.h" 32 #include "ui/message_center/message_center.h"
32 #include "ui/message_center/notifier_settings.h" 33 #include "ui/message_center/notifier_settings.h"
33 #include "ui/message_center/views/constants.h" 34 #include "ui/message_center/views/constants.h"
34 #include "webkit/browser/quota/quota_manager.h" 35 #include "webkit/browser/quota/quota_manager.h"
35 #include "webkit/browser/quota/storage_observer.h" 36 #include "webkit/browser/quota/storage_observer.h"
36 37
37 using content::BrowserThread; 38 using content::BrowserThread;
38 39
(...skipping 23 matching lines...) Expand all
62 // set until the extension/app reaches the initial threshold. 63 // set until the extension/app reaches the initial threshold.
63 const char kPrefNextStorageThreshold[] = "next_storage_threshold"; 64 const char kPrefNextStorageThreshold[] = "next_storage_threshold";
64 65
65 // If this preference is set to true, notifications will be suppressed when an 66 // If this preference is set to true, notifications will be suppressed when an
66 // extension or app consumes excessive disk space. 67 // extension or app consumes excessive disk space.
67 const char kPrefDisableStorageNotifications[] = "disable_storage_notifications"; 68 const char kPrefDisableStorageNotifications[] = "disable_storage_notifications";
68 69
69 bool ShouldMonitorStorageFor(const Extension* extension) { 70 bool ShouldMonitorStorageFor(const Extension* extension) {
70 // Only monitor storage for extensions that are granted unlimited storage. 71 // Only monitor storage for extensions that are granted unlimited storage.
71 // Do not monitor storage for component extensions. 72 // Do not monitor storage for component extensions.
72 return extension->HasAPIPermission(APIPermission::kUnlimitedStorage) && 73 return extension->permissions_data()->HasAPIPermission(
74 APIPermission::kUnlimitedStorage) &&
73 extension->location() != Manifest::COMPONENT; 75 extension->location() != Manifest::COMPONENT;
74 } 76 }
75 77
76 const Extension* GetExtensionById(content::BrowserContext* context, 78 const Extension* GetExtensionById(content::BrowserContext* context,
77 const std::string& extension_id) { 79 const std::string& extension_id) {
78 return ExtensionRegistry::Get(context)->GetExtensionById( 80 return ExtensionRegistry::Get(context)->GetExtensionById(
79 extension_id, ExtensionRegistry::EVERYTHING); 81 extension_id, ExtensionRegistry::EVERYTHING);
80 } 82 }
81 83
82 } // namespace 84 } // namespace
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 void ExtensionStorageMonitor::SetStorageNotificationEnabled( 606 void ExtensionStorageMonitor::SetStorageNotificationEnabled(
605 const std::string& extension_id, 607 const std::string& extension_id,
606 bool enable_notifications) { 608 bool enable_notifications) {
607 extension_prefs_->UpdateExtensionPref( 609 extension_prefs_->UpdateExtensionPref(
608 extension_id, 610 extension_id,
609 kPrefDisableStorageNotifications, 611 kPrefDisableStorageNotifications,
610 enable_notifications ? NULL : new base::FundamentalValue(true)); 612 enable_notifications ? NULL : new base::FundamentalValue(true));
611 } 613 }
612 614
613 } // namespace extensions 615 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_special_storage_policy.cc ('k') | chrome/browser/extensions/extension_tab_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698