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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/thread_task_runner_handle.h" |
8 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" | 14 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" |
13 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
14 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
15 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
16 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
17 #include "content/public/browser/render_widget_host_view.h" | 19 #include "content/public/browser/render_widget_host_view.h" |
(...skipping 29 matching lines...) Expand all Loading... |
47 } | 49 } |
48 | 50 |
49 private: | 51 private: |
50 // TODO(xiyuan): Update this when WidgetDelegate has bounds change hook. | 52 // TODO(xiyuan): Update this when WidgetDelegate has bounds change hook. |
51 void SaveWindowPlacement(const gfx::Rect& bounds, | 53 void SaveWindowPlacement(const gfx::Rect& bounds, |
52 ui::WindowShowState show_state) override { | 54 ui::WindowShowState show_state) override { |
53 if (should_quit_on_size_change_ && last_size_ != bounds.size()) { | 55 if (should_quit_on_size_change_ && last_size_ != bounds.size()) { |
54 // Schedule message loop quit because we could be called while | 56 // Schedule message loop quit because we could be called while |
55 // the bounds change call is on the stack and not in the nested message | 57 // the bounds change call is on the stack and not in the nested message |
56 // loop. | 58 // loop. |
57 base::MessageLoop::current()->PostTask( | 59 base::ThreadTaskRunnerHandle::Get()->PostTask( |
58 FROM_HERE, | 60 FROM_HERE, |
59 base::Bind(&base::MessageLoop::Quit, | 61 base::Bind(&base::MessageLoop::Quit, |
60 base::Unretained(base::MessageLoop::current()))); | 62 base::Unretained(base::MessageLoop::current()))); |
61 } | 63 } |
62 | 64 |
63 last_size_ = bounds.size(); | 65 last_size_ = bounds.size(); |
64 } | 66 } |
65 | 67 |
66 void OnDialogClosed(const std::string& json_retval) override { | 68 void OnDialogClosed(const std::string& json_retval) override { |
67 should_quit_on_size_change_ = false; // No quit when we are closing. | 69 should_quit_on_size_change_ = false; // No quit when we are closing. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 view_->GetWidget()->widget_delegate()->GetModalType()); | 228 view_->GetWidget()->widget_delegate()->GetModalType()); |
227 | 229 |
228 // Close the parent window. Tear down may happen asynchronously. | 230 // Close the parent window. Tear down may happen asynchronously. |
229 EXPECT_FALSE(web_dialog_delegate_destroyed_); | 231 EXPECT_FALSE(web_dialog_delegate_destroyed_); |
230 EXPECT_FALSE(web_dialog_view_destroyed_); | 232 EXPECT_FALSE(web_dialog_view_destroyed_); |
231 browser()->window()->Close(); | 233 browser()->window()->Close(); |
232 content::RunAllPendingInMessageLoop(); | 234 content::RunAllPendingInMessageLoop(); |
233 EXPECT_TRUE(web_dialog_delegate_destroyed_); | 235 EXPECT_TRUE(web_dialog_delegate_destroyed_); |
234 EXPECT_TRUE(web_dialog_view_destroyed_); | 236 EXPECT_TRUE(web_dialog_view_destroyed_); |
235 } | 237 } |
OLD | NEW |