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

Side by Side Diff: extensions/renderer/script_context.cc

Issue 2481923002: [WIP] make GURL::path() return a StringPiece (Closed)
Patch Set: thanks asan Created 4 years, 1 month 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
« no previous file with comments | « extensions/common/url_pattern.cc ('k') | extensions/renderer/user_script_injector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/script_context.h" 5 #include "extensions/renderer/script_context.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 // static 127 // static
128 bool ScriptContext::IsSandboxedPage(const GURL& url) { 128 bool ScriptContext::IsSandboxedPage(const GURL& url) {
129 // TODO(kalman): This is checking the wrong thing. See comment in 129 // TODO(kalman): This is checking the wrong thing. See comment in
130 // HasAccessOrThrowError. 130 // HasAccessOrThrowError.
131 if (url.SchemeIs(kExtensionScheme)) { 131 if (url.SchemeIs(kExtensionScheme)) {
132 const Extension* extension = 132 const Extension* extension =
133 RendererExtensionRegistry::Get()->GetByID(url.host()); 133 RendererExtensionRegistry::Get()->GetByID(url.host());
134 if (extension) { 134 if (extension) {
135 return SandboxedPageInfo::IsSandboxedPage(extension, url.path()); 135 return SandboxedPageInfo::IsSandboxedPage(extension,
136 url.path().as_string());
136 } 137 }
137 } 138 }
138 return false; 139 return false;
139 } 140 }
140 141
141 void ScriptContext::Invalidate() { 142 void ScriptContext::Invalidate() {
142 DCHECK(thread_checker_.CalledOnValidThread()); 143 DCHECK(thread_checker_.CalledOnValidThread());
143 CHECK(is_valid_); 144 CHECK(is_valid_);
144 is_valid_ = false; 145 is_valid_ = false;
145 146
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 // sandboxed frames, for example content scripts. Don't let them execute API 396 // sandboxed frames, for example content scripts. Don't let them execute API
396 // functions. 397 // functions.
397 // 398 //
398 // In any case, this check is silly. The frame's document's security origin 399 // In any case, this check is silly. The frame's document's security origin
399 // already tells us if it's sandboxed. The only problem is that until 400 // already tells us if it's sandboxed. The only problem is that until
400 // crbug.com/466373 is fixed, we don't know the security origin up-front and 401 // crbug.com/466373 is fixed, we don't know the security origin up-front and
401 // may not know it here, either. 402 // may not know it here, either.
402 // 403 //
403 // [1] citation needed. This ScriptContext should already be in a state that 404 // [1] citation needed. This ScriptContext should already be in a state that
404 // doesn't allow this, from ScriptContextSet::ClassifyJavaScriptContext. 405 // doesn't allow this, from ScriptContextSet::ClassifyJavaScriptContext.
405 if (extension() && 406 if (extension() && SandboxedPageInfo::IsSandboxedPage(
406 SandboxedPageInfo::IsSandboxedPage(extension(), url_.path())) { 407 extension(), url_.path().as_string())) {
407 static const char kMessage[] = 408 static const char kMessage[] =
408 "%s cannot be used within a sandboxed frame."; 409 "%s cannot be used within a sandboxed frame.";
409 std::string error_msg = base::StringPrintf(kMessage, name.c_str()); 410 std::string error_msg = base::StringPrintf(kMessage, name.c_str());
410 isolate()->ThrowException(v8::Exception::Error( 411 isolate()->ThrowException(v8::Exception::Error(
411 v8::String::NewFromUtf8(isolate(), error_msg.c_str()))); 412 v8::String::NewFromUtf8(isolate(), error_msg.c_str())));
412 return false; 413 return false;
413 } 414 }
414 415
415 Feature::Availability availability = GetAvailability(name); 416 Feature::Availability availability = GetAvailability(name);
416 if (!availability.is_available()) { 417 if (!availability.is_available()) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 v8::Local<v8::Value> argv[]) { 513 v8::Local<v8::Value> argv[]) {
513 return context_->CallFunction(function, argc, argv); 514 return context_->CallFunction(function, argc, argv);
514 } 515 }
515 516
516 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { 517 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() {
517 v8::HandleScope handle_scope(context_->isolate()); 518 v8::HandleScope handle_scope(context_->isolate());
518 return gin::PerContextData::From(context_->v8_context())->context_holder(); 519 return gin::PerContextData::From(context_->v8_context())->context_holder();
519 } 520 }
520 521
521 } // namespace extensions 522 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/url_pattern.cc ('k') | extensions/renderer/user_script_injector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698