OLD | NEW |
---|---|
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 "content/renderer/browser_plugin/browser_plugin.h" | 5 #include "content/renderer/browser_plugin/browser_plugin.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #if defined (OS_WIN) | 9 #if defined (OS_WIN) |
10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 using WebKit::WebPoint; | 36 using WebKit::WebPoint; |
37 using WebKit::WebString; | 37 using WebKit::WebString; |
38 using WebKit::WebRect; | 38 using WebKit::WebRect; |
39 using WebKit::WebURL; | 39 using WebKit::WebURL; |
40 using WebKit::WebVector; | 40 using WebKit::WebVector; |
41 | 41 |
42 namespace content { | 42 namespace content { |
43 | 43 |
44 namespace { | 44 namespace { |
45 const char kCrashEventName[] = "crash"; | 45 const char kCrashEventName[] = "crash"; |
46 const char kLoadRedirectEventName[] = "loadRedirect"; | |
46 const char kNavigationEventName[] = "navigation"; | 47 const char kNavigationEventName[] = "navigation"; |
47 const char* kPartitionAttribute = "partition"; | 48 const char* kPartitionAttribute = "partition"; |
48 const char* kPersistPrefix = "persist:"; | 49 const char* kPersistPrefix = "persist:"; |
49 const char* kSrcAttribute = "src"; | 50 const char* kSrcAttribute = "src"; |
50 | 51 |
52 const std::string kNewURL = "newUrl"; | |
Fady Samuel
2012/10/04 15:15:30
Please make these const char[] to match my loadSta
| |
53 const std::string kOldURL = "oldUrl"; | |
54 const std::string kIsTopLevel = "isTopLevel"; | |
55 | |
51 } | 56 } |
52 | 57 |
53 BrowserPlugin::BrowserPlugin( | 58 BrowserPlugin::BrowserPlugin( |
54 int instance_id, | 59 int instance_id, |
55 RenderViewImpl* render_view, | 60 RenderViewImpl* render_view, |
56 WebKit::WebFrame* frame, | 61 WebKit::WebFrame* frame, |
57 const WebPluginParams& params) | 62 const WebPluginParams& params) |
58 : instance_id_(instance_id), | 63 : instance_id_(instance_id), |
59 render_view_(render_view), | 64 render_view_(render_view), |
60 container_(NULL), | 65 container_(NULL), |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 v8::Local<v8::Value> param = | 340 v8::Local<v8::Value> param = |
336 v8::Local<v8::Value>::New(v8::String::New(src_.c_str())); | 341 v8::Local<v8::Value>::New(v8::String::New(src_.c_str())); |
337 container()->element().document().frame()-> | 342 container()->element().document().frame()-> |
338 callFunctionEvenIfScriptDisabled(*it, | 343 callFunctionEvenIfScriptDisabled(*it, |
339 v8::Object::New(), | 344 v8::Object::New(), |
340 1, | 345 1, |
341 ¶m); | 346 ¶m); |
342 } | 347 } |
343 } | 348 } |
344 | 349 |
350 void BrowserPlugin::LoadRedirect(const GURL& old_url, | |
351 const GURL& new_url, | |
352 bool is_top_level) { | |
353 if (!HasListeners(kLoadRedirectEventName)) | |
354 return; | |
355 | |
356 EventListeners& listeners = event_listener_map_[kLoadRedirectEventName]; | |
357 EventListeners::iterator it = listeners.begin(); | |
358 | |
359 v8::Context::Scope context_scope(v8::Context::New()); | |
360 v8::HandleScope handle_scope; | |
361 // Construct the loadRedirect event object. | |
362 v8::Local<v8::Value> event = | |
363 v8::Local<v8::Object>::New(v8::Object::New()); | |
364 v8::Local<v8::Object>::Cast(event)->Set( | |
365 v8::String::New(kOldURL.c_str(), kOldURL.size()), | |
Fady Samuel
2012/10/04 15:15:30
Please use char[] instead of string to match my pa
Charlie Reis
2012/10/04 19:05:58
Done.
| |
366 v8::String::New(old_url.spec().c_str(), old_url.spec().size())); | |
367 v8::Local<v8::Object>::Cast(event)->Set( | |
368 v8::String::New(kNewURL.c_str(), kNewURL.size()), | |
369 v8::String::New(new_url.spec().c_str(), new_url.spec().size())); | |
370 v8::Local<v8::Object>::Cast(event)->Set( | |
371 v8::String::New(kIsTopLevel.c_str(), kIsTopLevel.size()), | |
372 v8::Boolean::New(is_top_level)); | |
373 for (; it != listeners.end(); ++it) { | |
374 // Fire the event listener. | |
375 container()->element().document().frame()-> | |
376 callFunctionEvenIfScriptDisabled(*it, | |
377 v8::Object::New(), | |
378 1, | |
379 &event); | |
380 } | |
381 } | |
382 | |
345 void BrowserPlugin::AdvanceFocus(bool reverse) { | 383 void BrowserPlugin::AdvanceFocus(bool reverse) { |
346 // We do not have a RenderView when we are testing. | 384 // We do not have a RenderView when we are testing. |
347 if (render_view_) | 385 if (render_view_) |
348 render_view_->GetWebView()->advanceFocus(reverse); | 386 render_view_->GetWebView()->advanceFocus(reverse); |
349 } | 387 } |
350 | 388 |
351 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { | 389 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { |
352 if (container()) | 390 if (container()) |
353 container()->setIsAcceptingTouchEvents(accept); | 391 container()->setIsAcceptingTouchEvents(accept); |
354 } | 392 } |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
618 void* notify_data) { | 656 void* notify_data) { |
619 } | 657 } |
620 | 658 |
621 void BrowserPlugin::didFailLoadingFrameRequest( | 659 void BrowserPlugin::didFailLoadingFrameRequest( |
622 const WebKit::WebURL& url, | 660 const WebKit::WebURL& url, |
623 void* notify_data, | 661 void* notify_data, |
624 const WebKit::WebURLError& error) { | 662 const WebKit::WebURLError& error) { |
625 } | 663 } |
626 | 664 |
627 } // namespace content | 665 } // namespace content |
OLD | NEW |