Changeset 169422 in webkit
- Timestamp:
- May 28, 2014 7:28:56 AM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r169421 r169422 1 2014-05-28 Dan Bernstein <mitz@apple.com> 2 3 [Cocoa] Can't use bundle-defined classes for bundle parameters 4 https://bugs.webkit.org/show_bug.cgi?id=133339 5 6 Reviewed by Anders Carlsson. 7 8 Ensure that bundle parameters are decoded only after the injected bundle is loaded. 9 10 * WebProcess/InjectedBundle/InjectedBundle.cpp: 11 (WebKit::InjectedBundle::create): Moved the definition from the header to here, added the 12 lagacy initializationUserData as a parameter, and made this function set the sandbox 13 extension and load the bundle. 14 (WebKit::InjectedBundle::InjectedBundle): Removed call to platformInitialize. 15 * WebProcess/InjectedBundle/InjectedBundle.h: 16 (WebKit::InjectedBundle::setSandboxExtension): Deleted. 17 * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm: 18 (WebKit::InjectedBundle::initialize): Renamed the load function to this, and added the 19 creation parameters as a parameter. Moved code to initialize the bundle paramters from 20 platformInitialize to here. Changed the class passed to -decodeObjectOfClass:forKey: to 21 NSObject, to allow arbitrary types in the values, and added an assertion that the 22 top-level object is a dictionary. 23 (WebKit::InjectedBundle::platformInitialize): Deleted. 24 * WebProcess/WebProcess.cpp: 25 (WebKit::WebProcess::initializeWebProcess): Changed to pass the legacy initialization user 26 data to InjectedBundle::create() and removed code to separately set the sandbox extension 27 and load the bundle, which is now done by create(). 28 1 29 2014-05-28 Alberto Garcia <berto@igalia.com> 2 30 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
r169394 r169422 86 86 namespace WebKit { 87 87 88 PassRefPtr<InjectedBundle> InjectedBundle::create(const WebProcessCreationParameters& parameters, API::Object* initializationUserData) 89 { 90 RefPtr<InjectedBundle> bundle = adoptRef(new InjectedBundle(parameters)); 91 92 bundle->m_sandboxExtension = SandboxExtension::create(parameters.injectedBundlePathExtensionHandle); 93 if (!bundle->initialize(parameters, initializationUserData)) 94 return nullptr; 95 96 return bundle.release(); 97 } 98 88 99 InjectedBundle::InjectedBundle(const WebProcessCreationParameters& parameters) 89 100 : m_path(parameters.injectedBundlePath) 90 101 , m_platformBundle(0) 91 102 { 92 platformInitialize(parameters);93 103 } 94 104 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
r168123 r169422 82 82 class InjectedBundle : public API::ObjectImpl<API::Object::Type::Bundle> { 83 83 public: 84 static PassRefPtr<InjectedBundle> create(const WebProcessCreationParameters& parameters) 85 { 86 return adoptRef(new InjectedBundle(parameters)); 87 } 84 static PassRefPtr<InjectedBundle> create(const WebProcessCreationParameters&, API::Object* initializationUserData); 85 88 86 ~InjectedBundle(); 89 87 90 bool load(API::Object* initializationUserData); 91 void setSandboxExtension(PassRefPtr<SandboxExtension> sandboxExtension) { m_sandboxExtension = sandboxExtension; } 88 bool initialize(const WebProcessCreationParameters&, API::Object* initializationUserData); 92 89 93 90 void setBundleParameter(const String& key, const IPC::DataReference&); … … 182 179 explicit InjectedBundle(const WebProcessCreationParameters&); 183 180 184 void platformInitialize(const WebProcessCreationParameters&);185 186 181 String m_path; 187 182 PlatformBundle m_platformBundle; // This is leaked right now, since we never unload the bundle/module. -
trunk/Source/WebKit2/WebProcess/InjectedBundle/efl/InjectedBundleEfl.cpp
r165801 r169422 35 35 namespace WebKit { 36 36 37 bool InjectedBundle:: load(API::Object* initializationUserData)37 bool InjectedBundle::initialize(const WebProcessCreationParameters&, API::Object* initializationUserData) 38 38 { 39 39 m_platformBundle = eina_module_new(m_path.utf8().data()); … … 67 67 } 68 68 69 void InjectedBundle::platformInitialize(const WebProcessCreationParameters&)70 {71 }72 73 69 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/InjectedBundle/gtk/InjectedBundleGtk.cpp
r165802 r169422 37 37 namespace WebKit { 38 38 39 bool InjectedBundle:: load(API::Object* initializationUserData)39 bool InjectedBundle::initialize(const WebProcessCreationParameters&, API::Object* initializationUserData) 40 40 { 41 41 m_platformBundle = g_module_open(fileSystemRepresentation(m_path).data(), G_MODULE_BIND_LOCAL); … … 59 59 } 60 60 61 void InjectedBundle::platformInitialize(const WebProcessCreationParameters&)62 {63 }64 65 61 void InjectedBundle::setBundleParameter(WTF::String const&, IPC::DataReference const&) 66 62 { -
trunk/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm
r167865 r169422 48 48 namespace WebKit { 49 49 50 bool InjectedBundle:: load(API::Object* initializationUserData)50 bool InjectedBundle::initialize(const WebProcessCreationParameters& parameters, API::Object* initializationUserData) 51 51 { 52 52 if (m_sandboxExtension) { … … 90 90 91 91 #if WK_API_ENABLED 92 if (parameters.bundleParameterData) { 93 auto bundleParameterData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(parameters.bundleParameterData->bytes())) length:parameters.bundleParameterData->size() freeWhenDone:NO]); 94 95 auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:bundleParameterData.get()]); 96 [unarchiver setRequiresSecureCoding:YES]; 97 98 NSDictionary *dictionary = nil; 99 @try { 100 dictionary = [unarchiver.get() decodeObjectOfClass:[NSObject class] forKey:@"parameters"]; 101 ASSERT([dictionary isKindOfClass:[NSDictionary class]]); 102 } @catch (NSException *exception) { 103 LOG_ERROR("Failed to decode bundle parameters: %@", exception); 104 } 105 106 m_bundleParameters = adoptNS([[WKWebProcessBundleParameters alloc] initWithDictionary:dictionary]); 107 } 108 92 109 // Otherwise, look to see if the bundle has a principal class 93 110 Class principalClass = [m_platformBundle principalClass]; … … 163 180 } 164 181 165 166 void InjectedBundle::platformInitialize(const WebProcessCreationParameters& parameters)167 {168 #if WK_API_ENABLED169 if (!parameters.bundleParameterData)170 return;171 172 auto bundleParameterData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(parameters.bundleParameterData->bytes())) length:parameters.bundleParameterData->size() freeWhenDone:NO]);173 174 auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:bundleParameterData.get()]);175 [unarchiver setRequiresSecureCoding:YES];176 177 NSDictionary *dictionary = nil;178 @try {179 dictionary = [unarchiver.get() decodeObjectOfClass:[NSDictionary class] forKey:@"parameters"];180 } @catch (NSException *exception) {181 LOG_ERROR("Failed to decode bundle parameters: %@", exception);182 }183 184 m_bundleParameters = adoptNS([[WKWebProcessBundleParameters alloc] initWithDictionary:dictionary]);185 #endif186 }187 188 182 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/WebProcess.cpp
r169394 r169422 278 278 return; 279 279 280 if (!parameters.injectedBundlePath.isEmpty()) { 281 m_injectedBundle = InjectedBundle::create(parameters); 282 m_injectedBundle->setSandboxExtension(SandboxExtension::create(parameters.injectedBundlePathExtensionHandle)); 283 284 if (!m_injectedBundle->load(injectedBundleInitializationUserData.get())) { 285 // Don't keep around the InjectedBundle reference if the load fails. 286 m_injectedBundle.clear(); 287 } 288 } 280 if (!parameters.injectedBundlePath.isEmpty()) 281 m_injectedBundle = InjectedBundle::create(parameters, injectedBundleInitializationUserData.get()); 289 282 290 283 WebProcessSupplementMap::const_iterator it = m_supplements.begin();
Note: See TracChangeset
for help on using the changeset viewer.