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

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

Issue 9958147: Fix some uses of global variables in transient pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/extensions/context_menus_custom_bindings.h" 5 #include "chrome/renderer/extensions/context_menus_custom_bindings.h"
6 6
7 #include "chrome/common/extensions/extension_messages.h"
8 #include "content/public/renderer/render_thread.h"
7 #include "grit/renderer_resources.h" 9 #include "grit/renderer_resources.h"
8 #include "v8/include/v8.h" 10 #include "v8/include/v8.h"
9 11
10 namespace { 12 namespace {
11 13
12 v8::Handle<v8::Value> GetNextContextMenuId(const v8::Arguments& args) { 14 v8::Handle<v8::Value> GetNextContextMenuId(const v8::Arguments& args) {
13 // Note: this works because contextMenus.create() only works in the 15 int context_menu_id = -1;
14 // extension process. If that API is opened up to content scripts, this 16 content::RenderThread::Get()->Send(
15 // will need to change. See crbug.com/77023 17 new ExtensionHostMsg_GenerateUniqueID(&context_menu_id));
16 static int next_context_menu_id = 1; 18 return v8::Integer::New(context_menu_id);
17 return v8::Integer::New(next_context_menu_id++);
18 } 19 }
19 20
20 } // namespace 21 } // namespace
21 22
22 namespace extensions { 23 namespace extensions {
23 24
24 ContextMenusCustomBindings::ContextMenusCustomBindings() 25 ContextMenusCustomBindings::ContextMenusCustomBindings()
25 : ChromeV8Extension(NULL) { 26 : ChromeV8Extension(NULL) {
26 RouteStaticFunction("GetNextContextMenuId", &GetNextContextMenuId); 27 RouteStaticFunction("GetNextContextMenuId", &GetNextContextMenuId);
27 } 28 }
28 29
29 } // extensions 30 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698