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

Side by Side Diff: chrome/renderer/extensions/page_actions_custom_bindings.cc

Issue 472333002: Remove deprecated chrome.pageActions api functions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: histograms.xml Created 6 years, 4 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
(Empty)
1 // Copyright (c) 2012 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.
4
5 #include "chrome/renderer/extensions/page_actions_custom_bindings.h"
6
7 #include <string>
8
9 #include "base/bind.h"
10 #include "chrome/common/extensions/api/extension_action/action_info.h"
11 #include "extensions/common/extension.h"
12 #include "extensions/renderer/dispatcher.h"
13 #include "extensions/renderer/script_context.h"
14 #include "v8/include/v8.h"
15
16 namespace extensions {
17
18 PageActionsCustomBindings::PageActionsCustomBindings(Dispatcher* dispatcher,
19 ScriptContext* context)
20 : ObjectBackedNativeHandler(context), dispatcher_(dispatcher) {
21 RouteFunction("GetCurrentPageActions",
22 base::Bind(&PageActionsCustomBindings::GetCurrentPageActions,
23 base::Unretained(this)));
24 }
25
26 void PageActionsCustomBindings::GetCurrentPageActions(
27 const v8::FunctionCallbackInfo<v8::Value>& args) {
28 std::string extension_id = *v8::String::Utf8Value(args[0]->ToString());
29 CHECK(!extension_id.empty());
30 const Extension* extension =
31 dispatcher_->extensions()->GetByID(extension_id);
32 CHECK(extension);
33
34 v8::Isolate* isolate = args.GetIsolate();
35 v8::Local<v8::Array> page_action_vector = v8::Array::New(isolate);
36 if (ActionInfo::GetPageActionInfo(extension)) {
37 std::string id = ActionInfo::GetPageActionInfo(extension)->id;
38 page_action_vector->Set(v8::Integer::New(isolate, 0),
39 v8::String::NewFromUtf8(isolate,
40 id.c_str(),
41 v8::String::kNormalString,
42 id.size()));
43 }
44
45 args.GetReturnValue().Set(page_action_vector);
46 }
47
48 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698