| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_STORAGE_MANAGER_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_STORAGE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_STORAGE_MANAGER_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_STORAGE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "chrome/browser/browsing_data/site_data_size_collector.h" | 15 #include "chrome/browser/browsing_data/site_data_size_collector.h" |
| 16 #include "chrome/browser/ui/webui/options/options_ui.h" | 16 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" |
| 17 #include "components/arc/storage_manager/arc_storage_manager.h" | 17 #include "components/arc/storage_manager/arc_storage_manager.h" |
| 18 #include "components/user_manager/user.h" | 18 #include "components/user_manager/user.h" |
| 19 | 19 |
| 20 namespace chromeos { | 20 namespace chromeos { |
| 21 namespace options { | 21 namespace settings { |
| 22 | 22 |
| 23 // Storage manager overlay page UI handler. | 23 class StorageHandler : public ::settings::SettingsPageUIHandler { |
| 24 class StorageManagerHandler : public ::options::OptionsPageUIHandler { | |
| 25 public: | 24 public: |
| 26 // Enumeration for device state about remaining space. These values must be | 25 // Enumeration for device state about remaining space. These values must be |
| 27 // kept in sync with options.StorageSpaceState in JS code. | 26 // kept in sync with settings.StorageSpaceState in JS code. |
| 28 enum StorageSpaceState { | 27 enum StorageSpaceState { |
| 29 STORAGE_SPACE_NORMAL = 0, | 28 STORAGE_SPACE_NORMAL = 0, |
| 30 STORAGE_SPACE_LOW = 1, | 29 STORAGE_SPACE_LOW = 1, |
| 31 STORAGE_SPACE_CRITICALLY_LOW = 2, | 30 STORAGE_SPACE_CRITICALLY_LOW = 2, |
| 32 }; | 31 }; |
| 33 | 32 |
| 34 StorageManagerHandler(); | 33 StorageHandler(); |
| 35 ~StorageManagerHandler() override; | 34 ~StorageHandler() override; |
| 36 | 35 |
| 37 // OptionsPageUIHandler implementation. | 36 // SettingsPageUIHandler implementation. |
| 38 void GetLocalizedValues(base::DictionaryValue* localized_strings) override; | |
| 39 void InitializePage() override; | |
| 40 | |
| 41 // WebUIMessageHandler implementation. | |
| 42 void RegisterMessages() override; | 37 void RegisterMessages() override; |
| 38 void OnJavascriptAllowed() override {} |
| 39 void OnJavascriptDisallowed() override {} |
| 43 | 40 |
| 44 private: | 41 private: |
| 45 // Handlers of JS messages. | 42 // Handlers of JS messages. |
| 46 void HandleUpdateStorageInfo(const base::ListValue* unused_args); | 43 void HandleUpdateStorageInfo(const base::ListValue* unused_args); |
| 47 void HandleOpenDownloads(const base::ListValue* unused_args); | 44 void HandleOpenDownloads(const base::ListValue* unused_args); |
| 48 void HandleOpenArcStorage(const base::ListValue* unused_args); | 45 void HandleOpenArcStorage(const base::ListValue* unused_args); |
| 49 void HandleClearDriveCache(const base::ListValue* unused_args); | 46 void HandleClearDriveCache(const base::ListValue* unused_args); |
| 50 | 47 |
| 51 // Requests updating disk space information. | 48 // Requests updating disk space information. |
| 52 void UpdateSizeStat(); | 49 void UpdateSizeStat(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 72 // Callback to update the UI about the size of browsing data. | 69 // Callback to update the UI about the size of browsing data. |
| 73 void OnGetBrowsingDataSize(bool is_site_data, int64_t size); | 70 void OnGetBrowsingDataSize(bool is_site_data, int64_t size); |
| 74 | 71 |
| 75 // Requests updating the total size of other users' data. | 72 // Requests updating the total size of other users' data. |
| 76 void UpdateOtherUsersSize(); | 73 void UpdateOtherUsersSize(); |
| 77 | 74 |
| 78 // Callback to save the fetched user sizes and update the UI. | 75 // Callback to save the fetched user sizes and update the UI. |
| 79 void OnGetOtherUserSize(bool success, int64_t size); | 76 void OnGetOtherUserSize(bool success, int64_t size); |
| 80 | 77 |
| 81 // Requests updating the space size used by Android apps and cache. | 78 // Requests updating the space size used by Android apps and cache. |
| 82 void UpdateArcSize(); | 79 void UpdateAndroidSize(); |
| 83 | 80 |
| 84 // Callback to update the UI about Android apps and cache. | 81 // Callback to update the UI about Android apps and cache. |
| 85 void OnGetArcSize(bool succeeded, arc::mojom::ApplicationsSizePtr size); | 82 void OnGetAndroidSize(bool succeeded, arc::mojom::ApplicationsSizePtr size); |
| 86 | 83 |
| 87 // Callback called when clearing Drive cache is done. | 84 // Callback called when clearing Drive cache is done. |
| 88 void OnClearDriveCacheDone(bool success); | 85 void OnClearDriveCacheDone(bool success); |
| 89 | 86 |
| 90 // Total size of cache data in browsing data. | 87 // Total size of cache data in browsing data. |
| 91 int64_t browser_cache_size_; | 88 int64_t browser_cache_size_; |
| 92 | 89 |
| 93 // True if we have already received the size of http cache. | 90 // True if we have already received the size of http cache. |
| 94 bool has_browser_cache_size_; | 91 bool has_browser_cache_size_; |
| 95 | 92 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 106 // Fetched sizes of user directories. | 103 // Fetched sizes of user directories. |
| 107 std::vector<int64_t> user_sizes_; | 104 std::vector<int64_t> user_sizes_; |
| 108 | 105 |
| 109 // Helper to compute the total size of all types of site date. | 106 // Helper to compute the total size of all types of site date. |
| 110 std::unique_ptr<SiteDataSizeCollector> site_data_size_collector_; | 107 std::unique_ptr<SiteDataSizeCollector> site_data_size_collector_; |
| 111 | 108 |
| 112 // Flags indicating fetch operations for storage sizes are ongoing. | 109 // Flags indicating fetch operations for storage sizes are ongoing. |
| 113 bool updating_downloads_size_; | 110 bool updating_downloads_size_; |
| 114 bool updating_drive_cache_size_; | 111 bool updating_drive_cache_size_; |
| 115 bool updating_browsing_data_size_; | 112 bool updating_browsing_data_size_; |
| 116 bool updating_arc_size_; | 113 bool updating_android_size_; |
| 117 bool updating_other_users_size_; | 114 bool updating_other_users_size_; |
| 118 | 115 |
| 119 base::WeakPtrFactory<StorageManagerHandler> weak_ptr_factory_; | 116 DISALLOW_COPY_AND_ASSIGN(StorageHandler); |
| 120 | |
| 121 DISALLOW_COPY_AND_ASSIGN(StorageManagerHandler); | |
| 122 }; | 117 }; |
| 123 | 118 |
| 124 } // namespace options | 119 } // namespace settings |
| 125 } // namespace chromeos | 120 } // namespace chromeos |
| 126 | 121 |
| 127 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_STORAGE_MANAGER_HANDLER_H_ | 122 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_STORAGE_HANDLER_H_ |
| OLD | NEW |