| 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/extensions/extensions_service.h" | 5 #include "chrome/browser/extensions/extensions_service.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/scoped_handle.h" | 8 #include "base/scoped_handle.h" |
| 9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // interface, similar to how the message loop for the frontend comes | 96 // interface, similar to how the message loop for the frontend comes |
| 97 // from the frontend interface. | 97 // from the frontend interface. |
| 98 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, | 98 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, |
| 99 NewRunnableMethod(backend_.get(), | 99 NewRunnableMethod(backend_.get(), |
| 100 &ExtensionsServiceBackend::LoadExtensionsFromInstallDirectory, | 100 &ExtensionsServiceBackend::LoadExtensionsFromInstallDirectory, |
| 101 scoped_refptr<ExtensionsServiceFrontendInterface>(this))); | 101 scoped_refptr<ExtensionsServiceFrontendInterface>(this))); |
| 102 | 102 |
| 103 return true; | 103 return true; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void ExtensionsService::LaunchExtensionProcess(Extension* extension) { | |
| 107 // TODO(mpcomplete): Do something useful here. | |
| 108 GURL url = Extension::GetResourceURL(extension->url(), "index.html"); | |
| 109 ExtensionView* view = new ExtensionView(url, profile_); | |
| 110 view->InitHidden(); | |
| 111 } | |
| 112 | |
| 113 MessageLoop* ExtensionsService::GetMessageLoop() { | 106 MessageLoop* ExtensionsService::GetMessageLoop() { |
| 114 return message_loop_; | 107 return message_loop_; |
| 115 } | 108 } |
| 116 | 109 |
| 117 void ExtensionsService::InstallExtension(const FilePath& extension_path) { | 110 void ExtensionsService::InstallExtension(const FilePath& extension_path) { |
| 118 // TODO(aa): This message loop should probably come from a backend | 111 // TODO(aa): This message loop should probably come from a backend |
| 119 // interface, similar to how the message loop for the frontend comes | 112 // interface, similar to how the message loop for the frontend comes |
| 120 // from the frontend interface. | 113 // from the frontend interface. |
| 121 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, | 114 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, |
| 122 NewRunnableMethod(backend_.get(), | 115 NewRunnableMethod(backend_.get(), |
| 123 &ExtensionsServiceBackend::InstallExtension, | 116 &ExtensionsServiceBackend::InstallExtension, |
| 124 extension_path, | 117 extension_path, |
| 125 scoped_refptr<ExtensionsServiceFrontendInterface>(this))); | 118 scoped_refptr<ExtensionsServiceFrontendInterface>(this))); |
| 126 } | 119 } |
| 127 | 120 |
| 128 void ExtensionsService::LoadExtension(const FilePath& extension_path) { | 121 void ExtensionsService::LoadExtension(const FilePath& extension_path) { |
| 129 // TODO(aa): This message loop should probably come from a backend | 122 // TODO(aa): This message loop should probably come from a backend |
| 130 // interface, similar to how the message loop for the frontend comes | 123 // interface, similar to how the message loop for the frontend comes |
| 131 // from the frontend interface. | 124 // from the frontend interface. |
| 132 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, | 125 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, |
| 133 NewRunnableMethod(backend_.get(), | 126 NewRunnableMethod(backend_.get(), |
| 134 &ExtensionsServiceBackend::LoadSingleExtension, | 127 &ExtensionsServiceBackend::LoadSingleExtension, |
| 135 extension_path, | 128 extension_path, |
| 136 scoped_refptr<ExtensionsServiceFrontendInterface>(this))); | 129 scoped_refptr<ExtensionsServiceFrontendInterface>(this))); |
| 137 } | 130 } |
| 138 | 131 |
| 139 void ExtensionsService::OnExtensionsLoaded( | 132 void ExtensionsService::OnExtensionsLoaded(ExtensionList* new_extensions) { |
| 140 ExtensionList* new_extensions) { | |
| 141 extensions_.insert(extensions_.end(), new_extensions->begin(), | 133 extensions_.insert(extensions_.end(), new_extensions->begin(), |
| 142 new_extensions->end()); | 134 new_extensions->end()); |
| 143 | 135 |
| 144 // TODO: Fix race here. A page could need a user script on startup, before | 136 // TODO: Fix race here. A page could need a user script on startup, before |
| 145 // the user script is loaded. We need to freeze the renderer in that case. | 137 // the user script is loaded. We need to freeze the renderer in that case. |
| 146 // TODO(mpcomplete): We also need to force a renderer to refresh its cache of | 138 // TODO(mpcomplete): We also need to force a renderer to refresh its cache of |
| 147 // the plugin list when we inject user scripts, since it could have a stale | 139 // the plugin list when we inject user scripts, since it could have a stale |
| 148 // version by the time extensions are loaded. | 140 // version by the time extensions are loaded. |
| 149 | 141 |
| 150 for (ExtensionList::iterator extension = extensions_.begin(); | 142 for (ExtensionList::iterator extension = extensions_.begin(); |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 | 799 |
| 808 bool ExtensionsServiceBackend::ShouldInstall(const std::string& id, | 800 bool ExtensionsServiceBackend::ShouldInstall(const std::string& id, |
| 809 const std::string& version) { | 801 const std::string& version) { |
| 810 FilePath dir(install_directory_.AppendASCII(id.c_str())); | 802 FilePath dir(install_directory_.AppendASCII(id.c_str())); |
| 811 std::string current_version; | 803 std::string current_version; |
| 812 if (ReadCurrentVersion(dir, ¤t_version)) { | 804 if (ReadCurrentVersion(dir, ¤t_version)) { |
| 813 return !CheckCurrentVersion(version, current_version, dir); | 805 return !CheckCurrentVersion(version, current_version, dir); |
| 814 } | 806 } |
| 815 return true; | 807 return true; |
| 816 } | 808 } |
| OLD | NEW |