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

Side by Side Diff: chrome/browser/browser_init.cc

Issue 118328: chrome.exe --package-extension (Closed)
Patch Set: final Created 11 years, 6 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
« no previous file with comments | « chrome/browser/browser.vcproj ('k') | chrome/browser/extensions/extension_creator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/browser_init.h" 5 #include "chrome/browser/browser_init.h"
6 6
7 #if defined(OS_WIN)
8 #include "app/win_util.h"
9 #endif
7 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 11 #include "app/resource_bundle.h"
9 #include "base/basictypes.h" 12 #include "base/basictypes.h"
10 #include "base/command_line.h" 13 #include "base/command_line.h"
11 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
12 #include "base/event_recorder.h" 15 #include "base/event_recorder.h"
13 #include "base/file_path.h" 16 #include "base/file_path.h"
17 #include "base/file_util.h"
14 #include "base/histogram.h" 18 #include "base/histogram.h"
15 #include "base/path_service.h" 19 #include "base/path_service.h"
16 #include "base/string_util.h" 20 #include "base/string_util.h"
17 #include "base/sys_info.h" 21 #include "base/sys_info.h"
18 #include "chrome/browser/autocomplete/autocomplete.h" 22 #include "chrome/browser/autocomplete/autocomplete.h"
19 #include "chrome/browser/automation/automation_provider.h" 23 #include "chrome/browser/automation/automation_provider.h"
20 #include "chrome/browser/automation/automation_provider_list.h" 24 #include "chrome/browser/automation/automation_provider_list.h"
21 #include "chrome/browser/browser_list.h" 25 #include "chrome/browser/browser_list.h"
22 #include "chrome/browser/browser_process.h" 26 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/browser_window.h" 27 #include "chrome/browser/browser_window.h"
28 #if defined(OS_WIN) // TODO(port)
29 #include "chrome/browser/extensions/extension_creator.h"
30 #endif
24 #include "chrome/browser/extensions/extensions_service.h" 31 #include "chrome/browser/extensions/extensions_service.h"
25 #include "chrome/browser/extensions/user_script_master.h" 32 #include "chrome/browser/extensions/user_script_master.h"
26 #include "chrome/browser/first_run.h" 33 #include "chrome/browser/first_run.h"
27 #include "chrome/browser/net/dns_global.h" 34 #include "chrome/browser/net/dns_global.h"
28 #include "chrome/browser/profile.h" 35 #include "chrome/browser/profile.h"
29 #include "chrome/browser/renderer_host/render_process_host.h" 36 #include "chrome/browser/renderer_host/render_process_host.h"
30 #include "chrome/browser/search_engines/template_url_model.h" 37 #include "chrome/browser/search_engines/template_url_model.h"
31 #include "chrome/browser/session_startup_pref.h" 38 #include "chrome/browser/session_startup_pref.h"
32 #include "chrome/browser/sessions/session_restore.h" 39 #include "chrome/browser/sessions/session_restore.h"
33 #include "chrome/browser/shell_integration.h" 40 #include "chrome/browser/shell_integration.h"
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 689
683 // Extension should be loaded from path which is specified by flag 690 // Extension should be loaded from path which is specified by flag
684 // |kLoadExtension| once and only when the browser process is starting up. 691 // |kLoadExtension| once and only when the browser process is starting up.
685 if (command_line.HasSwitch(switches::kLoadExtension)) { 692 if (command_line.HasSwitch(switches::kLoadExtension)) {
686 std::wstring path_string = 693 std::wstring path_string =
687 command_line.GetSwitchValue(switches::kLoadExtension); 694 command_line.GetSwitchValue(switches::kLoadExtension);
688 FilePath path = FilePath::FromWStringHack(path_string); 695 FilePath path = FilePath::FromWStringHack(path_string);
689 profile->GetExtensionsService()->LoadExtension(path); 696 profile->GetExtensionsService()->LoadExtension(path);
690 profile->GetUserScriptMaster()->AddWatchedPath(path); 697 profile->GetUserScriptMaster()->AddWatchedPath(path);
691 } 698 }
699
700 if (command_line.HasSwitch(switches::kPackExtension)) {
701 // Input Paths.
702 FilePath src_dir = FilePath::FromWStringHack(command_line.GetSwitchValue(
703 switches::kPackExtension));
704 FilePath private_key_path;
705 if (command_line.HasSwitch(switches::kPackExtensionKey)) {
706 private_key_path = FilePath::FromWStringHack(
707 command_line.GetSwitchValue(switches::kPackExtensionKey));
708 }
709
710 // Output Paths.
711 FilePath output(src_dir.DirName().Append(src_dir.BaseName().value()));
712 FilePath crx_path(output);
713 crx_path = crx_path.ReplaceExtension(chrome::kExtensionFileExtension);
714 FilePath output_private_key_path;
715 if (private_key_path.empty()) {
716 output_private_key_path = FilePath(output);
717 output_private_key_path =
718 output_private_key_path.ReplaceExtension(FILE_PATH_LITERAL("pem"));
719 }
720
721 // TODO(port): Creation & running is removed from mac & linux because
722 // ExtensionCreator depends on base/crypto/rsa_private_key and
723 // base/crypto/signature_creator, both of which only have windows
724 // implementations.
725 #if defined(OS_WIN)
726 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator());
727 if (!creator->Run(src_dir, crx_path, private_key_path,
728 output_private_key_path)) {
729 win_util::MessageBox(NULL, UTF8ToWide(creator->error_message()),
730 L"Extension Packaging Error", MB_OK | MB_SETFOREGROUND);
731 return false;
732 }
733 #endif // defined(OS_WIN)
734 return false;
735 }
692 } 736 }
693 737
694 // Allow the command line to override the persisted setting of home page. 738 // Allow the command line to override the persisted setting of home page.
695 SetOverrideHomePage(command_line, profile->GetPrefs()); 739 SetOverrideHomePage(command_line, profile->GetPrefs());
696 740
697 bool silent_launch = false; 741 bool silent_launch = false;
698 if (command_line.HasSwitch(switches::kAutomationClientChannelID)) { 742 if (command_line.HasSwitch(switches::kAutomationClientChannelID)) {
699 std::string automation_channel_id = WideToASCII( 743 std::string automation_channel_id = WideToASCII(
700 command_line.GetSwitchValue(switches::kAutomationClientChannelID)); 744 command_line.GetSwitchValue(switches::kAutomationClientChannelID));
701 // If there are any loose parameters, we expect each one to generate a 745 // If there are any loose parameters, we expect each one to generate a
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 scoped_refptr<AutomationProviderClass> automation = 780 scoped_refptr<AutomationProviderClass> automation =
737 new AutomationProviderClass(profile); 781 new AutomationProviderClass(profile);
738 automation->ConnectToChannel(channel_id); 782 automation->ConnectToChannel(channel_id);
739 automation->SetExpectedTabCount(expected_tabs); 783 automation->SetExpectedTabCount(expected_tabs);
740 784
741 AutomationProviderList* list = 785 AutomationProviderList* list =
742 g_browser_process->InitAutomationProviderList(); 786 g_browser_process->InitAutomationProviderList();
743 DCHECK(list); 787 DCHECK(list);
744 list->AddProvider(automation); 788 list->AddProvider(automation);
745 } 789 }
OLDNEW
« no previous file with comments | « chrome/browser/browser.vcproj ('k') | chrome/browser/extensions/extension_creator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698