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 "extensions/browser/api/guest_view/web_view/web_view_internal_api.h" | 5 #include "extensions/browser/api/guest_view/web_view/web_view_internal_api.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 const char kFileSystemsKey[] = "fileSystems"; | 45 const char kFileSystemsKey[] = "fileSystems"; |
46 const char kIndexedDBKey[] = "indexedDB"; | 46 const char kIndexedDBKey[] = "indexedDB"; |
47 const char kLocalStorageKey[] = "localStorage"; | 47 const char kLocalStorageKey[] = "localStorage"; |
48 const char kWebSQLKey[] = "webSQL"; | 48 const char kWebSQLKey[] = "webSQL"; |
49 const char kSinceKey[] = "since"; | 49 const char kSinceKey[] = "since"; |
50 const char kLoadFileError[] = "Failed to load file: \"*\". "; | 50 const char kLoadFileError[] = "Failed to load file: \"*\". "; |
51 const char kViewInstanceIdError[] = "view_instance_id is missing."; | 51 const char kViewInstanceIdError[] = "view_instance_id is missing."; |
52 const char kDuplicatedContentScriptNamesError[] = | 52 const char kDuplicatedContentScriptNamesError[] = |
53 "The given content script name already exists."; | 53 "The given content script name already exists."; |
54 | 54 |
55 uint32 MaskForKey(const char* key) { | 55 uint32_t MaskForKey(const char* key) { |
56 if (strcmp(key, kAppCacheKey) == 0) | 56 if (strcmp(key, kAppCacheKey) == 0) |
57 return webview::WEB_VIEW_REMOVE_DATA_MASK_APPCACHE; | 57 return webview::WEB_VIEW_REMOVE_DATA_MASK_APPCACHE; |
58 if (strcmp(key, kCacheKey) == 0) | 58 if (strcmp(key, kCacheKey) == 0) |
59 return webview::WEB_VIEW_REMOVE_DATA_MASK_CACHE; | 59 return webview::WEB_VIEW_REMOVE_DATA_MASK_CACHE; |
60 if (strcmp(key, kCookiesKey) == 0) | 60 if (strcmp(key, kCookiesKey) == 0) |
61 return webview::WEB_VIEW_REMOVE_DATA_MASK_COOKIES; | 61 return webview::WEB_VIEW_REMOVE_DATA_MASK_COOKIES; |
62 if (strcmp(key, kFileSystemsKey) == 0) | 62 if (strcmp(key, kFileSystemsKey) == 0) |
63 return webview::WEB_VIEW_REMOVE_DATA_MASK_FILE_SYSTEMS; | 63 return webview::WEB_VIEW_REMOVE_DATA_MASK_FILE_SYSTEMS; |
64 if (strcmp(key, kIndexedDBKey) == 0) | 64 if (strcmp(key, kIndexedDBKey) == 0) |
65 return webview::WEB_VIEW_REMOVE_DATA_MASK_INDEXEDDB; | 65 return webview::WEB_VIEW_REMOVE_DATA_MASK_INDEXEDDB; |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 WebViewInternalClearDataFunction::WebViewInternalClearDataFunction() | 823 WebViewInternalClearDataFunction::WebViewInternalClearDataFunction() |
824 : remove_mask_(0), bad_message_(false) { | 824 : remove_mask_(0), bad_message_(false) { |
825 } | 825 } |
826 | 826 |
827 WebViewInternalClearDataFunction::~WebViewInternalClearDataFunction() { | 827 WebViewInternalClearDataFunction::~WebViewInternalClearDataFunction() { |
828 } | 828 } |
829 | 829 |
830 // Parses the |dataToRemove| argument to generate the remove mask. Sets | 830 // Parses the |dataToRemove| argument to generate the remove mask. Sets |
831 // |bad_message_| (like EXTENSION_FUNCTION_VALIDATE would if this were a bool | 831 // |bad_message_| (like EXTENSION_FUNCTION_VALIDATE would if this were a bool |
832 // method) if 'dataToRemove' is not present. | 832 // method) if 'dataToRemove' is not present. |
833 uint32 WebViewInternalClearDataFunction::GetRemovalMask() { | 833 uint32_t WebViewInternalClearDataFunction::GetRemovalMask() { |
834 base::DictionaryValue* data_to_remove; | 834 base::DictionaryValue* data_to_remove; |
835 if (!args_->GetDictionary(2, &data_to_remove)) { | 835 if (!args_->GetDictionary(2, &data_to_remove)) { |
836 bad_message_ = true; | 836 bad_message_ = true; |
837 return 0; | 837 return 0; |
838 } | 838 } |
839 | 839 |
840 uint32 remove_mask = 0; | 840 uint32_t remove_mask = 0; |
841 for (base::DictionaryValue::Iterator i(*data_to_remove); !i.IsAtEnd(); | 841 for (base::DictionaryValue::Iterator i(*data_to_remove); !i.IsAtEnd(); |
842 i.Advance()) { | 842 i.Advance()) { |
843 bool selected = false; | 843 bool selected = false; |
844 if (!i.value().GetAsBoolean(&selected)) { | 844 if (!i.value().GetAsBoolean(&selected)) { |
845 bad_message_ = true; | 845 bad_message_ = true; |
846 return 0; | 846 return 0; |
847 } | 847 } |
848 if (selected) | 848 if (selected) |
849 remove_mask |= MaskForKey(i.key().c_str()); | 849 remove_mask |= MaskForKey(i.key().c_str()); |
850 } | 850 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 // Will finish asynchronously. | 896 // Will finish asynchronously. |
897 return true; | 897 return true; |
898 } | 898 } |
899 | 899 |
900 void WebViewInternalClearDataFunction::ClearDataDone() { | 900 void WebViewInternalClearDataFunction::ClearDataDone() { |
901 Release(); // Balanced in RunAsync(). | 901 Release(); // Balanced in RunAsync(). |
902 SendResponse(true); | 902 SendResponse(true); |
903 } | 903 } |
904 | 904 |
905 } // namespace extensions | 905 } // namespace extensions |
OLD | NEW |