Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1558 // path. | 1558 // path. |
| 1559 if (params.default_file_name != params.default_file_name.BaseName()) { | 1559 if (params.default_file_name != params.default_file_name.BaseName()) { |
| 1560 bad_message::ReceivedBadMessage(GetProcess(), | 1560 bad_message::ReceivedBadMessage(GetProcess(), |
| 1561 bad_message::RFH_FILE_CHOOSER_PATH); | 1561 bad_message::RFH_FILE_CHOOSER_PATH); |
| 1562 return; | 1562 return; |
| 1563 } | 1563 } |
| 1564 | 1564 |
| 1565 delegate_->RunFileChooser(this, params); | 1565 delegate_->RunFileChooser(this, params); |
| 1566 } | 1566 } |
| 1567 | 1567 |
| 1568 void RenderFrameHostImpl::RequestTextSurroundingSelection( | |
| 1569 const TextSurroundingSelectionCallback& callback, | |
| 1570 int max_length) { | |
| 1571 // Only one outstanding request is allowed at any given time. | |
| 1572 // If already one request is in progress, then immediately release callback | |
| 1573 // with empty result. | |
| 1574 if (!text_surrounding_selection_callback_.is_null()) { | |
| 1575 callback.Run(base::string16(), 0, 0); | |
| 1576 return; | |
| 1577 } | |
| 1578 DCHECK(!callback.is_null()); | |
|
no sievers
2016/07/20 21:14:32
nit: move the DCHECK() to the top since you run it
AKV
2016/07/21 09:13:52
Done.
| |
| 1579 text_surrounding_selection_callback_ = callback; | |
| 1580 Send( | |
| 1581 new FrameMsg_TextSurroundingSelectionRequest(GetRoutingID(), max_length)); | |
| 1582 } | |
| 1583 | |
| 1568 void RenderFrameHostImpl::OnTextSurroundingSelectionResponse( | 1584 void RenderFrameHostImpl::OnTextSurroundingSelectionResponse( |
| 1569 const base::string16& content, | 1585 const base::string16& content, |
| 1570 uint32_t start_offset, | 1586 uint32_t start_offset, |
| 1571 uint32_t end_offset) { | 1587 uint32_t end_offset) { |
| 1572 render_view_host_->OnTextSurroundingSelectionResponse( | 1588 // Just Run the callback instead of propagating further. |
| 1573 content, start_offset, end_offset); | 1589 text_surrounding_selection_callback_.Run(content, start_offset, end_offset); |
| 1590 // Reset the callback for enabling early exit from future request. | |
| 1591 text_surrounding_selection_callback_.Reset(); | |
| 1574 } | 1592 } |
| 1575 | 1593 |
| 1576 void RenderFrameHostImpl::OnDidAccessInitialDocument() { | 1594 void RenderFrameHostImpl::OnDidAccessInitialDocument() { |
| 1577 delegate_->DidAccessInitialDocument(); | 1595 delegate_->DidAccessInitialDocument(); |
| 1578 } | 1596 } |
| 1579 | 1597 |
| 1580 void RenderFrameHostImpl::OnDidChangeOpener(int32_t opener_routing_id) { | 1598 void RenderFrameHostImpl::OnDidChangeOpener(int32_t opener_routing_id) { |
| 1581 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id, | 1599 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id, |
| 1582 GetSiteInstance()); | 1600 GetSiteInstance()); |
| 1583 } | 1601 } |
| (...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2974 // handler after it's destroyed so it can't run after the RFHI is destroyed. | 2992 // handler after it's destroyed so it can't run after the RFHI is destroyed. |
| 2975 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( | 2993 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( |
| 2976 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); | 2994 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); |
| 2977 } | 2995 } |
| 2978 | 2996 |
| 2979 void RenderFrameHostImpl::DeleteWebBluetoothService() { | 2997 void RenderFrameHostImpl::DeleteWebBluetoothService() { |
| 2980 web_bluetooth_service_.reset(); | 2998 web_bluetooth_service_.reset(); |
| 2981 } | 2999 } |
| 2982 | 3000 |
| 2983 } // namespace content | 3001 } // namespace content |
| OLD | NEW |