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

Side by Side Diff: chrome/common/extensions/manifest_handlers/content_scripts_handler.cc

Issue 313453002: Resubmit: Block content scripts from executing until user grants permission (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/common/extensions/manifest_handlers/content_scripts_handler.h" 5 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 13 matching lines...) Expand all
24 #include "url/gurl.h" 24 #include "url/gurl.h"
25 25
26 namespace extensions { 26 namespace extensions {
27 27
28 namespace keys = extensions::manifest_keys; 28 namespace keys = extensions::manifest_keys;
29 namespace values = manifest_values; 29 namespace values = manifest_values;
30 namespace errors = manifest_errors; 30 namespace errors = manifest_errors;
31 31
32 namespace { 32 namespace {
33 33
34 // The globally-unique id for a user script.
35 int64 g_next_user_script_id = 0;
36
34 // Helper method that loads either the include_globs or exclude_globs list 37 // Helper method that loads either the include_globs or exclude_globs list
35 // from an entry in the content_script lists of the manifest. 38 // from an entry in the content_script lists of the manifest.
36 bool LoadGlobsHelper(const base::DictionaryValue* content_script, 39 bool LoadGlobsHelper(const base::DictionaryValue* content_script,
37 int content_script_index, 40 int content_script_index,
38 const char* globs_property_name, 41 const char* globs_property_name,
39 base::string16* error, 42 base::string16* error,
40 void(UserScript::*add_method)(const std::string& glob), 43 void(UserScript::*add_method)(const std::string& glob),
41 UserScript* instance) { 44 UserScript* instance) {
42 if (!content_script->HasKey(globs_property_name)) 45 if (!content_script->HasKey(globs_property_name))
43 return true; // they are optional 46 return true; // they are optional
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 &user_script)) { 420 &user_script)) {
418 return false; // Failed to parse script context definition. 421 return false; // Failed to parse script context definition.
419 } 422 }
420 423
421 user_script.set_extension_id(extension->id()); 424 user_script.set_extension_id(extension->id());
422 if (extension->converted_from_user_script()) { 425 if (extension->converted_from_user_script()) {
423 user_script.set_emulate_greasemonkey(true); 426 user_script.set_emulate_greasemonkey(true);
424 // Greasemonkey matches all frames. 427 // Greasemonkey matches all frames.
425 user_script.set_match_all_frames(true); 428 user_script.set_match_all_frames(true);
426 } 429 }
430 user_script.set_id(g_next_user_script_id++);
not at google - send to devlin 2014/06/02 18:42:55 is there a test for ContentScriptsHandler that we
Devlin 2014/06/02 21:04:31 Sure.
427 content_scripts_info->content_scripts.push_back(user_script); 431 content_scripts_info->content_scripts.push_back(user_script);
428 } 432 }
429 extension->SetManifestData(keys::kContentScripts, 433 extension->SetManifestData(keys::kContentScripts,
430 content_scripts_info.release()); 434 content_scripts_info.release());
431 PermissionsData::SetInitialScriptableHosts( 435 PermissionsData::SetInitialScriptableHosts(
432 extension, 436 extension,
433 ContentScriptsInfo::GetScriptableHosts(extension)); 437 ContentScriptsInfo::GetScriptableHosts(extension));
434 return true; 438 return true;
435 } 439 }
436 440
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 if (!IsScriptValid(path, css_script.relative_path(), 475 if (!IsScriptValid(path, css_script.relative_path(),
472 IDS_EXTENSION_LOAD_CSS_FAILED, error)) 476 IDS_EXTENSION_LOAD_CSS_FAILED, error))
473 return false; 477 return false;
474 } 478 }
475 } 479 }
476 480
477 return true; 481 return true;
478 } 482 }
479 483
480 } // namespace extensions 484 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698