summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/exported/web_console_message.cc
blob: 0cdd05b6b51f4ce46efe44aa3e3141b0c82c92f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/public/web/web_console_message.h"

#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"

namespace blink {

void WebConsoleMessage::LogWebConsoleMessage(v8::Local<v8::Context> context,
                                             const WebConsoleMessage& message) {
  auto* execution_context = ToExecutionContext(context);
  if (!execution_context)  // Can happen in unittests.
    return;

  LocalFrame* frame = nullptr;
  if (auto* window = DynamicTo<LocalDOMWindow>(execution_context))
    frame = window->GetFrame();
  execution_context->AddConsoleMessage(
      MakeGarbageCollected<ConsoleMessage>(message, frame));
}

}  // namespace blink