OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 using extensions::Extension; | 188 using extensions::Extension; |
189 using extensions::ExtensionActionManager; | 189 using extensions::ExtensionActionManager; |
190 using extensions::ExtensionList; | 190 using extensions::ExtensionList; |
191 using extensions::Manifest; | 191 using extensions::Manifest; |
192 | 192 |
193 namespace { | 193 namespace { |
194 | 194 |
195 // Helper to reply asynchronously if |automation| is still valid. | 195 // Helper to reply asynchronously if |automation| is still valid. |
196 void SendSuccessReply(base::WeakPtr<AutomationProvider> automation, | 196 void SendSuccessReply(base::WeakPtr<AutomationProvider> automation, |
197 IPC::Message* reply_message) { | 197 IPC::Message* reply_message) { |
198 if (automation) | 198 if (automation.get()) |
199 AutomationJSONReply(automation.get(), reply_message).SendSuccess(NULL); | 199 AutomationJSONReply(automation.get(), reply_message).SendSuccess(NULL); |
200 } | 200 } |
201 | 201 |
202 // Helper to process the result of CanEnablePlugin. | 202 // Helper to process the result of CanEnablePlugin. |
203 void DidEnablePlugin(base::WeakPtr<AutomationProvider> automation, | 203 void DidEnablePlugin(base::WeakPtr<AutomationProvider> automation, |
204 IPC::Message* reply_message, | 204 IPC::Message* reply_message, |
205 const base::FilePath::StringType& path, | 205 const base::FilePath::StringType& path, |
206 const std::string& error_msg, | 206 const std::string& error_msg, |
207 bool did_enable) { | 207 bool did_enable) { |
208 if (did_enable) { | 208 if (did_enable) { |
209 SendSuccessReply(automation, reply_message); | 209 SendSuccessReply(automation, reply_message); |
210 } else { | 210 } else { |
211 if (automation) { | 211 if (automation.get()) { |
212 AutomationJSONReply(automation.get(), reply_message).SendError( | 212 AutomationJSONReply(automation.get(), reply_message) |
213 base::StringPrintf(error_msg.c_str(), path.c_str())); | 213 .SendError(base::StringPrintf(error_msg.c_str(), path.c_str())); |
214 } | 214 } |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 // Helper to resolve the overloading of PostTask. | 218 // Helper to resolve the overloading of PostTask. |
219 void PostTask(BrowserThread::ID id, const base::Closure& callback) { | 219 void PostTask(BrowserThread::ID id, const base::Closure& callback) { |
220 BrowserThread::PostTask(id, FROM_HERE, callback); | 220 BrowserThread::PostTask(id, FROM_HERE, callback); |
221 } | 221 } |
222 | 222 |
223 class AutomationInterstitialPage : public content::InterstitialPageDelegate { | 223 class AutomationInterstitialPage : public content::InterstitialPageDelegate { |
(...skipping 3809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4033 params.callback = base::Bind(&ExtensionsUpdatedObserver::UpdateCheckFinished, | 4033 params.callback = base::Bind(&ExtensionsUpdatedObserver::UpdateCheckFinished, |
4034 base::Unretained(observer)); | 4034 base::Unretained(observer)); |
4035 updater->CheckNow(params); | 4035 updater->CheckNow(params); |
4036 } | 4036 } |
4037 | 4037 |
4038 namespace { | 4038 namespace { |
4039 | 4039 |
4040 void SendSuccessIfAlive( | 4040 void SendSuccessIfAlive( |
4041 base::WeakPtr<AutomationProvider> provider, | 4041 base::WeakPtr<AutomationProvider> provider, |
4042 IPC::Message* reply_message) { | 4042 IPC::Message* reply_message) { |
4043 if (provider) | 4043 if (provider.get()) |
4044 AutomationJSONReply(provider.get(), reply_message).SendSuccess(NULL); | 4044 AutomationJSONReply(provider.get(), reply_message).SendSuccess(NULL); |
4045 } | 4045 } |
4046 | 4046 |
4047 } // namespace | 4047 } // namespace |
4048 | 4048 |
4049 void TestingAutomationProvider::OverrideGeoposition( | 4049 void TestingAutomationProvider::OverrideGeoposition( |
4050 base::DictionaryValue* args, | 4050 base::DictionaryValue* args, |
4051 IPC::Message* reply_message) { | 4051 IPC::Message* reply_message) { |
4052 double latitude, longitude, altitude; | 4052 double latitude, longitude, altitude; |
4053 if (!args->GetDouble("latitude", &latitude) || | 4053 if (!args->GetDouble("latitude", &latitude) || |
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5685 if (g_browser_process) | 5685 if (g_browser_process) |
5686 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 5686 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
5687 } | 5687 } |
5688 | 5688 |
5689 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 5689 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
5690 WebContents* tab) { | 5690 WebContents* tab) { |
5691 TabStripModel* tab_strip = browser->tab_strip_model(); | 5691 TabStripModel* tab_strip = browser->tab_strip_model(); |
5692 if (tab_strip->GetActiveWebContents() != tab) | 5692 if (tab_strip->GetActiveWebContents() != tab) |
5693 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); | 5693 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); |
5694 } | 5694 } |
OLD | NEW |