| OLD | NEW |
| 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/profile.h" | 5 #include "chrome/browser/profile.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 424 |
| 425 void ProfileImpl::InitExtensions() { | 425 void ProfileImpl::InitExtensions() { |
| 426 if (user_script_master_ || extensions_service_) | 426 if (user_script_master_ || extensions_service_) |
| 427 return; // Already initialized. | 427 return; // Already initialized. |
| 428 | 428 |
| 429 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 429 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 430 PrefService* prefs = GetPrefs(); | 430 PrefService* prefs = GetPrefs(); |
| 431 bool user_scripts_enabled = | 431 bool user_scripts_enabled = |
| 432 command_line->HasSwitch(switches::kEnableUserScripts) || | 432 command_line->HasSwitch(switches::kEnableUserScripts) || |
| 433 prefs->GetBoolean(prefs::kEnableUserScripts); | 433 prefs->GetBoolean(prefs::kEnableUserScripts); |
| 434 bool extensions_enabled = | |
| 435 command_line->HasSwitch(switches::kEnableExtensions) || | |
| 436 prefs->GetBoolean(prefs::kEnableExtensions); | |
| 437 | 434 |
| 438 FilePath script_dir; | 435 FilePath script_dir; |
| 439 if (user_scripts_enabled) { | 436 if (user_scripts_enabled) { |
| 440 if (command_line->HasSwitch(switches::kUserScriptsDir)) { | 437 if (command_line->HasSwitch(switches::kUserScriptsDir)) { |
| 441 std::wstring path_string = | 438 std::wstring path_string = |
| 442 command_line->GetSwitchValue(switches::kUserScriptsDir); | 439 command_line->GetSwitchValue(switches::kUserScriptsDir); |
| 443 script_dir = FilePath::FromWStringHack(path_string); | 440 script_dir = FilePath::FromWStringHack(path_string); |
| 444 } else { | 441 } else { |
| 445 script_dir = GetPath(); | 442 script_dir = GetPath(); |
| 446 script_dir = script_dir.Append(chrome::kUserScriptsDirname); | 443 script_dir = script_dir.Append(chrome::kUserScriptsDirname); |
| 447 } | 444 } |
| 448 } | 445 } |
| 449 | 446 |
| 450 ExtensionErrorReporter::Init(true); // allow noisy errors. | 447 ExtensionErrorReporter::Init(true); // allow noisy errors. |
| 451 user_script_master_ = new UserScriptMaster( | 448 user_script_master_ = new UserScriptMaster( |
| 452 g_browser_process->file_thread()->message_loop(), script_dir); | 449 g_browser_process->file_thread()->message_loop(), |
| 450 script_dir); |
| 453 extensions_service_ = new ExtensionsService( | 451 extensions_service_ = new ExtensionsService( |
| 454 this, MessageLoop::current(), | 452 this, MessageLoop::current(), |
| 455 g_browser_process->file_thread()->message_loop(), | 453 g_browser_process->file_thread()->message_loop(), |
| 456 std::string()); // Use default registry path | 454 std::string()); // Use default registry path |
| 457 | 455 |
| 458 // If we have extensions, the extension service will kick off the first scan | 456 extensions_service_->Init(); |
| 459 // after extensions are loaded. Otherwise, we need to do that now. | |
| 460 if (extensions_enabled) | |
| 461 extensions_service_->Init(); | |
| 462 else if (user_scripts_enabled) | |
| 463 user_script_master_->StartScan(); | |
| 464 } | 457 } |
| 465 | 458 |
| 466 ProfileImpl::~ProfileImpl() { | 459 ProfileImpl::~ProfileImpl() { |
| 467 tab_restore_service_ = NULL; | 460 tab_restore_service_ = NULL; |
| 468 | 461 |
| 469 StopCreateSessionServiceTimer(); | 462 StopCreateSessionServiceTimer(); |
| 470 // TemplateURLModel schedules a task on the WebDataService from its | 463 // TemplateURLModel schedules a task on the WebDataService from its |
| 471 // destructor. Delete it first to ensure the task gets scheduled before we | 464 // destructor. Delete it first to ensure the task gets scheduled before we |
| 472 // shut down the database. | 465 // shut down the database. |
| 473 template_url_model_.reset(); | 466 template_url_model_.reset(); |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 | 981 |
| 989 void ProfileImpl::StopCreateSessionServiceTimer() { | 982 void ProfileImpl::StopCreateSessionServiceTimer() { |
| 990 create_session_service_timer_.Stop(); | 983 create_session_service_timer_.Stop(); |
| 991 } | 984 } |
| 992 | 985 |
| 993 #ifdef CHROME_PERSONALIZATION | 986 #ifdef CHROME_PERSONALIZATION |
| 994 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { | 987 ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { |
| 995 return personalization_.get(); | 988 return personalization_.get(); |
| 996 } | 989 } |
| 997 #endif | 990 #endif |
| OLD | NEW |