| 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" | 10 #include "content/public/browser/notification_service.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 ShellContentBrowserClient* g_browser_client; | 46 ShellContentBrowserClient* g_browser_client; |
| 47 | 47 |
| 48 } // namespace | 48 } // namespace |
| 49 | 49 |
| 50 ShellContentBrowserClient* ShellContentBrowserClient::Get() { | 50 ShellContentBrowserClient* ShellContentBrowserClient::Get() { |
| 51 return g_browser_client; | 51 return g_browser_client; |
| 52 } | 52 } |
| 53 | 53 |
| 54 ShellContentBrowserClient::ShellContentBrowserClient() | 54 ShellContentBrowserClient::ShellContentBrowserClient() |
| 55 : hyphen_dictionary_file_(base::kInvalidPlatformFileValue), | 55 : shell_browser_main_parts_(NULL) { |
| 56 shell_browser_main_parts_(NULL) { | |
| 57 DCHECK(!g_browser_client); | 56 DCHECK(!g_browser_client); |
| 58 g_browser_client = this; | 57 g_browser_client = this; |
| 59 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 58 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
| 60 return; | 59 return; |
| 61 webkit_source_dir_ = GetWebKitRootDirFilePath(); | 60 webkit_source_dir_ = GetWebKitRootDirFilePath(); |
| 62 base::FilePath source_root_path; | |
| 63 PathService::Get(base::DIR_SOURCE_ROOT, &source_root_path); | |
| 64 base::FilePath dictionary_file_path = | |
| 65 base::MakeAbsoluteFilePath(source_root_path.Append( | |
| 66 FILE_PATH_LITERAL("third_party/hyphen/hyph_en_US.dic"))); | |
| 67 hyphen_dictionary_file_ = base::CreatePlatformFile(dictionary_file_path, | |
| 68 base::PLATFORM_FILE_READ | | |
| 69 base::PLATFORM_FILE_OPEN, | |
| 70 NULL, | |
| 71 NULL); | |
| 72 } | 61 } |
| 73 | 62 |
| 74 ShellContentBrowserClient::~ShellContentBrowserClient() { | 63 ShellContentBrowserClient::~ShellContentBrowserClient() { |
| 75 g_browser_client = NULL; | 64 g_browser_client = NULL; |
| 76 } | 65 } |
| 77 | 66 |
| 78 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( | 67 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( |
| 79 const MainFunctionParams& parameters) { | 68 const MainFunctionParams& parameters) { |
| 80 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters); | 69 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters); |
| 81 return shell_browser_main_parts_; | 70 return shell_browser_main_parts_; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 const NotificationSource& source, | 213 const NotificationSource& source, |
| 225 const NotificationDetails& details) { | 214 const NotificationDetails& details) { |
| 226 switch (type) { | 215 switch (type) { |
| 227 case NOTIFICATION_RENDERER_PROCESS_CREATED: { | 216 case NOTIFICATION_RENDERER_PROCESS_CREATED: { |
| 228 registrar_.Remove(this, | 217 registrar_.Remove(this, |
| 229 NOTIFICATION_RENDERER_PROCESS_CREATED, | 218 NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 230 source); | 219 source); |
| 231 registrar_.Remove(this, | 220 registrar_.Remove(this, |
| 232 NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 221 NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 233 source); | 222 source); |
| 234 if (hyphen_dictionary_file_ != base::kInvalidPlatformFileValue) { | |
| 235 RenderProcessHost* host = Source<RenderProcessHost>(source).ptr(); | |
| 236 IPC::PlatformFileForTransit file = IPC::GetFileHandleForProcess( | |
| 237 hyphen_dictionary_file_, host->GetHandle(), false); | |
| 238 host->Send(new ShellViewMsg_LoadHyphenDictionary(file)); | |
| 239 } | |
| 240 break; | 223 break; |
| 241 } | 224 } |
| 242 | 225 |
| 243 case NOTIFICATION_RENDERER_PROCESS_TERMINATED: { | 226 case NOTIFICATION_RENDERER_PROCESS_TERMINATED: { |
| 244 registrar_.Remove(this, | 227 registrar_.Remove(this, |
| 245 NOTIFICATION_RENDERER_PROCESS_CREATED, | 228 NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 246 source); | 229 source); |
| 247 registrar_.Remove(this, | 230 registrar_.Remove(this, |
| 248 NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 231 NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 249 source); | 232 source); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 271 ShellBrowserContext* | 254 ShellBrowserContext* |
| 272 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 255 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
| 273 BrowserContext* content_browser_context) { | 256 BrowserContext* content_browser_context) { |
| 274 if (content_browser_context == browser_context()) | 257 if (content_browser_context == browser_context()) |
| 275 return browser_context(); | 258 return browser_context(); |
| 276 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 259 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
| 277 return off_the_record_browser_context(); | 260 return off_the_record_browser_context(); |
| 278 } | 261 } |
| 279 | 262 |
| 280 } // namespace content | 263 } // namespace content |
| OLD | NEW |