OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 1991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2002 AllTabsStoppedLoadingObserver::~AllTabsStoppedLoadingObserver() {} | 2002 AllTabsStoppedLoadingObserver::~AllTabsStoppedLoadingObserver() {} |
2003 | 2003 |
2004 void AllTabsStoppedLoadingObserver::Observe( | 2004 void AllTabsStoppedLoadingObserver::Observe( |
2005 NotificationType type, | 2005 NotificationType type, |
2006 const NotificationSource& source, | 2006 const NotificationSource& source, |
2007 const NotificationDetails& details) { | 2007 const NotificationDetails& details) { |
2008 CheckIfStopped(); | 2008 CheckIfStopped(); |
2009 } | 2009 } |
2010 | 2010 |
2011 void AllTabsStoppedLoadingObserver::CheckIfStopped() { | 2011 void AllTabsStoppedLoadingObserver::CheckIfStopped() { |
2012 if (!automation_) { | |
2013 delete this; | |
2014 return; | |
2015 } | |
2012 bool done_loading = true; | 2016 bool done_loading = true; |
2013 BrowserList::const_iterator iter = BrowserList::begin(); | 2017 BrowserList::const_iterator iter = BrowserList::begin(); |
2014 for (; iter != BrowserList::end(); ++iter) { | 2018 for (; iter != BrowserList::end(); ++iter) { |
2015 Browser* browser = *iter; | 2019 Browser* browser = *iter; |
2016 for (int i = 0; i < browser->tab_count(); ++i) { | 2020 for (int i = 0; i < browser->tab_count(); ++i) { |
2017 TabContents* tab = browser->GetTabContentsAt(i); | 2021 TabContents* tab = browser->GetTabContentsAt(i); |
2018 if (tab->is_loading()) { | 2022 if (tab->is_loading()) { |
2019 done_loading = false; | 2023 done_loading = false; |
2020 break; | 2024 break; |
2021 } | 2025 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2088 NewRunnableMethod( | 2092 NewRunnableMethod( |
2089 this, | 2093 this, |
2090 &WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread)); | 2094 &WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread)); |
2091 } | 2095 } |
2092 | 2096 |
2093 void WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread() { | 2097 void WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread() { |
2094 if (automation_) | 2098 if (automation_) |
2095 automation_->Send(reply_message_.release()); | 2099 automation_->Send(reply_message_.release()); |
2096 Release(); | 2100 Release(); |
2097 } | 2101 } |
2102 | |
2103 ExecuteJavascriptObserver::ExecuteJavascriptObserver( | |
2104 AutomationProvider* automation, | |
2105 IPC::Message* reply_message) | |
2106 : automation_(automation->AsWeakPtr()), | |
2107 reply_message_(reply_message) { | |
2108 } | |
2109 | |
2110 ExecuteJavascriptObserver::~ExecuteJavascriptObserver() { | |
2111 } | |
2112 | |
2113 void ExecuteJavascriptObserver::OnDomOperationCompleted(const std::string& json) { | |
Paweł Hajdan Jr.
2011/03/05 11:44:56
nit: 80 cols.
kkania
2011/03/07 04:31:51
Done.
| |
2114 if (automation_) { | |
2115 DictionaryValue dict; | |
2116 dict.SetString("result", json); | |
2117 AutomationJSONReply(automation_, reply_message_.release()) | |
2118 .SendSuccess(&dict); | |
2119 } | |
2120 delete this; | |
2121 } | |
OLD | NEW |