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 "chrome/browser/automation/automation_provider_observers.h" | 5 #include "chrome/browser/automation/automation_provider_observers.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 void BrowserClosedNotificationObserver::Observe( | 871 void BrowserClosedNotificationObserver::Observe( |
872 int type, const content::NotificationSource& source, | 872 int type, const content::NotificationSource& source, |
873 const content::NotificationDetails& details) { | 873 const content::NotificationDetails& details) { |
874 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSED); | 874 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSED); |
875 | 875 |
876 if (!automation_) { | 876 if (!automation_) { |
877 delete this; | 877 delete this; |
878 return; | 878 return; |
879 } | 879 } |
880 | 880 |
881 content::Details<bool> close_app(details); | 881 int browser_count = static_cast<int>(BrowserList::size()); |
| 882 // We get the notification before the browser is removed from the BrowserList. |
| 883 bool app_closing = browser_count == 1; |
882 | 884 |
883 if (use_json_interface_) { | 885 if (use_json_interface_) { |
884 AutomationJSONReply(automation_, | 886 AutomationJSONReply(automation_, |
885 reply_message_.release()).SendSuccess(NULL); | 887 reply_message_.release()).SendSuccess(NULL); |
886 } else { | 888 } else { |
887 if (for_browser_command_) { | 889 if (for_browser_command_) { |
888 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(), | 890 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(), |
889 true); | 891 true); |
890 } else { | 892 } else { |
891 AutomationMsg_CloseBrowser::WriteReplyParams(reply_message_.get(), true, | 893 AutomationMsg_CloseBrowser::WriteReplyParams(reply_message_.get(), true, |
892 *(close_app.ptr())); | 894 app_closing); |
893 } | 895 } |
894 automation_->Send(reply_message_.release()); | 896 automation_->Send(reply_message_.release()); |
895 } | 897 } |
896 delete this; | 898 delete this; |
897 } | 899 } |
898 | 900 |
899 void BrowserClosedNotificationObserver::set_for_browser_command( | 901 void BrowserClosedNotificationObserver::set_for_browser_command( |
900 bool for_browser_command) { | 902 bool for_browser_command) { |
901 for_browser_command_ = for_browser_command; | 903 for_browser_command_ = for_browser_command; |
902 } | 904 } |
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3152 if (automation_) { | 3154 if (automation_) { |
3153 AutomationJSONReply(automation_, reply_message_.release()) | 3155 AutomationJSONReply(automation_, reply_message_.release()) |
3154 .SendSuccess(NULL); | 3156 .SendSuccess(NULL); |
3155 } | 3157 } |
3156 delete this; | 3158 delete this; |
3157 } | 3159 } |
3158 } else { | 3160 } else { |
3159 NOTREACHED(); | 3161 NOTREACHED(); |
3160 } | 3162 } |
3161 } | 3163 } |
OLD | NEW |