summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/context_menus_custom_bindings.cc
blob: 3f9d4ffa47b75ab6b6742e94ea07b1545765e402 (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
// 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/context_menus_custom_bindings.h"

#include "base/bind.h"
#include "content/public/renderer/render_thread.h"
#include "extensions/common/extension_messages.h"
#include "v8/include/v8.h"

namespace {

void GetNextContextMenuId(const v8::FunctionCallbackInfo<v8::Value>& args) {
  int context_menu_id = -1;
  content::RenderThread::Get()->Send(
      new ExtensionHostMsg_GenerateUniqueID(&context_menu_id));
  args.GetReturnValue().Set(static_cast<int32_t>(context_menu_id));
}

}  // namespace

namespace extensions {

ContextMenusCustomBindings::ContextMenusCustomBindings(ScriptContext* context)
    : ObjectBackedNativeHandler(context) {
  RouteFunction("GetNextContextMenuId", base::Bind(&GetNextContextMenuId));
}

}  // extensions