OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/renderer_host/render_view_host.h" | 5 #include "content/browser/renderer_host/render_view_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 #include "content/public/common/bindings_policy.h" | 43 #include "content/public/common/bindings_policy.h" |
44 #include "content/public/common/url_constants.h" | 44 #include "content/public/common/url_constants.h" |
45 #include "net/base/net_util.h" | 45 #include "net/base/net_util.h" |
46 #include "net/url_request/url_request_context_getter.h" | 46 #include "net/url_request/url_request_context_getter.h" |
47 #include "third_party/skia/include/core/SkBitmap.h" | 47 #include "third_party/skia/include/core/SkBitmap.h" |
48 #include "ui/gfx/native_widget_types.h" | 48 #include "ui/gfx/native_widget_types.h" |
49 #include "webkit/glue/context_menu.h" | 49 #include "webkit/glue/context_menu.h" |
50 #include "webkit/glue/webaccessibility.h" | 50 #include "webkit/glue/webaccessibility.h" |
51 #include "webkit/glue/webdropdata.h" | 51 #include "webkit/glue/webdropdata.h" |
52 | 52 |
53 #include "content/common/notification_details.h" | |
54 | |
53 using base::TimeDelta; | 55 using base::TimeDelta; |
54 using WebKit::WebConsoleMessage; | 56 using WebKit::WebConsoleMessage; |
55 using WebKit::WebDragOperation; | 57 using WebKit::WebDragOperation; |
56 using WebKit::WebDragOperationNone; | 58 using WebKit::WebDragOperationNone; |
57 using WebKit::WebDragOperationsMask; | 59 using WebKit::WebDragOperationsMask; |
58 using WebKit::WebInputEvent; | 60 using WebKit::WebInputEvent; |
59 using WebKit::WebMediaPlayerAction; | 61 using WebKit::WebMediaPlayerAction; |
60 | 62 |
61 namespace { | 63 namespace { |
62 | 64 |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 | 476 |
475 int RenderViewHost::ExecuteJavascriptInWebFrameNotifyResult( | 477 int RenderViewHost::ExecuteJavascriptInWebFrameNotifyResult( |
476 const string16& frame_xpath, | 478 const string16& frame_xpath, |
477 const string16& jscript) { | 479 const string16& jscript) { |
478 static int next_id = 1; | 480 static int next_id = 1; |
479 Send(new ViewMsg_ScriptEvalRequest(routing_id(), frame_xpath, jscript, | 481 Send(new ViewMsg_ScriptEvalRequest(routing_id(), frame_xpath, jscript, |
480 next_id, true)); | 482 next_id, true)); |
481 return next_id++; | 483 return next_id++; |
482 } | 484 } |
483 | 485 |
486 typedef std::pair<int, Value*> ExecuteDetailType; | |
487 | |
488 ExecuteNotificationObserver::ExecuteNotificationObserver(int id) : id_(id) { } | |
Avi (use Gerrit)
2011/10/17 14:20:38
adhere to style guide
keishi
2011/10/21 05:05:43
Done.
| |
489 ExecuteNotificationObserver::~ExecuteNotificationObserver() { } | |
Avi (use Gerrit)
2011/10/17 14:20:38
ditto
keishi
2011/10/21 05:05:43
Done.
| |
490 void ExecuteNotificationObserver::Observe(int type, | |
491 const NotificationSource& source, | |
492 const NotificationDetails& details) | |
493 { | |
Avi (use Gerrit)
2011/10/17 14:20:38
opening brace always on previous line
keishi
2011/10/21 05:05:43
Done.
| |
494 int id = (static_cast<Details<ExecuteDetailType > >(details))->first; | |
Avi (use Gerrit)
2011/10/17 14:20:38
no space before first >
keishi
2011/10/21 05:05:43
Done.
| |
495 if (id != id_) | |
496 return; | |
497 Value* value = (static_cast<Details<ExecuteDetailType > >(details))->second; | |
Avi (use Gerrit)
2011/10/17 14:20:38
ditto
keishi
2011/10/21 05:05:43
Done.
| |
498 if (value) | |
499 value_.reset(value->DeepCopy()); | |
500 MessageLoop::current()->Quit(); | |
501 } | |
502 | |
503 Value* RenderViewHost::ExecuteJavascriptAndGetValue(const string16& frame_xpath, | |
504 const string16& jscript) { | |
Avi (use Gerrit)
2011/10/17 14:20:38
align params
keishi
2011/10/21 05:05:43
Done.
| |
505 int id = ExecuteJavascriptInWebFrameNotifyResult(frame_xpath, jscript); | |
506 ExecuteNotificationObserver observer(id); | |
507 NotificationRegistrar notification_registrar; | |
508 notification_registrar.Add( | |
509 &observer, content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, | |
510 Source<RenderViewHost>(this)); | |
511 MessageLoop* loop = MessageLoop::current(); | |
512 loop->Run(); | |
513 return observer.value()->DeepCopy(); | |
Avi (use Gerrit)
2011/10/17 14:20:38
We make two copies?
keishi
2011/10/21 05:05:43
The value must outlive the observer so this copy i
| |
514 } | |
515 | |
484 void RenderViewHost::JavaScriptDialogClosed(IPC::Message* reply_msg, | 516 void RenderViewHost::JavaScriptDialogClosed(IPC::Message* reply_msg, |
485 bool success, | 517 bool success, |
486 const string16& user_input) { | 518 const string16& user_input) { |
487 process()->set_ignore_input_events(false); | 519 process()->set_ignore_input_events(false); |
488 bool is_waiting = | 520 bool is_waiting = |
489 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_; | 521 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_; |
490 if (is_waiting) | 522 if (is_waiting) |
491 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 523 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
492 | 524 |
493 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, | 525 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1427 void RenderViewHost::OnRunFileChooser( | 1459 void RenderViewHost::OnRunFileChooser( |
1428 const ViewHostMsg_RunFileChooser_Params& params) { | 1460 const ViewHostMsg_RunFileChooser_Params& params) { |
1429 delegate_->RunFileChooser(this, params); | 1461 delegate_->RunFileChooser(this, params); |
1430 } | 1462 } |
1431 | 1463 |
1432 void RenderViewHost::OnWebUISend(const GURL& source_url, | 1464 void RenderViewHost::OnWebUISend(const GURL& source_url, |
1433 const std::string& name, | 1465 const std::string& name, |
1434 const base::ListValue& args) { | 1466 const base::ListValue& args) { |
1435 delegate_->WebUISend(this, source_url, name, args); | 1467 delegate_->WebUISend(this, source_url, name, args); |
1436 } | 1468 } |
OLD | NEW |