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

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

Issue 12570005: Update user gesture related code to the new WebKit API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years, 9 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
« no previous file with comments | « chrome/renderer/extensions/request_sender.cc ('k') | content/renderer/notification_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "third_party/WebKit/Source/WebKit/chromium/public/WebUserGestureIndicat or.h"
18 #include "v8/include/v8.h" 19 #include "v8/include/v8.h"
19 20
20 using WebKit::WebDocument; 21 using WebKit::WebDocument;
21 using WebKit::WebElement; 22 using WebKit::WebElement;
22 using WebKit::WebFrame; 23 using WebKit::WebFrame;
23 using WebKit::WebNode; 24 using WebKit::WebNode;
24 using WebKit::WebNodeList; 25 using WebKit::WebNodeList;
26 using WebKit::WebUserGestureIndicator;
25 27
26 namespace extensions { 28 namespace extensions {
27 29
28 namespace { 30 namespace {
29 31
30 const char kWebstoreLinkRelation[] = "chrome-webstore-item"; 32 const char kWebstoreLinkRelation[] = "chrome-webstore-item";
31 33
32 const char kPreferredStoreLinkUrlNotAString[] = 34 const char kPreferredStoreLinkUrlNotAString[] =
33 "The Chrome Web Store item link URL parameter must be a string."; 35 "The Chrome Web Store item link URL parameter must be a string.";
34 const char kSuccessCallbackNotAFunctionError[] = 36 const char kSuccessCallbackNotAFunctionError[] =
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 113
112 // static 114 // static
113 bool WebstoreBindings::GetWebstoreItemIdFromFrame( 115 bool WebstoreBindings::GetWebstoreItemIdFromFrame(
114 WebFrame* frame, const std::string& preferred_store_link_url, 116 WebFrame* frame, const std::string& preferred_store_link_url,
115 std::string* webstore_item_id, std::string* error) { 117 std::string* webstore_item_id, std::string* error) {
116 if (frame != frame->top()) { 118 if (frame != frame->top()) {
117 *error = kNotInTopFrameError; 119 *error = kNotInTopFrameError;
118 return false; 120 return false;
119 } 121 }
120 122
121 if (!frame->isProcessingUserGesture()) { 123 if (!WebUserGestureIndicator::isProcessingUserGesture()) {
122 *error = kNotUserGestureError; 124 *error = kNotUserGestureError;
123 return false; 125 return false;
124 } 126 }
125 127
126 WebDocument document = frame->document(); 128 WebDocument document = frame->document();
127 if (document.isNull()) { 129 if (document.isNull()) {
128 *error = kNoWebstoreItemLinkFoundError; 130 *error = kNoWebstoreItemLinkFoundError;
129 return false; 131 return false;
130 } 132 }
131 133
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 v8::Context::Scope context_scope(context_->v8_context()); 215 v8::Context::Scope context_scope(context_->v8_context());
214 v8::Handle<v8::Value> argv[3]; 216 v8::Handle<v8::Value> argv[3];
215 argv[0] = v8::Integer::New(install_id); 217 argv[0] = v8::Integer::New(install_id);
216 argv[1] = v8::Boolean::New(success); 218 argv[1] = v8::Boolean::New(success);
217 argv[2] = v8::String::New(error.c_str()); 219 argv[2] = v8::String::New(error.c_str());
218 context_->CallChromeHiddenMethod("webstore.onInstallResponse", 220 context_->CallChromeHiddenMethod("webstore.onInstallResponse",
219 arraysize(argv), argv, NULL); 221 arraysize(argv), argv, NULL);
220 } 222 }
221 223
222 } // namespace extensions 224 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/request_sender.cc ('k') | content/renderer/notification_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698