Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: chrome/browser/extensions/sandboxed_extension_unpacker.cc

Issue 9317074: Create an API around UtilityProcessHost and use that from chrome. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/extensions/sandboxed_extension_unpacker.h" 5 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/file_util_proxy.h" 12 #include "base/file_util_proxy.h"
13 #include "base/json/json_value_serializer.h" 13 #include "base/json/json_value_serializer.h"
14 #include "base/memory/scoped_handle.h" 14 #include "base/memory/scoped_handle.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/utf_string_conversions.h" // TODO(viettrungluu): delete me. 18 #include "base/utf_string_conversions.h" // TODO(viettrungluu): delete me.
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/chrome_utility_messages.h" 22 #include "chrome/common/chrome_utility_messages.h"
23 #include "chrome/common/extensions/extension_constants.h" 23 #include "chrome/common/extensions/extension_constants.h"
24 #include "chrome/common/extensions/extension_file_util.h" 24 #include "chrome/common/extensions/extension_file_util.h"
25 #include "chrome/common/extensions/extension_l10n_util.h" 25 #include "chrome/common/extensions/extension_l10n_util.h"
26 #include "chrome/common/extensions/extension_unpacker.h" 26 #include "chrome/common/extensions/extension_unpacker.h"
27 #include "content/browser/renderer_host/resource_dispatcher_host.h" 27 #include "content/browser/renderer_host/resource_dispatcher_host.h"
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/utility_process_host.h"
29 #include "crypto/signature_verifier.h" 30 #include "crypto/signature_verifier.h"
30 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
31 #include "third_party/skia/include/core/SkBitmap.h" 32 #include "third_party/skia/include/core/SkBitmap.h"
32 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
33 #include "ui/gfx/codec/png_codec.h" 34 #include "ui/gfx/codec/png_codec.h"
34 35
35 using content::BrowserThread; 36 using content::BrowserThread;
37 using content::UtilityProcessHost;
36 38
37 // The following macro makes histograms that record the length of paths 39 // The following macro makes histograms that record the length of paths
38 // in this file much easier to read. 40 // in this file much easier to read.
39 // Windows has a short max path length. If the path length to a 41 // Windows has a short max path length. If the path length to a
40 // file being unpacked from a CRX exceeds the max length, we might 42 // file being unpacked from a CRX exceeds the max length, we might
41 // fail to install. To see if this is happening, see how long the 43 // fail to install. To see if this is happening, see how long the
42 // path to the temp unpack directory is. See crbug.com/69693 . 44 // path to the temp unpack directory is. See crbug.com/69693 .
43 #define PATH_LENGTH_HISTOGRAM(name, path) \ 45 #define PATH_LENGTH_HISTOGRAM(name, path) \
44 UMA_HISTOGRAM_CUSTOM_COUNTS(name, path.value().length(), 0, 500, 100) 46 UMA_HISTOGRAM_CUSTOM_COUNTS(name, path.value().length(), 0, 500, 100)
45 47
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // Utility process crashed while trying to install. 306 // Utility process crashed while trying to install.
305 ReportFailure( 307 ReportFailure(
306 UTILITY_PROCESS_CRASHED_WHILE_TRYING_TO_INSTALL, 308 UTILITY_PROCESS_CRASHED_WHILE_TRYING_TO_INSTALL,
307 l10n_util::GetStringFUTF16( 309 l10n_util::GetStringFUTF16(
308 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, 310 IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
309 ASCIIToUTF16("UTILITY_PROCESS_CRASHED_WHILE_TRYING_TO_INSTALL"))); 311 ASCIIToUTF16("UTILITY_PROCESS_CRASHED_WHILE_TRYING_TO_INSTALL")));
310 } 312 }
311 313
312 void SandboxedExtensionUnpacker::StartProcessOnIOThread( 314 void SandboxedExtensionUnpacker::StartProcessOnIOThread(
313 const FilePath& temp_crx_path) { 315 const FilePath& temp_crx_path) {
314 UtilityProcessHost* host = new UtilityProcessHost(this, thread_identifier_); 316 UtilityProcessHost* host = UtilityProcessHost::Create(
317 this, thread_identifier_);
315 // Grant the subprocess access to the entire subdir the extension file is 318 // Grant the subprocess access to the entire subdir the extension file is
316 // in, so that it can unpack to that dir. 319 // in, so that it can unpack to that dir.
317 host->set_exposed_dir(temp_crx_path.DirName()); 320 host->SetExposedDir(temp_crx_path.DirName());
318 host->Send( 321 host->Send(
319 new ChromeUtilityMsg_UnpackExtension( 322 new ChromeUtilityMsg_UnpackExtension(
320 temp_crx_path, location_, creation_flags_)); 323 temp_crx_path, location_, creation_flags_));
321 } 324 }
322 325
323 void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded( 326 void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded(
324 const DictionaryValue& manifest) { 327 const DictionaryValue& manifest) {
325 // Skip check for unittests. 328 // Skip check for unittests.
326 if (thread_identifier_ != BrowserThread::ID_COUNT) 329 if (thread_identifier_ != BrowserThread::ID_COUNT)
327 CHECK(BrowserThread::CurrentlyOn(thread_identifier_)); 330 CHECK(BrowserThread::CurrentlyOn(thread_identifier_));
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 ERROR_SAVING_CATALOG, 771 ERROR_SAVING_CATALOG,
769 l10n_util::GetStringFUTF16( 772 l10n_util::GetStringFUTF16(
770 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, 773 IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
771 ASCIIToUTF16("ERROR_SAVING_CATALOG"))); 774 ASCIIToUTF16("ERROR_SAVING_CATALOG")));
772 return false; 775 return false;
773 } 776 }
774 } 777 }
775 778
776 return true; 779 return true;
777 } 780 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/sandboxed_extension_unpacker.h ('k') | chrome/browser/extensions/webstore_inline_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698