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 <algorithm> | 5 #include <algorithm> |
6 #include <iterator> | 6 #include <iterator> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 pending_async_completed_(false), | 106 pending_async_completed_(false), |
107 num_inline_disposition_(0), | 107 num_inline_disposition_(0), |
108 delegate_(NULL) { | 108 delegate_(NULL) { |
109 } | 109 } |
110 | 110 |
111 void MockClose() { | 111 void MockClose() { |
112 delegate_->OnClosing(); | 112 delegate_->OnClosing(); |
113 } | 113 } |
114 | 114 |
115 // WebIntentPicker implementation. | 115 // WebIntentPicker implementation. |
116 virtual void Close() OVERRIDE {} | 116 virtual void Close() OVERRIDE { StopWaiting(); } |
117 virtual void SetActionString(const string16& action) OVERRIDE {} | 117 virtual void SetActionString(const string16& action) OVERRIDE {} |
118 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE { | 118 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE { |
119 num_extensions_installed_++; | 119 num_extensions_installed_++; |
120 } | 120 } |
121 virtual void OnExtensionInstallFailure(const std::string& id) OVERRIDE {} | 121 virtual void OnExtensionInstallFailure(const std::string& id) OVERRIDE {} |
122 virtual void OnInlineDispositionAutoResize(const gfx::Size& size) OVERRIDE {} | 122 virtual void OnInlineDispositionAutoResize(const gfx::Size& size) OVERRIDE {} |
123 virtual void OnPendingAsyncCompleted() OVERRIDE { | 123 virtual void OnPendingAsyncCompleted() OVERRIDE { |
124 StopWaiting(); | 124 StopWaiting(); |
125 } | 125 } |
126 | 126 |
(...skipping 18 matching lines...) Expand all Loading... |
145 void Wait() { | 145 void Wait() { |
146 if (!pending_async_completed_) { | 146 if (!pending_async_completed_) { |
147 message_loop_started_ = true; | 147 message_loop_started_ = true; |
148 content::RunMessageLoop(); | 148 content::RunMessageLoop(); |
149 pending_async_completed_ = false; | 149 pending_async_completed_ = false; |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 void StopWaiting() { | 153 void StopWaiting() { |
154 pending_async_completed_ = true; | 154 pending_async_completed_ = true; |
155 if (message_loop_started_) | 155 if (message_loop_started_) { |
| 156 message_loop_started_ = false; |
156 MessageLoop::current()->Quit(); | 157 MessageLoop::current()->Quit(); |
| 158 } |
157 } | 159 } |
158 | 160 |
159 int num_installed_services_; | 161 int num_installed_services_; |
160 int num_icons_changed_; | 162 int num_icons_changed_; |
161 int num_extension_icons_changed_; | 163 int num_extension_icons_changed_; |
162 int num_extensions_installed_; | 164 int num_extensions_installed_; |
163 bool message_loop_started_; | 165 bool message_loop_started_; |
164 bool pending_async_completed_; | 166 bool pending_async_completed_; |
165 int num_inline_disposition_; | 167 int num_inline_disposition_; |
166 WebIntentPickerDelegate* delegate_; | 168 WebIntentPickerDelegate* delegate_; |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 | 637 |
636 EXPECT_EQ(2, picker_.num_installed_services_); | 638 EXPECT_EQ(2, picker_.num_installed_services_); |
637 | 639 |
638 // The tab is shown immediately without needing to call OnServiceChosen. | 640 // The tab is shown immediately without needing to call OnServiceChosen. |
639 ASSERT_EQ(2, browser()->tab_count()); | 641 ASSERT_EQ(2, browser()->tab_count()); |
640 EXPECT_EQ(GURL(kServiceURL1), | 642 EXPECT_EQ(GURL(kServiceURL1), |
641 chrome::GetActiveWebContents(browser())->GetURL()); | 643 chrome::GetActiveWebContents(browser())->GetURL()); |
642 | 644 |
643 EXPECT_TRUE(dispatcher.dispatched_); | 645 EXPECT_TRUE(dispatcher.dispatched_); |
644 } | 646 } |
OLD | NEW |