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

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

Issue 2819683002: [Extenisons Bindings] Don't throw unchecked errors; add console errors (Closed)
Patch Set: . Created 3 years, 8 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 #ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ 5 #ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
6 #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ 6 #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
17 #include "content/public/common/console_message_level.h"
17 #include "extensions/common/features/feature.h" 18 #include "extensions/common/features/feature.h"
18 #include "extensions/common/permissions/api_permission_set.h" 19 #include "extensions/common/permissions/api_permission_set.h"
19 #include "extensions/renderer/module_system.h" 20 #include "extensions/renderer/module_system.h"
20 #include "extensions/renderer/request_sender.h" 21 #include "extensions/renderer/request_sender.h"
21 #include "extensions/renderer/safe_builtins.h" 22 #include "extensions/renderer/safe_builtins.h"
22 #include "extensions/renderer/script_injection_callback.h" 23 #include "extensions/renderer/script_injection_callback.h"
23 #include "gin/runner.h" 24 #include "gin/runner.h"
24 #include "url/gurl.h" 25 #include "url/gurl.h"
25 #include "v8/include/v8.h" 26 #include "v8/include/v8.h"
26 27
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // a context for an extension which has that permission, or by being a web 206 // a context for an extension which has that permission, or by being a web
206 // context which has been granted the corresponding capability by an 207 // context which has been granted the corresponding capability by an
207 // extension. 208 // extension.
208 bool HasAPIPermission(APIPermission::ID permission) const; 209 bool HasAPIPermission(APIPermission::ID permission) const;
209 210
210 // Throws an Error in this context's JavaScript context, if this context does 211 // Throws an Error in this context's JavaScript context, if this context does
211 // not have access to |name|. Returns true if this context has access (i.e. 212 // not have access to |name|. Returns true if this context has access (i.e.
212 // no exception thrown), false if it does not (i.e. an exception was thrown). 213 // no exception thrown), false if it does not (i.e. an exception was thrown).
213 bool HasAccessOrThrowError(const std::string& name); 214 bool HasAccessOrThrowError(const std::string& name);
214 215
216 // Adds a message to the associated RenderFrame's console. If there is no
217 // RenderFrame, LOG()s the message instead.
218 void AddMessageToConsole(content::ConsoleMessageLevel level,
219 const std::string& message);
220
215 // Returns a string representation of this ScriptContext, for debugging. 221 // Returns a string representation of this ScriptContext, for debugging.
216 std::string GetDebugString() const; 222 std::string GetDebugString() const;
217 223
218 // Gets the current stack trace as a multi-line string to be logged. 224 // Gets the current stack trace as a multi-line string to be logged.
219 std::string GetStackTraceAsString() const; 225 std::string GetStackTraceAsString() const;
220 226
221 // Runs |code|, labelling the script that gets created as |name| (the name is 227 // Runs |code|, labelling the script that gets created as |name| (the name is
222 // used in the devtools and stack traces). |exception_handler| will be called 228 // used in the devtools and stack traces). |exception_handler| will be called
223 // re-entrantly if an exception is thrown during the script's execution. 229 // re-entrantly if an exception is thrown during the script's execution.
224 v8::Local<v8::Value> RunScript( 230 v8::Local<v8::Value> RunScript(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 std::unique_ptr<Runner> runner_; 280 std::unique_ptr<Runner> runner_;
275 281
276 base::ThreadChecker thread_checker_; 282 base::ThreadChecker thread_checker_;
277 283
278 DISALLOW_COPY_AND_ASSIGN(ScriptContext); 284 DISALLOW_COPY_AND_ASSIGN(ScriptContext);
279 }; 285 };
280 286
281 } // namespace extensions 287 } // namespace extensions
282 288
283 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ 289 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698