summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/print_native_handler.cc
blob: 1e83b0e5b9529031fc61cf9940109c6f9a0858c6 (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
30
31
32
// Copyright 2014 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 "extensions/renderer/print_native_handler.h"

#include <string>

#include "base/bind.h"
#include "base/strings/string_util.h"

namespace extensions {

PrintNativeHandler::PrintNativeHandler(ScriptContext* context)
    : ObjectBackedNativeHandler(context) {
  RouteFunction("Print",
                base::Bind(&PrintNativeHandler::Print, base::Unretained(this)));
}

void PrintNativeHandler::Print(
    const v8::FunctionCallbackInfo<v8::Value>& args) {
  if (args.Length() < 1)
    return;

  std::vector<std::string> components;
  for (int i = 0; i < args.Length(); ++i)
    components.push_back(*v8::String::Utf8Value(args[i]->ToString()));

  LOG(ERROR) << JoinString(components, ',');
}

}  // namespace extensions