| 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/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 1500 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 1501 RunTaskOnIOThreadAndWait(base::Bind(&BrowserTestClipboardScope::SetText, | 1501 RunTaskOnIOThreadAndWait(base::Bind(&BrowserTestClipboardScope::SetText, |
| 1502 base::Unretained(this), text)); | 1502 base::Unretained(this), text)); |
| 1503 return; | 1503 return; |
| 1504 } | 1504 } |
| 1505 #endif | 1505 #endif |
| 1506 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_COPY_PASTE); | 1506 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_COPY_PASTE); |
| 1507 clipboard_writer.WriteText(base::ASCIIToUTF16(text)); | 1507 clipboard_writer.WriteText(base::ASCIIToUTF16(text)); |
| 1508 } | 1508 } |
| 1509 | 1509 |
| 1510 class FrameFocusedObserver::FrameTreeNodeObserverImpl |
| 1511 : public FrameTreeNode::Observer { |
| 1512 public: |
| 1513 explicit FrameTreeNodeObserverImpl(FrameTreeNode* owner) |
| 1514 : owner_(owner), message_loop_runner_(new MessageLoopRunner) { |
| 1515 owner->AddObserver(this); |
| 1516 } |
| 1517 ~FrameTreeNodeObserverImpl() override { owner_->RemoveObserver(this); } |
| 1518 |
| 1519 void Run() { message_loop_runner_->Run(); } |
| 1520 |
| 1521 void OnFrameTreeNodeFocused(FrameTreeNode* node) override { |
| 1522 if (node == owner_) |
| 1523 message_loop_runner_->Quit(); |
| 1524 } |
| 1525 |
| 1526 private: |
| 1527 FrameTreeNode* owner_; |
| 1528 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 1529 }; |
| 1530 |
| 1531 FrameFocusedObserver::FrameFocusedObserver(RenderFrameHost* owner_host) |
| 1532 : impl_(new FrameTreeNodeObserverImpl( |
| 1533 static_cast<RenderFrameHostImpl*>(owner_host)->frame_tree_node())) {} |
| 1534 |
| 1535 FrameFocusedObserver::~FrameFocusedObserver() {} |
| 1536 |
| 1537 void FrameFocusedObserver::Wait() { |
| 1538 impl_->Run(); |
| 1539 } |
| 1540 |
| 1510 } // namespace content | 1541 } // namespace content |
| OLD | NEW |