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/extensions/startup_helper.h" | 5 #include "chrome/browser/extensions/startup_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 error_= error; | 257 error_= error; |
258 done_callback_.Run(); | 258 done_callback_.Run(); |
259 } | 259 } |
260 | 260 |
261 void DeleteHelperAndRunCallback(AppInstallHelper* helper, | 261 void DeleteHelperAndRunCallback(AppInstallHelper* helper, |
262 base::Callback<void()> callback) { | 262 base::Callback<void()> callback) { |
263 delete helper; | 263 delete helper; |
264 callback.Run(); | 264 callback.Run(); |
265 } | 265 } |
266 | 266 |
| 267 void DeleteHelper(AppInstallHelper* helper) { |
| 268 delete helper; |
| 269 } |
| 270 |
267 } // namespace | 271 } // namespace |
268 | 272 |
269 bool StartupHelper::InstallFromWebstore(const CommandLine& cmd_line, | 273 bool StartupHelper::InstallFromWebstore(const CommandLine& cmd_line, |
270 Profile* profile) { | 274 Profile* profile) { |
271 std::string id = cmd_line.GetSwitchValueASCII(switches::kInstallFromWebstore); | 275 std::string id = cmd_line.GetSwitchValueASCII(switches::kInstallFromWebstore); |
272 if (!Extension::IdIsValid(id)) { | 276 if (!Extension::IdIsValid(id)) { |
273 LOG(ERROR) << "Invalid id for " << switches::kInstallFromWebstore | 277 LOG(ERROR) << "Invalid id for " << switches::kInstallFromWebstore |
274 << " : '" << id << "'"; | 278 << " : '" << id << "'"; |
275 return false; | 279 return false; |
276 } | 280 } |
(...skipping 18 matching lines...) Expand all Loading... |
295 done_callback.Run(); | 299 done_callback.Run(); |
296 return; | 300 return; |
297 } | 301 } |
298 | 302 |
299 AppInstallHelper* helper = new AppInstallHelper(); | 303 AppInstallHelper* helper = new AppInstallHelper(); |
300 helper->BeginInstall(profile, id, false /*show_prompt*/, | 304 helper->BeginInstall(profile, id, false /*show_prompt*/, |
301 base::Bind(&DeleteHelperAndRunCallback, | 305 base::Bind(&DeleteHelperAndRunCallback, |
302 helper, done_callback)); | 306 helper, done_callback)); |
303 } | 307 } |
304 | 308 |
| 309 void StartupHelper::InstallChromeApp( |
| 310 const CommandLine& cmd_line, |
| 311 Profile* profile) { |
| 312 std::string id = cmd_line.GetSwitchValueASCII(switches::kInstallChromeApp); |
| 313 if (!Extension::IdIsValid(id)) { |
| 314 LOG(ERROR) << "Invalid id for " << switches::kInstallChromeApp |
| 315 << " : '" << id << "'"; |
| 316 return; |
| 317 } |
| 318 |
| 319 AppInstallHelper* helper = new AppInstallHelper(); |
| 320 helper->BeginInstall(profile, id, true /*show_prompt*/, |
| 321 base::Bind(&DeleteHelper, helper)); |
| 322 } |
| 323 |
305 std::string StartupHelper::WebStoreIdFromLimitedInstallCmdLine( | 324 std::string StartupHelper::WebStoreIdFromLimitedInstallCmdLine( |
306 const CommandLine& cmd_line) { | 325 const CommandLine& cmd_line) { |
307 std::string index = cmd_line.GetSwitchValueASCII( | 326 std::string index = cmd_line.GetSwitchValueASCII( |
308 switches::kLimitedInstallFromWebstore); | 327 switches::kLimitedInstallFromWebstore); |
309 std::string id; | 328 std::string id; |
310 if (index == "1") { | 329 if (index == "1") { |
311 id = "nckgahadagoaajjgafhacjanaoiihapd"; | 330 id = "nckgahadagoaajjgafhacjanaoiihapd"; |
312 } else if (index == "2") { | 331 } else if (index == "2") { |
313 id = "ecglahbcnmdpdciemllbhojghbkagdje"; | 332 id = "ecglahbcnmdpdciemllbhojghbkagdje"; |
314 } | 333 } |
315 return id; | 334 return id; |
316 } | 335 } |
317 | 336 |
318 StartupHelper::~StartupHelper() { | 337 StartupHelper::~StartupHelper() { |
319 if (pack_job_.get()) | 338 if (pack_job_.get()) |
320 pack_job_->ClearClient(); | 339 pack_job_->ClearClient(); |
321 } | 340 } |
322 | 341 |
323 } // namespace extensions | 342 } // namespace extensions |
OLD | NEW |