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 "content/shell/shell_content_browser_client.h" | 5 #include "content/shell/shell_content_browser_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "content/public/browser/notification_service.h" |
| 11 #include "content/public/browser/notification_types.h" |
10 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
11 #include "content/public/browser/resource_dispatcher_host.h" | 13 #include "content/public/browser/resource_dispatcher_host.h" |
12 #include "content/public/browser/storage_partition.h" | 14 #include "content/public/browser/storage_partition.h" |
13 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
14 #include "content/shell/geolocation/shell_access_token_store.h" | 16 #include "content/shell/geolocation/shell_access_token_store.h" |
15 #include "content/shell/shell.h" | 17 #include "content/shell/shell.h" |
16 #include "content/shell/shell_browser_context.h" | 18 #include "content/shell/shell_browser_context.h" |
17 #include "content/shell/shell_browser_main_parts.h" | 19 #include "content/shell/shell_browser_main_parts.h" |
18 #include "content/shell/shell_devtools_delegate.h" | 20 #include "content/shell/shell_devtools_delegate.h" |
19 #include "content/shell/shell_message_filter.h" | 21 #include "content/shell/shell_message_filter.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 RenderProcessHost* host) { | 112 RenderProcessHost* host) { |
111 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 113 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
112 return; | 114 return; |
113 host->GetChannel()->AddFilter(new ShellMessageFilter( | 115 host->GetChannel()->AddFilter(new ShellMessageFilter( |
114 host->GetID(), | 116 host->GetID(), |
115 BrowserContext::GetDefaultStoragePartition(browser_context()) | 117 BrowserContext::GetDefaultStoragePartition(browser_context()) |
116 ->GetDatabaseTracker(), | 118 ->GetDatabaseTracker(), |
117 BrowserContext::GetDefaultStoragePartition(browser_context()) | 119 BrowserContext::GetDefaultStoragePartition(browser_context()) |
118 ->GetQuotaManager())); | 120 ->GetQuotaManager())); |
119 host->Send(new ShellViewMsg_SetWebKitSourceDir(webkit_source_dir_)); | 121 host->Send(new ShellViewMsg_SetWebKitSourceDir(webkit_source_dir_)); |
120 | 122 registrar_.Add(this, |
121 if (hyphen_dictionary_file_ != base::kInvalidPlatformFileValue) { | 123 NOTIFICATION_RENDERER_PROCESS_CREATED, |
122 IPC::PlatformFileForTransit file = IPC::GetFileHandleForProcess( | 124 Source<RenderProcessHost>(host)); |
123 hyphen_dictionary_file_, host->GetHandle(), false); | |
124 host->Send(new ShellViewMsg_LoadHyphenDictionary(file)); | |
125 } | |
126 } | 125 } |
127 | 126 |
128 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( | 127 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( |
129 BrowserContext* content_browser_context, | 128 BrowserContext* content_browser_context, |
130 ProtocolHandlerMap* protocol_handlers) { | 129 ProtocolHandlerMap* protocol_handlers) { |
131 ShellBrowserContext* shell_browser_context = | 130 ShellBrowserContext* shell_browser_context = |
132 ShellBrowserContextForBrowserContext(content_browser_context); | 131 ShellBrowserContextForBrowserContext(content_browser_context); |
133 return shell_browser_context->CreateRequestContext(protocol_handlers); | 132 return shell_browser_context->CreateRequestContext(protocol_handlers); |
134 } | 133 } |
135 | 134 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 if (f == base::kInvalidPlatformFileValue) { | 207 if (f == base::kInvalidPlatformFileValue) { |
209 NOTREACHED() << "Failed to open file when creating renderer process: " | 208 NOTREACHED() << "Failed to open file when creating renderer process: " |
210 << "content_shell.pak"; | 209 << "content_shell.pak"; |
211 } | 210 } |
212 mappings->push_back( | 211 mappings->push_back( |
213 content::FileDescriptorInfo(kShellPakDescriptor, | 212 content::FileDescriptorInfo(kShellPakDescriptor, |
214 base::FileDescriptor(f, true))); | 213 base::FileDescriptor(f, true))); |
215 } | 214 } |
216 #endif | 215 #endif |
217 | 216 |
| 217 void ShellContentBrowserClient::Observe(int type, |
| 218 const NotificationSource& source, |
| 219 const NotificationDetails& details) { |
| 220 switch (type) { |
| 221 case NOTIFICATION_RENDERER_PROCESS_CREATED: { |
| 222 registrar_.Remove(this, |
| 223 NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 224 source); |
| 225 if (hyphen_dictionary_file_ != base::kInvalidPlatformFileValue) { |
| 226 RenderProcessHost* host = Source<RenderProcessHost>(source).ptr(); |
| 227 IPC::PlatformFileForTransit file = IPC::GetFileHandleForProcess( |
| 228 hyphen_dictionary_file_, host->GetHandle(), false); |
| 229 host->Send(new ShellViewMsg_LoadHyphenDictionary(file)); |
| 230 } |
| 231 break; |
| 232 } |
| 233 |
| 234 default: |
| 235 NOTREACHED(); |
| 236 } |
| 237 } |
| 238 |
218 ShellBrowserContext* ShellContentBrowserClient::browser_context() { | 239 ShellBrowserContext* ShellContentBrowserClient::browser_context() { |
219 return shell_browser_main_parts_->browser_context(); | 240 return shell_browser_main_parts_->browser_context(); |
220 } | 241 } |
221 | 242 |
222 ShellBrowserContext* | 243 ShellBrowserContext* |
223 ShellContentBrowserClient::off_the_record_browser_context() { | 244 ShellContentBrowserClient::off_the_record_browser_context() { |
224 return shell_browser_main_parts_->off_the_record_browser_context(); | 245 return shell_browser_main_parts_->off_the_record_browser_context(); |
225 } | 246 } |
226 | 247 |
227 AccessTokenStore* ShellContentBrowserClient::CreateAccessTokenStore() { | 248 AccessTokenStore* ShellContentBrowserClient::CreateAccessTokenStore() { |
228 return new ShellAccessTokenStore(browser_context()->GetRequestContext()); | 249 return new ShellAccessTokenStore(browser_context()->GetRequestContext()); |
229 } | 250 } |
230 | 251 |
231 ShellBrowserContext* | 252 ShellBrowserContext* |
232 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 253 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
233 BrowserContext* content_browser_context) { | 254 BrowserContext* content_browser_context) { |
234 if (content_browser_context == browser_context()) | 255 if (content_browser_context == browser_context()) |
235 return browser_context(); | 256 return browser_context(); |
236 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 257 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
237 return off_the_record_browser_context(); | 258 return off_the_record_browser_context(); |
238 } | 259 } |
239 | 260 |
240 } // namespace content | 261 } // namespace content |
OLD | NEW |