diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-25 05:08:54 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-25 05:08:54 +0000 |
commit | bdbc87ca87fda52c3262240705d974030e9ed4b4 (patch) | |
tree | 6ca34f4c2ba9fe4b340075206846c115a5400d27 /chrome/browser/profile.cc | |
parent | 1692ea885338dd799ae9f47151d2a7fd4d1b10c4 (diff) | |
download | chromium_src-bdbc87ca87fda52c3262240705d974030e9ed4b4.zip chromium_src-bdbc87ca87fda52c3262240705d974030e9ed4b4.tar.gz chromium_src-bdbc87ca87fda52c3262240705d974030e9ed4b4.tar.bz2 |
Add user script support to extensions.
This is implemented mostly by relying on the existing
user script code. But since extension user scripts are
declared, not discovered in a directory, I had to add
support for adding 'lone' user scripts to
UserScriptMaster. This led to a bit of refactoring.
Note that this CL relies on:
http://codereview.chromium.org/18352
Review URL: http://codereview.chromium.org/18198
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8614 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profile.cc')
-rw-r--r-- | chrome/browser/profile.cc | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index 089dd9c..5af89c9 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -257,6 +257,10 @@ class OffTheRecordProfileImpl : public Profile, virtual void MarkAsCleanShutdown() { } + virtual void InitExtensions() { + NOTREACHED(); + } + virtual void ExitedOffTheRecordMode() { // Drop our download manager so we forget about all the downloads made // in off-the-record mode. @@ -297,7 +301,6 @@ class OffTheRecordProfileImpl : public Profile, ProfileImpl::ProfileImpl(const std::wstring& path) : path_(path), off_the_record_(false), - extensions_service_(new ExtensionsService(FilePath(path))), history_service_created_(false), created_web_data_service_(false), created_download_manager_(false), @@ -313,11 +316,38 @@ ProfileImpl::ProfileImpl(const std::wstring& path) create_session_service_timer_.Start( TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, &ProfileImpl::EnsureSessionServiceCreated); + PrefService* prefs = GetPrefs(); prefs->AddPrefObserver(prefs::kSpellCheckDictionary, this); prefs->AddPrefObserver(prefs::kEnableSpellCheck, this); } +void ProfileImpl::InitExtensions() { + const CommandLine* command_line = CommandLine::ForCurrentProcess(); + bool user_scripts_enabled = + command_line->HasSwitch(switches::kEnableUserScripts); + bool extensions_enabled = + command_line->HasSwitch(switches::kEnableExtensions); + + std::wstring script_dir; + if (user_scripts_enabled) { + script_dir = GetPath(); + file_util::AppendToPath(&script_dir, chrome::kUserScriptsDirname); + } + + user_script_master_ = new UserScriptMaster( + g_browser_process->file_thread()->message_loop(), FilePath(script_dir)); + extensions_service_ = new ExtensionsService( + FilePath(GetPath()), user_script_master_.get()); + + // If we have extensions, the extension service will kick off the first scan + // after extensions are loaded. Otherwise, we need to do that now. + if (extensions_enabled) + extensions_service_->Init(); + else if (user_scripts_enabled) + user_script_master_->StartScan(); +} + ProfileImpl::~ProfileImpl() { tab_restore_service_ = NULL; @@ -449,14 +479,6 @@ ExtensionsService* ProfileImpl::GetExtensionsService() { } UserScriptMaster* ProfileImpl::GetUserScriptMaster() { - if (!user_script_master_.get()) { - std::wstring script_dir = GetPath(); - file_util::AppendToPath(&script_dir, chrome::kUserScriptsDirname); - user_script_master_ = - new UserScriptMaster(g_browser_process->file_thread()->message_loop(), - FilePath(script_dir)); - } - return user_script_master_.get(); } |