| 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" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/sandboxed_unpacker.h" | 17 #include "chrome/browser/extensions/sandboxed_unpacker.h" |
| 18 #include "chrome/browser/extensions/webstore_startup_installer.h" | 18 #include "chrome/browser/extensions/webstore_startup_installer.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/extensions/chrome_extensions_client.h" | 21 #include "chrome/common/extensions/chrome_extensions_client.h" |
| 22 #include "components/crx_file/id_util.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 24 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
| 25 #include "ipc/ipc_message.h" | 26 #include "ipc/ipc_message.h" |
| 26 | 27 |
| 27 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 28 #include "apps/app_window.h" | 29 #include "apps/app_window.h" |
| 29 #include "apps/app_window_registry.h" | 30 #include "apps/app_window_registry.h" |
| 30 #include "extensions/browser/extension_registry.h" | 31 #include "extensions/browser/extension_registry.h" |
| 31 #include "extensions/browser/extension_util.h" | 32 #include "extensions/browser/extension_util.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 base::Callback<void()> callback) { | 307 base::Callback<void()> callback) { |
| 307 delete helper; | 308 delete helper; |
| 308 callback.Run(); | 309 callback.Run(); |
| 309 } | 310 } |
| 310 | 311 |
| 311 } // namespace | 312 } // namespace |
| 312 | 313 |
| 313 bool StartupHelper::InstallFromWebstore(const CommandLine& cmd_line, | 314 bool StartupHelper::InstallFromWebstore(const CommandLine& cmd_line, |
| 314 Profile* profile) { | 315 Profile* profile) { |
| 315 std::string id = cmd_line.GetSwitchValueASCII(switches::kInstallFromWebstore); | 316 std::string id = cmd_line.GetSwitchValueASCII(switches::kInstallFromWebstore); |
| 316 if (!Extension::IdIsValid(id)) { | 317 if (!crx_file::id_util::IdIsValid(id)) { |
| 317 LOG(ERROR) << "Invalid id for " << switches::kInstallFromWebstore | 318 LOG(ERROR) << "Invalid id for " << switches::kInstallFromWebstore |
| 318 << " : '" << id << "'"; | 319 << " : '" << id << "'"; |
| 319 return false; | 320 return false; |
| 320 } | 321 } |
| 321 | 322 |
| 322 AppInstallHelper helper; | 323 AppInstallHelper helper; |
| 323 base::RunLoop run_loop; | 324 base::RunLoop run_loop; |
| 324 helper.BeginInstall(profile, id, true, run_loop.QuitClosure()); | 325 helper.BeginInstall(profile, id, true, run_loop.QuitClosure()); |
| 325 run_loop.Run(); | 326 run_loop.Run(); |
| 326 | 327 |
| 327 if (!helper.success()) | 328 if (!helper.success()) |
| 328 LOG(ERROR) << "InstallFromWebstore failed with error: " << helper.error(); | 329 LOG(ERROR) << "InstallFromWebstore failed with error: " << helper.error(); |
| 329 return helper.success(); | 330 return helper.success(); |
| 330 } | 331 } |
| 331 | 332 |
| 332 void StartupHelper::LimitedInstallFromWebstore( | 333 void StartupHelper::LimitedInstallFromWebstore( |
| 333 const CommandLine& cmd_line, | 334 const CommandLine& cmd_line, |
| 334 Profile* profile, | 335 Profile* profile, |
| 335 base::Callback<void()> done_callback) { | 336 base::Callback<void()> done_callback) { |
| 336 std::string id = WebStoreIdFromLimitedInstallCmdLine(cmd_line); | 337 std::string id = WebStoreIdFromLimitedInstallCmdLine(cmd_line); |
| 337 if (!Extension::IdIsValid(id)) { | 338 if (!crx_file::id_util::IdIsValid(id)) { |
| 338 LOG(ERROR) << "Invalid index for " << switches::kLimitedInstallFromWebstore; | 339 LOG(ERROR) << "Invalid index for " << switches::kLimitedInstallFromWebstore; |
| 339 done_callback.Run(); | 340 done_callback.Run(); |
| 340 return; | 341 return; |
| 341 } | 342 } |
| 342 | 343 |
| 343 AppInstallHelper* helper = new AppInstallHelper(); | 344 AppInstallHelper* helper = new AppInstallHelper(); |
| 344 helper->BeginInstall(profile, id, false /*show_prompt*/, | 345 helper->BeginInstall(profile, id, false /*show_prompt*/, |
| 345 base::Bind(&DeleteHelperAndRunCallback, | 346 base::Bind(&DeleteHelperAndRunCallback, |
| 346 helper, done_callback)); | 347 helper, done_callback)); |
| 347 } | 348 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 358 } | 359 } |
| 359 return id; | 360 return id; |
| 360 } | 361 } |
| 361 | 362 |
| 362 StartupHelper::~StartupHelper() { | 363 StartupHelper::~StartupHelper() { |
| 363 if (pack_job_.get()) | 364 if (pack_job_.get()) |
| 364 pack_job_->ClearClient(); | 365 pack_job_->ClearClient(); |
| 365 } | 366 } |
| 366 | 367 |
| 367 } // namespace extensions | 368 } // namespace extensions |
| OLD | NEW |