OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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_main.h" | 5 #include "chrome/browser/browser_main.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "chrome/browser/profile_manager.h" | 44 #include "chrome/browser/profile_manager.h" |
45 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 45 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
46 #include "chrome/browser/shell_integration.h" | 46 #include "chrome/browser/shell_integration.h" |
47 #include "chrome/browser/user_data_manager.h" | 47 #include "chrome/browser/user_data_manager.h" |
48 #include "chrome/common/chrome_constants.h" | 48 #include "chrome/common/chrome_constants.h" |
49 #include "chrome/common/chrome_paths.h" | 49 #include "chrome/common/chrome_paths.h" |
50 #include "chrome/common/chrome_switches.h" | 50 #include "chrome/common/chrome_switches.h" |
51 #include "chrome/common/histogram_synchronizer.h" | 51 #include "chrome/common/histogram_synchronizer.h" |
52 #include "chrome/common/jstemplate_builder.h" | 52 #include "chrome/common/jstemplate_builder.h" |
53 #include "chrome/common/main_function_params.h" | 53 #include "chrome/common/main_function_params.h" |
| 54 #include "chrome/common/net/net_resource_provider.h" |
54 #include "chrome/common/pref_names.h" | 55 #include "chrome/common/pref_names.h" |
55 #include "chrome/common/pref_service.h" | 56 #include "chrome/common/pref_service.h" |
56 #include "chrome/common/result_codes.h" | 57 #include "chrome/common/result_codes.h" |
57 #include "chrome/installer/util/google_update_settings.h" | 58 #include "chrome/installer/util/google_update_settings.h" |
58 #include "chrome/installer/util/master_preferences.h" | 59 #include "chrome/installer/util/master_preferences.h" |
59 #include "grit/chromium_strings.h" | 60 #include "grit/chromium_strings.h" |
60 #include "grit/generated_resources.h" | 61 #include "grit/generated_resources.h" |
61 #include "grit/net_resources.h" | |
62 #include "net/base/cookie_monster.h" | 62 #include "net/base/cookie_monster.h" |
63 #include "net/base/net_module.h" | 63 #include "net/base/net_module.h" |
64 #include "net/http/http_network_session.h" | 64 #include "net/http/http_network_session.h" |
65 #include "net/socket/client_socket_pool_base.h" | 65 #include "net/socket/client_socket_pool_base.h" |
66 | 66 |
67 #if defined(OS_POSIX) | 67 #if defined(OS_POSIX) |
68 // TODO(port): get rid of this include. It's used just to provide declarations | 68 // TODO(port): get rid of this include. It's used just to provide declarations |
69 // and stub definitions for classes we encouter during the porting effort. | 69 // and stub definitions for classes we encouter during the porting effort. |
70 #include "chrome/common/temp_scaffolding_stubs.h" | 70 #include "chrome/common/temp_scaffolding_stubs.h" |
71 #include <errno.h> | 71 #include <errno.h> |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 DCHECK(false); | 135 DCHECK(false); |
136 } | 136 } |
137 | 137 |
138 // This parameter causes a null pointer crash (crash reporter trigger). | 138 // This parameter causes a null pointer crash (crash reporter trigger). |
139 if (command_line.HasSwitch(switches::kBrowserCrashTest)) { | 139 if (command_line.HasSwitch(switches::kBrowserCrashTest)) { |
140 int* bad_pointer = NULL; | 140 int* bad_pointer = NULL; |
141 *bad_pointer = 0; | 141 *bad_pointer = 0; |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 // The net module doesn't have access to this HTML or the strings that need to | |
146 // be localized. The Chrome locale will never change while we're running, so | |
147 // it's safe to have a static string that we always return a pointer into. | |
148 // This allows us to have the ResourceProvider return a pointer into the actual | |
149 // resource (via a StringPiece), instead of always copying resources. | |
150 struct LazyDirectoryListerCacher { | |
151 LazyDirectoryListerCacher() { | |
152 DictionaryValue value; | |
153 value.SetString(L"header", | |
154 l10n_util::GetString(IDS_DIRECTORY_LISTING_HEADER)); | |
155 value.SetString(L"parentDirText", | |
156 l10n_util::GetString(IDS_DIRECTORY_LISTING_PARENT)); | |
157 value.SetString(L"headerName", | |
158 l10n_util::GetString(IDS_DIRECTORY_LISTING_NAME)); | |
159 value.SetString(L"headerSize", | |
160 l10n_util::GetString(IDS_DIRECTORY_LISTING_SIZE)); | |
161 value.SetString(L"headerDateModified", | |
162 l10n_util::GetString(IDS_DIRECTORY_LISTING_DATE_MODIFIED)); | |
163 html_data = jstemplate_builder::GetI18nTemplateHtml( | |
164 ResourceBundle::GetSharedInstance().GetRawDataResource( | |
165 IDR_DIR_HEADER_HTML), | |
166 &value); | |
167 } | |
168 | |
169 std::string html_data; | |
170 }; | |
171 | |
172 base::LazyInstance<LazyDirectoryListerCacher> lazy_dir_lister( | |
173 base::LINKER_INITIALIZED); | |
174 | |
175 // This is called indirectly by the network layer to access resources. | |
176 base::StringPiece NetResourceProvider(int key) { | |
177 if (IDR_DIR_HEADER_HTML == key) | |
178 return base::StringPiece(lazy_dir_lister.Pointer()->html_data); | |
179 | |
180 return ResourceBundle::GetSharedInstance().GetRawDataResource(key); | |
181 } | |
182 | |
183 void RunUIMessageLoop(BrowserProcess* browser_process) { | 145 void RunUIMessageLoop(BrowserProcess* browser_process) { |
184 #if defined(TOOLKIT_VIEWS) | 146 #if defined(TOOLKIT_VIEWS) |
185 views::AcceleratorHandler accelerator_handler; | 147 views::AcceleratorHandler accelerator_handler; |
186 MessageLoopForUI::current()->Run(&accelerator_handler); | 148 MessageLoopForUI::current()->Run(&accelerator_handler); |
187 #elif defined(OS_LINUX) | 149 #elif defined(OS_LINUX) |
188 MessageLoopForUI::current()->Run(NULL); | 150 MessageLoopForUI::current()->Run(NULL); |
189 #elif defined(OS_POSIX) | 151 #elif defined(OS_POSIX) |
190 MessageLoopForUI::current()->Run(); | 152 MessageLoopForUI::current()->Run(); |
191 #endif | 153 #endif |
192 } | 154 } |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 InitCommonControlsEx(&config); | 658 InitCommonControlsEx(&config); |
697 | 659 |
698 win_util::ScopedCOMInitializer com_initializer; | 660 win_util::ScopedCOMInitializer com_initializer; |
699 | 661 |
700 // Init the RLZ library. This just binds the dll and schedules a task on the | 662 // Init the RLZ library. This just binds the dll and schedules a task on the |
701 // file thread to be run sometime later. If this is the first run we record | 663 // file thread to be run sometime later. If this is the first run we record |
702 // the installation event. | 664 // the installation event. |
703 RLZTracker::InitRlzDelayed(base::DIR_MODULE, is_first_run, rlz_ping_delay); | 665 RLZTracker::InitRlzDelayed(base::DIR_MODULE, is_first_run, rlz_ping_delay); |
704 #endif | 666 #endif |
705 | 667 |
706 // Config the network module so it has access to resources. | 668 // Configure the network module so it has access to resources. |
707 net::NetModule::SetResourceProvider(NetResourceProvider); | 669 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); |
708 | 670 |
709 // Register our global network handler for chrome:// and | 671 // Register our global network handler for chrome:// and |
710 // chrome-extension:// URLs. | 672 // chrome-extension:// URLs. |
711 RegisterURLRequestChromeJob(); | 673 RegisterURLRequestChromeJob(); |
712 RegisterExtensionProtocols(); | 674 RegisterExtensionProtocols(); |
713 RegisterMetadataURLRequestHandler(); | 675 RegisterMetadataURLRequestHandler(); |
714 | 676 |
715 // In unittest mode, this will do nothing. In normal mode, this will create | 677 // In unittest mode, this will do nothing. In normal mode, this will create |
716 // the global GoogleURLTracker instance, which will promptly go to sleep for | 678 // the global GoogleURLTracker instance, which will promptly go to sleep for |
717 // five seconds (to avoid slowing startup), and wake up afterwards to see if | 679 // five seconds (to avoid slowing startup), and wake up afterwards to see if |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 if (metrics) | 802 if (metrics) |
841 metrics->Stop(); | 803 metrics->Stop(); |
842 | 804 |
843 // browser_shutdown takes care of deleting browser_process, so we need to | 805 // browser_shutdown takes care of deleting browser_process, so we need to |
844 // release it. | 806 // release it. |
845 browser_process.release(); | 807 browser_process.release(); |
846 browser_shutdown::Shutdown(); | 808 browser_shutdown::Shutdown(); |
847 | 809 |
848 return result_code; | 810 return result_code; |
849 } | 811 } |
OLD | NEW |