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

Side by Side Diff: extensions/browser/api/guest_view/web_view/web_view_internal_api.cc

Issue 1365563003: Prevent guest views from issuing a search for empty text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint Created 5 years, 2 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
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 "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 "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 27 matching lines...) Expand all
38 namespace { 38 namespace {
39 39
40 const char kAppCacheKey[] = "appcache"; 40 const char kAppCacheKey[] = "appcache";
41 const char kCacheKey[] = "cache"; 41 const char kCacheKey[] = "cache";
42 const char kCookiesKey[] = "cookies"; 42 const char kCookiesKey[] = "cookies";
43 const char kFileSystemsKey[] = "fileSystems"; 43 const char kFileSystemsKey[] = "fileSystems";
44 const char kIndexedDBKey[] = "indexedDB"; 44 const char kIndexedDBKey[] = "indexedDB";
45 const char kLocalStorageKey[] = "localStorage"; 45 const char kLocalStorageKey[] = "localStorage";
46 const char kWebSQLKey[] = "webSQL"; 46 const char kWebSQLKey[] = "webSQL";
47 const char kSinceKey[] = "since"; 47 const char kSinceKey[] = "since";
48
49 const char kDuplicatedContentScriptNamesError[] =
50 "The given content script name already exists.";
51 const char kEmptyFindTextError[] = "Find called with no text";
48 const char kLoadFileError[] = "Failed to load file: \"*\". "; 52 const char kLoadFileError[] = "Failed to load file: \"*\". ";
49 const char kViewInstanceIdError[] = "view_instance_id is missing."; 53 const char kViewInstanceIdError[] = "view_instance_id is missing.";
50 const char kDuplicatedContentScriptNamesError[] =
51 "The given content script name already exists.";
52 54
53 uint32 MaskForKey(const char* key) { 55 uint32 MaskForKey(const char* key) {
54 if (strcmp(key, kAppCacheKey) == 0) 56 if (strcmp(key, kAppCacheKey) == 0)
55 return webview::WEB_VIEW_REMOVE_DATA_MASK_APPCACHE; 57 return webview::WEB_VIEW_REMOVE_DATA_MASK_APPCACHE;
56 if (strcmp(key, kCacheKey) == 0) 58 if (strcmp(key, kCacheKey) == 0)
57 return webview::WEB_VIEW_REMOVE_DATA_MASK_CACHE; 59 return webview::WEB_VIEW_REMOVE_DATA_MASK_CACHE;
58 if (strcmp(key, kCookiesKey) == 0) 60 if (strcmp(key, kCookiesKey) == 0)
59 return webview::WEB_VIEW_REMOVE_DATA_MASK_COOKIES; 61 return webview::WEB_VIEW_REMOVE_DATA_MASK_COOKIES;
60 if (strcmp(key, kFileSystemsKey) == 0) 62 if (strcmp(key, kFileSystemsKey) == 0)
61 return webview::WEB_VIEW_REMOVE_DATA_MASK_FILE_SYSTEMS; 63 return webview::WEB_VIEW_REMOVE_DATA_MASK_FILE_SYSTEMS;
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 627
626 bool WebViewInternalFindFunction::RunAsyncSafe(WebViewGuest* guest) { 628 bool WebViewInternalFindFunction::RunAsyncSafe(WebViewGuest* guest) {
627 scoped_ptr<web_view_internal::Find::Params> params( 629 scoped_ptr<web_view_internal::Find::Params> params(
628 web_view_internal::Find::Params::Create(*args_)); 630 web_view_internal::Find::Params::Create(*args_));
629 EXTENSION_FUNCTION_VALIDATE(params.get()); 631 EXTENSION_FUNCTION_VALIDATE(params.get());
630 632
631 // Convert the std::string search_text to string16. 633 // Convert the std::string search_text to string16.
632 base::string16 search_text; 634 base::string16 search_text;
633 base::UTF8ToUTF16( 635 base::UTF8ToUTF16(
634 params->search_text.c_str(), params->search_text.length(), &search_text); 636 params->search_text.c_str(), params->search_text.length(), &search_text);
637 if (search_text.empty()) {
Fady Samuel 2015/09/26 00:14:34 I don't think this is the correct solution. I thin
Lei Zhang 2015/09/26 00:22:01 You are referring to https://developer.chrome.com/
Charlie Reis 2015/09/28 19:35:17 It does seem like a nonsensical case to me. I'd b
638 error_ = kEmptyFindTextError;
639 SendResponse(false);
640 return true;
641 }
635 642
636 // Set the find options to their default values. 643 // Set the find options to their default values.
637 blink::WebFindOptions options; 644 blink::WebFindOptions options;
638 if (params->options) { 645 if (params->options) {
639 options.forward = 646 options.forward =
640 params->options->backward ? !*params->options->backward : true; 647 params->options->backward ? !*params->options->backward : true;
641 options.matchCase = 648 options.matchCase =
642 params->options->match_case ? *params->options->match_case : false; 649 params->options->match_case ? *params->options->match_case : false;
643 } 650 }
644 651
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 // Will finish asynchronously. 899 // Will finish asynchronously.
893 return true; 900 return true;
894 } 901 }
895 902
896 void WebViewInternalClearDataFunction::ClearDataDone() { 903 void WebViewInternalClearDataFunction::ClearDataDone() {
897 Release(); // Balanced in RunAsync(). 904 Release(); // Balanced in RunAsync().
898 SendResponse(true); 905 SendResponse(true);
899 } 906 }
900 907
901 } // namespace extensions 908 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698