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

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

Issue 10821133: Move c/r/extensions/* into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for cq Created 8 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
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/webstore_bindings.h" 5 #include "chrome/renderer/extensions/webstore_bindings.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/common/extensions/extension.h" 8 #include "chrome/common/extensions/extension.h"
9 #include "chrome/common/extensions/extension_messages.h" 9 #include "chrome/common/extensions/extension_messages.h"
10 #include "chrome/renderer/extensions/chrome_v8_context.h" 10 #include "chrome/renderer/extensions/chrome_v8_context.h"
11 #include "content/public/renderer/render_view.h" 11 #include "content/public/renderer/render_view.h"
12 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 #include "grit/renderer_resources.h" 13 #include "grit/renderer_resources.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h"
18 #include "v8/include/v8.h" 18 #include "v8/include/v8.h"
19 19
20 using WebKit::WebDocument; 20 using WebKit::WebDocument;
21 using WebKit::WebElement; 21 using WebKit::WebElement;
22 using WebKit::WebFrame; 22 using WebKit::WebFrame;
23 using WebKit::WebNode; 23 using WebKit::WebNode;
24 using WebKit::WebNodeList; 24 using WebKit::WebNodeList;
25 25
26 namespace extensions {
27
26 namespace { 28 namespace {
27 29
28 const char kWebstoreLinkRelation[] = "chrome-webstore-item"; 30 const char kWebstoreLinkRelation[] = "chrome-webstore-item";
29 31
30 const char kPreferredStoreLinkUrlNotAString[] = 32 const char kPreferredStoreLinkUrlNotAString[] =
31 "The Chrome Web Store item link URL parameter must be a string."; 33 "The Chrome Web Store item link URL parameter must be a string.";
32 const char kSuccessCallbackNotAFunctionError[] = 34 const char kSuccessCallbackNotAFunctionError[] =
33 "The success callback parameter must be a function."; 35 "The success callback parameter must be a function.";
34 const char kFailureCallbackNotAFunctionError[] = 36 const char kFailureCallbackNotAFunctionError[] =
35 "The failure callback parameter must be a function."; 37 "The failure callback parameter must be a function.";
36 const char kNotInTopFrameError[] = 38 const char kNotInTopFrameError[] =
37 "Chrome Web Store installations can only be started by the top frame."; 39 "Chrome Web Store installations can only be started by the top frame.";
38 const char kNotUserGestureError[] = 40 const char kNotUserGestureError[] =
39 "Chrome Web Store installations can only be initated by a user gesture."; 41 "Chrome Web Store installations can only be initated by a user gesture.";
40 const char kNoWebstoreItemLinkFoundError[] = 42 const char kNoWebstoreItemLinkFoundError[] =
41 "No Chrome Web Store item link found."; 43 "No Chrome Web Store item link found.";
42 const char kInvalidWebstoreItemUrlError[] = 44 const char kInvalidWebstoreItemUrlError[] =
43 "Invalid Chrome Web Store item URL."; 45 "Invalid Chrome Web Store item URL.";
44 46
45 // chrome.webstore.install() calls generate an install ID so that the install's 47 // chrome.webstore.install() calls generate an install ID so that the install's
46 // callbacks may be fired when the browser notifies us of install completion 48 // callbacks may be fired when the browser notifies us of install completion
47 // (successful or not) via OnInlineWebstoreInstallResponse. 49 // (successful or not) via OnInlineWebstoreInstallResponse.
48 int g_next_install_id = 0; 50 int g_next_install_id = 0;
49 51
50 } // anonymous namespace 52 } // anonymous namespace
51 53
52 WebstoreBindings::WebstoreBindings(ExtensionDispatcher* dispatcher, 54 WebstoreBindings::WebstoreBindings(Dispatcher* dispatcher,
53 ChromeV8Context* context) 55 ChromeV8Context* context)
54 : ChromeV8Extension(dispatcher), 56 : ChromeV8Extension(dispatcher),
55 ChromeV8ExtensionHandler(context) { 57 ChromeV8ExtensionHandler(context) {
56 RouteFunction("Install", 58 RouteFunction("Install",
57 base::Bind(&WebstoreBindings::Install, base::Unretained(this))); 59 base::Bind(&WebstoreBindings::Install, base::Unretained(this)));
58 } 60 }
59 61
60 v8::Handle<v8::Value> WebstoreBindings::Install( 62 v8::Handle<v8::Value> WebstoreBindings::Install(
61 const v8::Arguments& args) { 63 const v8::Arguments& args) {
62 WebFrame* frame = WebFrame::frameForCurrentContext(); 64 WebFrame* frame = WebFrame::frameForCurrentContext();
63 if (!frame || !frame->view()) 65 if (!frame || !frame->view())
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 const std::string& error) { 211 const std::string& error) {
210 v8::HandleScope handle_scope; 212 v8::HandleScope handle_scope;
211 v8::Context::Scope context_scope(context_->v8_context()); 213 v8::Context::Scope context_scope(context_->v8_context());
212 v8::Handle<v8::Value> argv[3]; 214 v8::Handle<v8::Value> argv[3];
213 argv[0] = v8::Integer::New(install_id); 215 argv[0] = v8::Integer::New(install_id);
214 argv[1] = v8::Boolean::New(success); 216 argv[1] = v8::Boolean::New(success);
215 argv[2] = v8::String::New(error.c_str()); 217 argv[2] = v8::String::New(error.c_str());
216 CHECK(context_->CallChromeHiddenMethod("webstore.onInstallResponse", 218 CHECK(context_->CallChromeHiddenMethod("webstore.onInstallResponse",
217 arraysize(argv), argv, NULL)); 219 arraysize(argv), argv, NULL));
218 } 220 }
221
222 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/webstore_bindings.h ('k') | chrome/renderer/resources/extensions/app_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698