Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / extensions / browser / extension_error_test_util.cc
blob0396d8604aabbad7f451b62afc5fe8e4b8edc842
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
3 // found in the LICENSE file.
5 #include "extensions/browser/extension_error_test_util.h"
7 #include "base/logging.h"
8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/common/url_constants.h"
11 #include "extensions/browser/extension_error.h"
12 #include "extensions/common/constants.h"
13 #include "extensions/common/stack_frame.h"
14 #include "url/gurl.h"
16 namespace extensions {
17 namespace error_test_util {
19 namespace {
20 const char kDefaultStackTrace[] = "function_name (https://url.com:1:1)";
23 scoped_ptr<ExtensionError> CreateNewRuntimeError(
24 const std::string& extension_id,
25 const std::string& message,
26 bool from_incognito) {
27 StackTrace stack_trace;
28 scoped_ptr<StackFrame> frame =
29 StackFrame::CreateFromText(base::ASCIIToUTF16(kDefaultStackTrace));
30 CHECK(frame.get());
31 stack_trace.push_back(*frame);
33 base::string16 source =
34 base::UTF8ToUTF16(std::string(kExtensionScheme) +
35 url::kStandardSchemeSeparator +
36 extension_id);
38 return scoped_ptr<ExtensionError>(
39 new RuntimeError(extension_id, from_incognito, source,
40 base::UTF8ToUTF16(message), stack_trace,
41 GURL::EmptyGURL(), // no context url
42 logging::LOG_INFO,
43 0, // Render frame id
44 0)); // Render process id
47 scoped_ptr<ExtensionError> CreateNewRuntimeError(
48 const std::string& extension_id, const std::string& message) {
49 return CreateNewRuntimeError(extension_id, message, false);
52 scoped_ptr<ExtensionError> CreateNewManifestError(
53 const std::string& extension_id, const std::string& message) {
54 return scoped_ptr<ExtensionError>(
55 new ManifestError(extension_id,
56 base::UTF8ToUTF16(message),
57 base::string16(),
58 base::string16()));
61 } // namespace error_test_util
62 } // namespace extensions