OLD | NEW |
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 "chrome/browser/ui/webui/options/cookies_view_handler.h" | 5 #include "chrome/browser/ui/webui/options/cookies_view_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 13 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
| 14 #include "chrome/browser/browsing_data/browsing_data_cache_storage_helper.h" |
14 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" |
15 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
16 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
17 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 18 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
18 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" | 19 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" |
19 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 20 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
20 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 21 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
21 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h" | 22 #include "chrome/browser/browsing_data/browsing_data_quota_helper.h" |
22 #include "chrome/browser/browsing_data/browsing_data_service_worker_helper.h" | 23 #include "chrome/browser/browsing_data/browsing_data_service_worker_helper.h" |
23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
(...skipping 17 matching lines...) Expand all Loading... |
41 } | 42 } |
42 | 43 |
43 CookiesViewHandler::~CookiesViewHandler() { | 44 CookiesViewHandler::~CookiesViewHandler() { |
44 } | 45 } |
45 | 46 |
46 void CookiesViewHandler::GetLocalizedValues( | 47 void CookiesViewHandler::GetLocalizedValues( |
47 base::DictionaryValue* localized_strings) { | 48 base::DictionaryValue* localized_strings) { |
48 DCHECK(localized_strings); | 49 DCHECK(localized_strings); |
49 | 50 |
50 static OptionsStringResource resources[] = { | 51 static OptionsStringResource resources[] = { |
51 { "label_cookie_name", IDS_COOKIES_COOKIE_NAME_LABEL }, | 52 {"label_cookie_name", IDS_COOKIES_COOKIE_NAME_LABEL}, |
52 { "label_cookie_content", IDS_COOKIES_COOKIE_CONTENT_LABEL }, | 53 {"label_cookie_content", IDS_COOKIES_COOKIE_CONTENT_LABEL}, |
53 { "label_cookie_domain", IDS_COOKIES_COOKIE_DOMAIN_LABEL }, | 54 {"label_cookie_domain", IDS_COOKIES_COOKIE_DOMAIN_LABEL}, |
54 { "label_cookie_path", IDS_COOKIES_COOKIE_PATH_LABEL }, | 55 {"label_cookie_path", IDS_COOKIES_COOKIE_PATH_LABEL}, |
55 { "label_cookie_send_for", IDS_COOKIES_COOKIE_SENDFOR_LABEL }, | 56 {"label_cookie_send_for", IDS_COOKIES_COOKIE_SENDFOR_LABEL}, |
56 { "label_cookie_accessible_to_script", | 57 {"label_cookie_accessible_to_script", |
57 IDS_COOKIES_COOKIE_ACCESSIBLE_TO_SCRIPT_LABEL }, | 58 IDS_COOKIES_COOKIE_ACCESSIBLE_TO_SCRIPT_LABEL}, |
58 { "label_cookie_created", IDS_COOKIES_COOKIE_CREATED_LABEL }, | 59 {"label_cookie_created", IDS_COOKIES_COOKIE_CREATED_LABEL}, |
59 { "label_cookie_expires", IDS_COOKIES_COOKIE_EXPIRES_LABEL }, | 60 {"label_cookie_expires", IDS_COOKIES_COOKIE_EXPIRES_LABEL}, |
60 { "label_webdb_desc", IDS_COOKIES_WEB_DATABASE_DESCRIPTION_LABEL }, | 61 {"label_webdb_desc", IDS_COOKIES_WEB_DATABASE_DESCRIPTION_LABEL}, |
61 { "label_local_storage_size", | 62 {"label_local_storage_size", |
62 IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL }, | 63 IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL}, |
63 { "label_local_storage_last_modified", | 64 {"label_local_storage_last_modified", |
64 IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL }, | 65 IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL}, |
65 { "label_local_storage_origin", IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL }, | 66 {"label_local_storage_origin", IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL}, |
66 { "label_indexed_db_size", IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL }, | 67 {"label_indexed_db_size", IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL}, |
67 { "label_indexed_db_last_modified", | 68 {"label_indexed_db_last_modified", |
68 IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL }, | 69 IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL}, |
69 { "label_indexed_db_origin", IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL }, | 70 {"label_indexed_db_origin", IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL}, |
70 { "label_service_worker_origin", IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL }, | 71 {"label_service_worker_origin", IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL}, |
71 { "label_service_worker_size", | 72 {"label_service_worker_size", |
72 IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL }, | 73 IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL}, |
73 { "label_service_worker_scopes", IDS_COOKIES_SERVICE_WORKER_SCOPES_LABEL }, | 74 {"label_service_worker_scopes", IDS_COOKIES_SERVICE_WORKER_SCOPES_LABEL}, |
74 { "label_app_cache_manifest", | 75 {"label_cache_storage_origin", IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL}, |
75 IDS_COOKIES_APPLICATION_CACHE_MANIFEST_LABEL }, | 76 {"label_cache_storage_size", |
76 { "label_cookie_last_accessed", IDS_COOKIES_LAST_ACCESSED_LABEL }, | 77 IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL}, |
77 { "cookie_domain", IDS_COOKIES_DOMAIN_COLUMN_HEADER }, | 78 {"label_cache_storage_last_modified", |
78 { "cookie_local_data", IDS_COOKIES_DATA_COLUMN_HEADER }, | 79 IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL}, |
79 { "cookie_singular", IDS_COOKIES_SINGLE_COOKIE }, | 80 {"label_app_cache_manifest", |
80 { "cookie_plural", IDS_COOKIES_PLURAL_COOKIES }, | 81 IDS_COOKIES_APPLICATION_CACHE_MANIFEST_LABEL}, |
81 { "cookie_database_storage", IDS_COOKIES_DATABASE_STORAGE }, | 82 {"label_cookie_last_accessed", IDS_COOKIES_LAST_ACCESSED_LABEL}, |
82 { "cookie_indexed_db", IDS_COOKIES_INDEXED_DB }, | 83 {"cookie_domain", IDS_COOKIES_DOMAIN_COLUMN_HEADER}, |
83 { "cookie_local_storage", IDS_COOKIES_LOCAL_STORAGE }, | 84 {"cookie_local_data", IDS_COOKIES_DATA_COLUMN_HEADER}, |
84 { "cookie_app_cache", IDS_COOKIES_APPLICATION_CACHE }, | 85 {"cookie_singular", IDS_COOKIES_SINGLE_COOKIE}, |
85 { "cookie_service_worker", IDS_COOKIES_SERVICE_WORKER }, | 86 {"cookie_plural", IDS_COOKIES_PLURAL_COOKIES}, |
86 { "cookie_flash_lso", IDS_COOKIES_FLASH_LSO }, | 87 {"cookie_database_storage", IDS_COOKIES_DATABASE_STORAGE}, |
87 { "search_cookies", IDS_COOKIES_SEARCH_COOKIES }, | 88 {"cookie_indexed_db", IDS_COOKIES_INDEXED_DB}, |
88 { "remove_cookie", IDS_COOKIES_REMOVE_LABEL }, | 89 {"cookie_local_storage", IDS_COOKIES_LOCAL_STORAGE}, |
89 { "remove_all_cookie", IDS_COOKIES_REMOVE_ALL_LABEL }, | 90 {"cookie_app_cache", IDS_COOKIES_APPLICATION_CACHE}, |
90 { "remove_all_shown_cookie", IDS_COOKIES_REMOVE_ALL_SHOWN_LABEL }, | 91 {"cookie_service_worker", IDS_COOKIES_SERVICE_WORKER}, |
91 { "cookie_file_system", IDS_COOKIES_FILE_SYSTEM }, | 92 {"cookie_cache_storage", IDS_COOKIES_CACHE_STORAGE}, |
92 { "label_file_system_origin", IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL }, | 93 {"cookie_flash_lso", IDS_COOKIES_FLASH_LSO}, |
93 { "label_file_system_temporary_usage", | 94 {"search_cookies", IDS_COOKIES_SEARCH_COOKIES}, |
94 IDS_COOKIES_FILE_SYSTEM_TEMPORARY_USAGE_LABEL }, | 95 {"remove_cookie", IDS_COOKIES_REMOVE_LABEL}, |
95 { "label_file_system_persistent_usage", | 96 {"remove_all_cookie", IDS_COOKIES_REMOVE_ALL_LABEL}, |
96 IDS_COOKIES_FILE_SYSTEM_PERSISTENT_USAGE_LABEL }, | 97 {"remove_all_shown_cookie", IDS_COOKIES_REMOVE_ALL_SHOWN_LABEL}, |
97 { "cookie_channel_id", IDS_COOKIES_CHANNEL_ID }, | 98 {"cookie_file_system", IDS_COOKIES_FILE_SYSTEM}, |
98 { "label_channel_id_server_id", | 99 {"label_file_system_origin", IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL}, |
99 IDS_COOKIES_CHANNEL_ID_ORIGIN_LABEL }, | 100 {"label_file_system_temporary_usage", |
100 { "label_channel_id_type", | 101 IDS_COOKIES_FILE_SYSTEM_TEMPORARY_USAGE_LABEL}, |
101 IDS_COOKIES_CHANNEL_ID_TYPE_LABEL }, | 102 {"label_file_system_persistent_usage", |
102 { "label_channel_id_created", | 103 IDS_COOKIES_FILE_SYSTEM_PERSISTENT_USAGE_LABEL}, |
103 IDS_COOKIES_CHANNEL_ID_CREATED_LABEL }, | 104 {"cookie_channel_id", IDS_COOKIES_CHANNEL_ID}, |
104 { "label_channel_id_expires", | 105 {"label_channel_id_server_id", IDS_COOKIES_CHANNEL_ID_ORIGIN_LABEL}, |
105 IDS_COOKIES_CHANNEL_ID_EXPIRES_LABEL }, | 106 {"label_channel_id_type", IDS_COOKIES_CHANNEL_ID_TYPE_LABEL}, |
106 { "label_protected_by_apps", | 107 {"label_channel_id_created", IDS_COOKIES_CHANNEL_ID_CREATED_LABEL}, |
107 IDS_GEOLOCATION_SET_BY_HOVER }, // TODO(bauerb): Use a better string | 108 {"label_channel_id_expires", IDS_COOKIES_CHANNEL_ID_EXPIRES_LABEL}, |
| 109 {"label_protected_by_apps", |
| 110 IDS_GEOLOCATION_SET_BY_HOVER}, // TODO(bauerb): Use a better string |
108 }; | 111 }; |
109 | 112 |
110 RegisterStrings(localized_strings, resources, arraysize(resources)); | 113 RegisterStrings(localized_strings, resources, arraysize(resources)); |
111 RegisterTitle(localized_strings, "cookiesViewPage", | 114 RegisterTitle(localized_strings, "cookiesViewPage", |
112 IDS_COOKIES_WEBSITE_PERMISSIONS_WINDOW_TITLE); | 115 IDS_COOKIES_WEBSITE_PERMISSIONS_WINDOW_TITLE); |
113 } | 116 } |
114 | 117 |
115 void CookiesViewHandler::RegisterMessages() { | 118 void CookiesViewHandler::RegisterMessages() { |
116 web_ui()->RegisterMessageCallback("updateCookieSearchResults", | 119 web_ui()->RegisterMessageCallback("updateCookieSearchResults", |
117 base::Bind(&CookiesViewHandler::UpdateSearchResults, | 120 base::Bind(&CookiesViewHandler::UpdateSearchResults, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 191 |
189 void CookiesViewHandler::EnsureCookiesTreeModelCreated() { | 192 void CookiesViewHandler::EnsureCookiesTreeModelCreated() { |
190 if (!cookies_tree_model_.get()) { | 193 if (!cookies_tree_model_.get()) { |
191 Profile* profile = Profile::FromWebUI(web_ui()); | 194 Profile* profile = Profile::FromWebUI(web_ui()); |
192 content::StoragePartition* storage_partition = | 195 content::StoragePartition* storage_partition = |
193 content::BrowserContext::GetDefaultStoragePartition(profile); | 196 content::BrowserContext::GetDefaultStoragePartition(profile); |
194 content::IndexedDBContext* indexed_db_context = | 197 content::IndexedDBContext* indexed_db_context = |
195 storage_partition->GetIndexedDBContext(); | 198 storage_partition->GetIndexedDBContext(); |
196 content::ServiceWorkerContext* service_worker_context = | 199 content::ServiceWorkerContext* service_worker_context = |
197 storage_partition->GetServiceWorkerContext(); | 200 storage_partition->GetServiceWorkerContext(); |
| 201 content::CacheStorageContext* cache_storage_context = |
| 202 storage_partition->GetCacheStorageContext(); |
198 storage::FileSystemContext* file_system_context = | 203 storage::FileSystemContext* file_system_context = |
199 storage_partition->GetFileSystemContext(); | 204 storage_partition->GetFileSystemContext(); |
200 LocalDataContainer* container = new LocalDataContainer( | 205 LocalDataContainer* container = new LocalDataContainer( |
201 new BrowsingDataCookieHelper(profile->GetRequestContext()), | 206 new BrowsingDataCookieHelper(profile->GetRequestContext()), |
202 new BrowsingDataDatabaseHelper(profile), | 207 new BrowsingDataDatabaseHelper(profile), |
203 new BrowsingDataLocalStorageHelper(profile), | 208 new BrowsingDataLocalStorageHelper(profile), NULL, |
204 NULL, | |
205 new BrowsingDataAppCacheHelper(profile), | 209 new BrowsingDataAppCacheHelper(profile), |
206 new BrowsingDataIndexedDBHelper(indexed_db_context), | 210 new BrowsingDataIndexedDBHelper(indexed_db_context), |
207 BrowsingDataFileSystemHelper::Create(file_system_context), | 211 BrowsingDataFileSystemHelper::Create(file_system_context), |
208 BrowsingDataQuotaHelper::Create(profile), | 212 BrowsingDataQuotaHelper::Create(profile), |
209 BrowsingDataChannelIDHelper::Create(profile->GetRequestContext()), | 213 BrowsingDataChannelIDHelper::Create(profile->GetRequestContext()), |
210 new BrowsingDataServiceWorkerHelper(service_worker_context), | 214 new BrowsingDataServiceWorkerHelper(service_worker_context), |
| 215 new BrowsingDataCacheStorageHelper(cache_storage_context), |
211 BrowsingDataFlashLSOHelper::Create(profile)); | 216 BrowsingDataFlashLSOHelper::Create(profile)); |
212 cookies_tree_model_.reset( | 217 cookies_tree_model_.reset( |
213 new CookiesTreeModel(container, | 218 new CookiesTreeModel(container, |
214 profile->GetExtensionSpecialStoragePolicy(), | 219 profile->GetExtensionSpecialStoragePolicy(), |
215 false)); | 220 false)); |
216 cookies_tree_model_->AddCookiesTreeObserver(this); | 221 cookies_tree_model_->AddCookiesTreeObserver(this); |
217 } | 222 } |
218 } | 223 } |
219 | 224 |
220 void CookiesViewHandler::UpdateSearchResults(const base::ListValue* args) { | 225 void CookiesViewHandler::UpdateSearchResults(const base::ListValue* args) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 web_ui()->CallJavascriptFunction("CookiesView.loadChildren", args); | 278 web_ui()->CallJavascriptFunction("CookiesView.loadChildren", args); |
274 } | 279 } |
275 | 280 |
276 void CookiesViewHandler::ReloadCookies(const base::ListValue* args) { | 281 void CookiesViewHandler::ReloadCookies(const base::ListValue* args) { |
277 cookies_tree_model_.reset(); | 282 cookies_tree_model_.reset(); |
278 | 283 |
279 EnsureCookiesTreeModelCreated(); | 284 EnsureCookiesTreeModelCreated(); |
280 } | 285 } |
281 | 286 |
282 } // namespace options | 287 } // namespace options |
OLD | NEW |