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/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 delegate->GetDialogSize(&last_size_); | 44 delegate->GetDialogSize(&last_size_); |
45 } | 45 } |
46 | 46 |
47 void set_should_quit_on_size_change(bool should_quit) { | 47 void set_should_quit_on_size_change(bool should_quit) { |
48 should_quit_on_size_change_ = should_quit; | 48 should_quit_on_size_change_ = should_quit; |
49 } | 49 } |
50 | 50 |
51 private: | 51 private: |
52 // TODO(xiyuan): Update this when WidgetDelegate has bounds change hook. | 52 // TODO(xiyuan): Update this when WidgetDelegate has bounds change hook. |
53 virtual void SaveWindowPlacement(const gfx::Rect& bounds, | 53 virtual void SaveWindowPlacement(const gfx::Rect& bounds, |
54 ui::WindowShowState show_state) OVERRIDE { | 54 ui::WindowShowState show_state) override { |
55 if (should_quit_on_size_change_ && last_size_ != bounds.size()) { | 55 if (should_quit_on_size_change_ && last_size_ != bounds.size()) { |
56 // Schedule message loop quit because we could be called while | 56 // Schedule message loop quit because we could be called while |
57 // 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 |
58 // loop. | 58 // loop. |
59 base::MessageLoop::current()->PostTask( | 59 base::MessageLoop::current()->PostTask( |
60 FROM_HERE, | 60 FROM_HERE, |
61 base::Bind(&base::MessageLoop::Quit, | 61 base::Bind(&base::MessageLoop::Quit, |
62 base::Unretained(base::MessageLoop::current()))); | 62 base::Unretained(base::MessageLoop::current()))); |
63 } | 63 } |
64 | 64 |
65 last_size_ = bounds.size(); | 65 last_size_ = bounds.size(); |
66 } | 66 } |
67 | 67 |
68 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { | 68 virtual void OnDialogClosed(const std::string& json_retval) override { |
69 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. |
70 views::WebDialogView::OnDialogClosed(json_retval); | 70 views::WebDialogView::OnDialogClosed(json_retval); |
71 } | 71 } |
72 | 72 |
73 // Whether we should quit message loop when size change is detected. | 73 // Whether we should quit message loop when size change is detected. |
74 bool should_quit_on_size_change_; | 74 bool should_quit_on_size_change_; |
75 gfx::Size last_size_; | 75 gfx::Size last_size_; |
76 | 76 |
77 DISALLOW_COPY_AND_ASSIGN(TestWebDialogView); | 77 DISALLOW_COPY_AND_ASSIGN(TestWebDialogView); |
78 }; | 78 }; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 EXPECT_EQ(min_size, actual_bounds.size()); | 181 EXPECT_EQ(min_size, actual_bounds.size()); |
182 | 182 |
183 // And that the render view is also non-zero. | 183 // And that the render view is also non-zero. |
184 rwhv_bounds = | 184 rwhv_bounds = |
185 view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); | 185 view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); |
186 EXPECT_LT(0, rwhv_bounds.width()); | 186 EXPECT_LT(0, rwhv_bounds.width()); |
187 EXPECT_LT(0, rwhv_bounds.height()); | 187 EXPECT_LT(0, rwhv_bounds.height()); |
188 | 188 |
189 view->GetWidget()->CloseNow(); | 189 view->GetWidget()->CloseNow(); |
190 } | 190 } |
OLD | NEW |