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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 gfx::Point(client_x, client_y), | 568 gfx::Point(client_x, client_y), |
569 gfx::Point(screen_x, screen_y), | 569 gfx::Point(screen_x, screen_y), |
570 false, WebDragOperationNone)); | 570 false, WebDragOperationNone)); |
571 } | 571 } |
572 | 572 |
573 void RenderViewHost::DragSourceSystemDragEnded() { | 573 void RenderViewHost::DragSourceSystemDragEnded() { |
574 Send(new DragMsg_SourceSystemDragEnded(routing_id())); | 574 Send(new DragMsg_SourceSystemDragEnded(routing_id())); |
575 } | 575 } |
576 | 576 |
577 void RenderViewHost::AllowBindings(int bindings_flags) { | 577 void RenderViewHost::AllowBindings(int bindings_flags) { |
| 578 // Ensure we aren't granting bindings to a process that has already |
| 579 // been used for non-privileged views. |
| 580 if (process()->HasConnection() && |
| 581 !ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( |
| 582 process()->GetID())) { |
| 583 // This process has no bindings yet. Make sure it does not have more |
| 584 // than this single view. |
| 585 content::RenderProcessHost::listeners_iterator iter( |
| 586 process()->ListenersIterator()); |
| 587 iter.Advance(); |
| 588 if (!iter.IsAtEnd()) |
| 589 return; |
| 590 } |
| 591 |
578 if (bindings_flags & content::BINDINGS_POLICY_WEB_UI) { | 592 if (bindings_flags & content::BINDINGS_POLICY_WEB_UI) { |
579 ChildProcessSecurityPolicy::GetInstance()->GrantWebUIBindings( | 593 ChildProcessSecurityPolicy::GetInstance()->GrantWebUIBindings( |
580 process()->GetID()); | 594 process()->GetID()); |
581 } | 595 } |
582 | 596 |
583 enabled_bindings_ |= bindings_flags; | 597 enabled_bindings_ |= bindings_flags; |
584 if (renderer_initialized_) | 598 if (renderer_initialized_) |
585 Send(new ViewMsg_AllowBindings(routing_id(), enabled_bindings_)); | 599 Send(new ViewMsg_AllowBindings(routing_id(), enabled_bindings_)); |
586 } | 600 } |
587 | 601 |
588 void RenderViewHost::SetWebUIProperty(const std::string& name, | 602 void RenderViewHost::SetWebUIProperty(const std::string& name, |
589 const std::string& value) { | 603 const std::string& value) { |
590 DCHECK(enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI); | 604 // This is just a sanity check before telling the renderer to enable the |
591 Send(new ViewMsg_SetWebUIProperty(routing_id(), name, value)); | 605 // property. It could lie and send the corresponding IPC messages anyway, |
| 606 // but we will not act on them if enabled_bindings_ doesn't agree. |
| 607 if (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) |
| 608 Send(new ViewMsg_SetWebUIProperty(routing_id(), name, value)); |
| 609 else |
| 610 NOTREACHED() << "WebUI bindings not enabled."; |
592 } | 611 } |
593 | 612 |
594 void RenderViewHost::GotFocus() { | 613 void RenderViewHost::GotFocus() { |
595 RenderWidgetHost::GotFocus(); // Notifies the renderer it got focus. | 614 RenderWidgetHost::GotFocus(); // Notifies the renderer it got focus. |
596 | 615 |
597 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 616 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
598 if (view) | 617 if (view) |
599 view->GotFocus(); | 618 view->GotFocus(); |
600 } | 619 } |
601 | 620 |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 | 1548 |
1530 void RenderViewHost::OnWebUISend(const GURL& source_url, | 1549 void RenderViewHost::OnWebUISend(const GURL& source_url, |
1531 const std::string& name, | 1550 const std::string& name, |
1532 const base::ListValue& args) { | 1551 const base::ListValue& args) { |
1533 delegate_->WebUISend(this, source_url, name, args); | 1552 delegate_->WebUISend(this, source_url, name, args); |
1534 } | 1553 } |
1535 | 1554 |
1536 void RenderViewHost::ClearPowerSaveBlockers() { | 1555 void RenderViewHost::ClearPowerSaveBlockers() { |
1537 STLDeleteValues(&power_save_blockers_); | 1556 STLDeleteValues(&power_save_blockers_); |
1538 } | 1557 } |
OLD | NEW |