Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Defines the Chrome Extensions Clear API functions, which entail | 5 // Defines the Chrome Extensions Clear API functions, which entail |
| 6 // clearing browsing data, and clearing the browser's cache (which, let's be | 6 // clearing browsing data, and clearing the browser's cache (which, let's be |
| 7 // honest, are the same thing), as specified in | 7 // honest, are the same thing), as specified in |
| 8 // chrome/common/extensions/api/extension_api.json. | 8 // chrome/common/extensions/api/extension_api.json. |
| 9 | 9 |
| 10 #include "chrome/browser/extensions/extension_clear_api.h" | 10 #include "chrome/browser/extensions/extension_clear_api.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 if (!dict->GetBoolean(key, &value)) | 52 if (!dict->GetBoolean(key, &value)) |
| 53 return false; | 53 return false; |
| 54 else | 54 else |
| 55 return value; | 55 return value; |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Convert the JavaScript API's object input ({ cookies: true }) into the | 58 // Convert the JavaScript API's object input ({ cookies: true }) into the |
| 59 // appropriate removal mask for the BrowsingDataRemover object. | 59 // appropriate removal mask for the BrowsingDataRemover object. |
| 60 int ParseRemovalMask(base::DictionaryValue* value) { | 60 int ParseRemovalMask(base::DictionaryValue* value) { |
| 61 int GetRemovalMask = 0; | 61 int GetRemovalMask = 0; |
| 62 if (DataRemovalRequested(value, keys::kAppCacheKey)) | |
| 63 GetRemovalMask |= BrowsingDataRemover::REMOVE_APPCACHE; | |
| 62 if (DataRemovalRequested(value, keys::kCacheKey)) | 64 if (DataRemovalRequested(value, keys::kCacheKey)) |
| 63 GetRemovalMask |= BrowsingDataRemover::REMOVE_CACHE; | 65 GetRemovalMask |= BrowsingDataRemover::REMOVE_CACHE; |
| 66 if (DataRemovalRequested(value, keys::kCookiesKey)) | |
| 67 GetRemovalMask |= BrowsingDataRemover::REMOVE_COOKIES; | |
| 64 if (DataRemovalRequested(value, keys::kDownloadsKey)) | 68 if (DataRemovalRequested(value, keys::kDownloadsKey)) |
| 65 GetRemovalMask |= BrowsingDataRemover::REMOVE_DOWNLOADS; | 69 GetRemovalMask |= BrowsingDataRemover::REMOVE_DOWNLOADS; |
| 70 if (DataRemovalRequested(value, keys::kPasswordsKey)) | |
| 71 GetRemovalMask |= BrowsingDataRemover::REMOVE_FILE_SYSTEMS; | |
| 66 if (DataRemovalRequested(value, keys::kFormDataKey)) | 72 if (DataRemovalRequested(value, keys::kFormDataKey)) |
| 67 GetRemovalMask |= BrowsingDataRemover::REMOVE_FORM_DATA; | 73 GetRemovalMask |= BrowsingDataRemover::REMOVE_FORM_DATA; |
| 68 if (DataRemovalRequested(value, keys::kHistoryKey)) | 74 if (DataRemovalRequested(value, keys::kHistoryKey)) |
| 69 GetRemovalMask |= BrowsingDataRemover::REMOVE_HISTORY; | 75 GetRemovalMask |= BrowsingDataRemover::REMOVE_HISTORY; |
| 70 if (DataRemovalRequested(value, keys::kPasswordsKey)) | 76 if (DataRemovalRequested(value, keys::kPasswordsKey)) |
| 77 GetRemovalMask |= BrowsingDataRemover::REMOVE_INDEXEDDB; | |
| 78 if (DataRemovalRequested(value, keys::kPasswordsKey)) | |
| 79 GetRemovalMask |= BrowsingDataRemover::REMOVE_LOCAL_STORAGE; | |
| 80 if (DataRemovalRequested(value, keys::kPasswordsKey)) | |
| 81 GetRemovalMask |= BrowsingDataRemover::REMOVE_LSO_DATA; | |
| 82 if (DataRemovalRequested(value, keys::kPasswordsKey)) | |
| 71 GetRemovalMask |= BrowsingDataRemover::REMOVE_PASSWORDS; | 83 GetRemovalMask |= BrowsingDataRemover::REMOVE_PASSWORDS; |
| 72 | 84 if (DataRemovalRequested(value, keys::kPasswordsKey)) |
| 73 // When we talk users about "cookies", we mean not just cookies, but pretty | 85 GetRemovalMask |= BrowsingDataRemover::REMOVE_WEBSQL; |
| 74 // much everything associated with an origin. | |
| 75 if (DataRemovalRequested(value, keys::kCookiesKey)) | |
| 76 GetRemovalMask |= BrowsingDataRemover::REMOVE_SITE_DATA; | |
| 77 | 86 |
| 78 return GetRemovalMask; | 87 return GetRemovalMask; |
| 79 } | 88 } |
| 80 | 89 |
| 81 } // Namespace. | 90 } // Namespace. |
| 82 | 91 |
| 83 void BrowsingDataExtensionFunction::OnBrowsingDataRemoverDone() { | 92 void BrowsingDataExtensionFunction::OnBrowsingDataRemoverDone() { |
| 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 85 this->SendResponse(true); | 94 this->SendResponse(true); |
| 86 | 95 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 117 | 126 |
| 118 int ClearBrowsingDataFunction::GetRemovalMask() const { | 127 int ClearBrowsingDataFunction::GetRemovalMask() const { |
| 119 // Parse the |dataToRemove| argument to generate the removal mask. | 128 // Parse the |dataToRemove| argument to generate the removal mask. |
| 120 base::DictionaryValue* data_to_remove; | 129 base::DictionaryValue* data_to_remove; |
| 121 if (args_->GetDictionary(1, &data_to_remove)) | 130 if (args_->GetDictionary(1, &data_to_remove)) |
| 122 return ParseRemovalMask(data_to_remove); | 131 return ParseRemovalMask(data_to_remove); |
| 123 else | 132 else |
| 124 return 0; | 133 return 0; |
| 125 } | 134 } |
| 126 | 135 |
| 136 int ClearAppCacheFunction::GetRemovalMask() const { | |
| 137 return BrowsingDataRemover::REMOVE_APPCACHE; | |
|
Aaron Boodman
2011/10/13 02:19:19
Idea: Did you know that you can get the function n
Mike West
2011/12/13 11:27:23
This is a good idea, but I'd like to do it in a se
| |
| 138 } | |
| 139 | |
| 127 int ClearCacheFunction::GetRemovalMask() const { | 140 int ClearCacheFunction::GetRemovalMask() const { |
| 128 return BrowsingDataRemover::REMOVE_CACHE; | 141 return BrowsingDataRemover::REMOVE_CACHE; |
| 129 } | 142 } |
| 130 | 143 |
| 131 int ClearCookiesFunction::GetRemovalMask() const { | 144 int ClearCookiesFunction::GetRemovalMask() const { |
| 132 return BrowsingDataRemover::REMOVE_SITE_DATA; | 145 return BrowsingDataRemover::REMOVE_COOKIES; |
| 133 } | 146 } |
| 134 | 147 |
| 135 int ClearDownloadsFunction::GetRemovalMask() const { | 148 int ClearDownloadsFunction::GetRemovalMask() const { |
| 136 return BrowsingDataRemover::REMOVE_DOWNLOADS; | 149 return BrowsingDataRemover::REMOVE_DOWNLOADS; |
| 137 } | 150 } |
| 138 | 151 |
| 152 int ClearFileSystemsFunction::GetRemovalMask() const { | |
| 153 return BrowsingDataRemover::REMOVE_FILE_SYSTEMS; | |
| 154 } | |
| 155 | |
| 139 int ClearFormDataFunction::GetRemovalMask() const { | 156 int ClearFormDataFunction::GetRemovalMask() const { |
| 140 return BrowsingDataRemover::REMOVE_FORM_DATA; | 157 return BrowsingDataRemover::REMOVE_FORM_DATA; |
| 141 } | 158 } |
| 142 | 159 |
| 143 int ClearHistoryFunction::GetRemovalMask() const { | 160 int ClearHistoryFunction::GetRemovalMask() const { |
| 144 return BrowsingDataRemover::REMOVE_HISTORY; | 161 return BrowsingDataRemover::REMOVE_HISTORY; |
| 145 } | 162 } |
| 146 | 163 |
| 164 int ClearIndexedDBFunction::GetRemovalMask() const { | |
| 165 return BrowsingDataRemover::REMOVE_INDEXEDDB; | |
| 166 } | |
| 167 | |
| 168 int ClearLocalStorageFunction::GetRemovalMask() const { | |
| 169 return BrowsingDataRemover::REMOVE_LOCAL_STORAGE; | |
| 170 } | |
| 171 | |
| 172 int ClearLSODataFunction::GetRemovalMask() const { | |
| 173 return BrowsingDataRemover::REMOVE_LSO_DATA; | |
| 174 } | |
| 175 | |
| 147 int ClearPasswordsFunction::GetRemovalMask() const { | 176 int ClearPasswordsFunction::GetRemovalMask() const { |
| 148 return BrowsingDataRemover::REMOVE_CACHE; | 177 return BrowsingDataRemover::REMOVE_PASSWORDS; |
| 149 } | 178 } |
| 179 | |
| 180 int ClearWebSQLFunction::GetRemovalMask() const { | |
| 181 return BrowsingDataRemover::REMOVE_WEBSQL; | |
| 182 } | |
| OLD | NEW |