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

Unified Diff: runtime/lib/mirrors.cc

Issue 321293002: Censor dart:_blink and dart:builtin from the enumeration of libraries in the isolate and from impor… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/lib/mirrors/mirrors_reader_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors.cc
diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
index b66088c1f8b18be66dd5e17c7d03333899b39799..1e66b8259c57c4847c5f4ce53eba89c8068718fd 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -385,6 +385,10 @@ static RawInstance* CreateLibraryMirror(const Library& lib) {
str = lib.name();
args.SetAt(1, str);
str = lib.url();
+ if (str.Equals("dart:builtin") || str.Equals("dart:_blink")) {
+ // Censored library (grumble).
+ return Instance::null();
+ }
args.SetAt(2, str);
return CreateMirror(Symbols::_LocalLibraryMirror(), args);
}
@@ -406,6 +410,10 @@ static RawInstance* CreateLibraryDependencyMirror(const Instance& importer,
const Library& importee = Library::Handle(ns.library());
const Instance& importee_mirror =
Instance::Handle(CreateLibraryMirror(importee));
+ if (importee_mirror.IsNull()) {
+ // Imported library is censored: censor the import.
+ return Instance::null();
+ }
const Array& show_names = Array::Handle(ns.show_names());
const Array& hide_names = Array::Handle(ns.hide_names());
@@ -461,7 +469,9 @@ DEFINE_NATIVE_ENTRY(LibraryMirror_libraryDependencies, 2) {
ns ^= ports.At(i);
if (!ns.IsNull()) {
dep = CreateLibraryDependencyMirror(lib_mirror, ns, prefix, true);
- deps.Add(dep);
+ if (!dep.IsNull()) {
+ deps.Add(dep);
+ }
}
}
@@ -470,7 +480,9 @@ DEFINE_NATIVE_ENTRY(LibraryMirror_libraryDependencies, 2) {
for (intptr_t i = 0; i < ports.Length(); i++) {
ns ^= ports.At(i);
dep = CreateLibraryDependencyMirror(lib_mirror, ns, prefix, false);
- deps.Add(dep);
+ if (!dep.IsNull()) {
+ deps.Add(dep);
+ }
}
// Prefixed imports.
@@ -486,7 +498,9 @@ DEFINE_NATIVE_ENTRY(LibraryMirror_libraryDependencies, 2) {
ns ^= ports.At(i);
if (!ns.IsNull()) {
dep = CreateLibraryDependencyMirror(lib_mirror, ns, prefix, true);
- deps.Add(dep);
+ if (!dep.IsNull()) {
+ deps.Add(dep);
+ }
}
}
}
@@ -549,18 +563,21 @@ static RawInstance* CreateIsolateMirror() {
static RawInstance* CreateMirrorSystem() {
Isolate* isolate = Isolate::Current();
- const GrowableObjectArray& libraries =
- GrowableObjectArray::Handle(isolate->object_store()->libraries());
+ const GrowableObjectArray& libraries = GrowableObjectArray::Handle(
+ isolate, isolate->object_store()->libraries());
const intptr_t num_libraries = libraries.Length();
- const Array& library_mirrors = Array::Handle(Array::New(num_libraries));
- Library& library = Library::Handle();
- Instance& library_mirror = Instance::Handle();
+ const GrowableObjectArray& library_mirrors = GrowableObjectArray::Handle(
+ isolate, GrowableObjectArray::New(num_libraries));
+ Library& library = Library::Handle(isolate);
+ Instance& library_mirror = Instance::Handle(isolate);
for (int i = 0; i < num_libraries; i++) {
library ^= libraries.At(i);
library_mirror = CreateLibraryMirror(library);
- library_mirrors.SetAt(i, library_mirror);
+ if (!library_mirror.IsNull()) {
+ library_mirrors.Add(library_mirror);
+ }
}
const Instance& isolate_mirror = Instance::Handle(CreateIsolateMirror());
« no previous file with comments | « no previous file | tests/lib/mirrors/mirrors_reader_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698