| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 StorageNamespace* PageGroup::localStorage() | 249 StorageNamespace* PageGroup::localStorage() |
| 250 { | 250 { |
| 251 if (!m_localStorage) { | 251 if (!m_localStorage) { |
| 252 unsigned quota = m_groupSettings->localStorageQuotaBytes(); | 252 unsigned quota = m_groupSettings->localStorageQuotaBytes(); |
| 253 m_localStorage = StorageNamespace::localStorageNamespace(quota); | 253 m_localStorage = StorageNamespace::localStorageNamespace(quota); |
| 254 } | 254 } |
| 255 | 255 |
| 256 return m_localStorage.get(); | 256 return m_localStorage.get(); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void PageGroup::addUserScriptToWorld(DOMWrapperWorld* world, const String& sourc
e, const KURL& url, | |
| 260 const Vector<String>& whitelist, const Vect
or<String>& blacklist, | |
| 261 UserScriptInjectionTime injectionTime, User
ContentInjectedFrames injectedFrames) | |
| 262 { | |
| 263 ASSERT_ARG(world, world); | |
| 264 | |
| 265 OwnPtr<UserScript> userScript = adoptPtr(new UserScript(source, url, whiteli
st, blacklist, injectionTime, injectedFrames)); | |
| 266 if (!m_userScripts) | |
| 267 m_userScripts = adoptPtr(new UserScriptMap); | |
| 268 OwnPtr<UserScriptVector>& scriptsInWorld = m_userScripts->add(world, nullptr
).iterator->value; | |
| 269 if (!scriptsInWorld) | |
| 270 scriptsInWorld = adoptPtr(new UserScriptVector); | |
| 271 scriptsInWorld->append(userScript.release()); | |
| 272 } | |
| 273 | |
| 274 void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& s
ource, const KURL& url, | 259 void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& s
ource, const KURL& url, |
| 275 const Vector<String>& whitelist, const
Vector<String>& blacklist, | 260 const Vector<String>& whitelist, const
Vector<String>& blacklist, |
| 276 UserContentInjectedFrames injectedFrame
s, | 261 UserContentInjectedFrames injectedFrame
s, |
| 277 UserStyleLevel level, | 262 UserStyleLevel level, |
| 278 UserStyleInjectionTime injectionTime) | 263 UserStyleInjectionTime injectionTime) |
| 279 { | 264 { |
| 280 ASSERT_ARG(world, world); | 265 ASSERT_ARG(world, world); |
| 281 | 266 |
| 282 OwnPtr<UserStyleSheet> userStyleSheet = adoptPtr(new UserStyleSheet(source,
url, whitelist, blacklist, injectedFrames, level)); | 267 OwnPtr<UserStyleSheet> userStyleSheet = adoptPtr(new UserStyleSheet(source,
url, whitelist, blacklist, injectedFrames, level)); |
| 283 if (!m_userStyleSheets) | 268 if (!m_userStyleSheets) |
| 284 m_userStyleSheets = adoptPtr(new UserStyleSheetMap); | 269 m_userStyleSheets = adoptPtr(new UserStyleSheetMap); |
| 285 OwnPtr<UserStyleSheetVector>& styleSheetsInWorld = m_userStyleSheets->add(wo
rld, nullptr).iterator->value; | 270 OwnPtr<UserStyleSheetVector>& styleSheetsInWorld = m_userStyleSheets->add(wo
rld, nullptr).iterator->value; |
| 286 if (!styleSheetsInWorld) | 271 if (!styleSheetsInWorld) |
| 287 styleSheetsInWorld = adoptPtr(new UserStyleSheetVector); | 272 styleSheetsInWorld = adoptPtr(new UserStyleSheetVector); |
| 288 styleSheetsInWorld->append(userStyleSheet.release()); | 273 styleSheetsInWorld->append(userStyleSheet.release()); |
| 289 | 274 |
| 290 if (injectionTime == InjectInExistingDocuments) | 275 if (injectionTime == InjectInExistingDocuments) |
| 291 invalidatedInjectedStyleSheetCacheInAllFrames(); | 276 invalidatedInjectedStyleSheetCacheInAllFrames(); |
| 292 } | 277 } |
| 293 | 278 |
| 294 void PageGroup::removeUserScriptFromWorld(DOMWrapperWorld* world, const KURL& ur
l) | |
| 295 { | |
| 296 ASSERT_ARG(world, world); | |
| 297 | |
| 298 if (!m_userScripts) | |
| 299 return; | |
| 300 | |
| 301 UserScriptMap::iterator it = m_userScripts->find(world); | |
| 302 if (it == m_userScripts->end()) | |
| 303 return; | |
| 304 | |
| 305 UserScriptVector* scripts = it->value.get(); | |
| 306 for (int i = scripts->size() - 1; i >= 0; --i) { | |
| 307 if (scripts->at(i)->url() == url) | |
| 308 scripts->remove(i); | |
| 309 } | |
| 310 | |
| 311 if (scripts->isEmpty()) | |
| 312 m_userScripts->remove(it); | |
| 313 } | |
| 314 | |
| 315 void PageGroup::removeUserStyleSheetFromWorld(DOMWrapperWorld* world, const KURL
& url) | |
| 316 { | |
| 317 ASSERT_ARG(world, world); | |
| 318 | |
| 319 if (!m_userStyleSheets) | |
| 320 return; | |
| 321 | |
| 322 UserStyleSheetMap::iterator it = m_userStyleSheets->find(world); | |
| 323 bool sheetsChanged = false; | |
| 324 if (it == m_userStyleSheets->end()) | |
| 325 return; | |
| 326 | |
| 327 UserStyleSheetVector* stylesheets = it->value.get(); | |
| 328 for (int i = stylesheets->size() - 1; i >= 0; --i) { | |
| 329 if (stylesheets->at(i)->url() == url) { | |
| 330 stylesheets->remove(i); | |
| 331 sheetsChanged = true; | |
| 332 } | |
| 333 } | |
| 334 | |
| 335 if (!sheetsChanged) | |
| 336 return; | |
| 337 | |
| 338 if (stylesheets->isEmpty()) | |
| 339 m_userStyleSheets->remove(it); | |
| 340 | |
| 341 invalidatedInjectedStyleSheetCacheInAllFrames(); | |
| 342 } | |
| 343 | |
| 344 void PageGroup::removeUserScriptsFromWorld(DOMWrapperWorld* world) | |
| 345 { | |
| 346 ASSERT_ARG(world, world); | |
| 347 | |
| 348 if (!m_userScripts) | |
| 349 return; | |
| 350 | |
| 351 UserScriptMap::iterator it = m_userScripts->find(world); | |
| 352 if (it == m_userScripts->end()) | |
| 353 return; | |
| 354 | |
| 355 m_userScripts->remove(it); | |
| 356 } | |
| 357 | |
| 358 void PageGroup::removeUserStyleSheetsFromWorld(DOMWrapperWorld* world) | |
| 359 { | |
| 360 ASSERT_ARG(world, world); | |
| 361 | |
| 362 if (!m_userStyleSheets) | |
| 363 return; | |
| 364 | |
| 365 UserStyleSheetMap::iterator it = m_userStyleSheets->find(world); | |
| 366 if (it == m_userStyleSheets->end()) | |
| 367 return; | |
| 368 | |
| 369 m_userStyleSheets->remove(it); | |
| 370 | |
| 371 invalidatedInjectedStyleSheetCacheInAllFrames(); | |
| 372 } | |
| 373 | |
| 374 void PageGroup::removeAllUserContent() | 279 void PageGroup::removeAllUserContent() |
| 375 { | 280 { |
| 376 m_userScripts.clear(); | |
| 377 | |
| 378 if (m_userStyleSheets) { | 281 if (m_userStyleSheets) { |
| 379 m_userStyleSheets.clear(); | 282 m_userStyleSheets.clear(); |
| 380 invalidatedInjectedStyleSheetCacheInAllFrames(); | 283 invalidatedInjectedStyleSheetCacheInAllFrames(); |
| 381 } | 284 } |
| 382 } | 285 } |
| 383 | 286 |
| 384 void PageGroup::invalidatedInjectedStyleSheetCacheInAllFrames() | 287 void PageGroup::invalidatedInjectedStyleSheetCacheInAllFrames() |
| 385 { | 288 { |
| 386 // Clear our cached sheets and have them just reparse. | 289 // Clear our cached sheets and have them just reparse. |
| 387 HashSet<Page*>::const_iterator end = m_pages.end(); | 290 HashSet<Page*>::const_iterator end = m_pages.end(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 403 { | 306 { |
| 404 if (!m_captionPreferences) | 307 if (!m_captionPreferences) |
| 405 m_captionPreferences = CaptionUserPreferences::create(this); | 308 m_captionPreferences = CaptionUserPreferences::create(this); |
| 406 | 309 |
| 407 return m_captionPreferences.get(); | 310 return m_captionPreferences.get(); |
| 408 } | 311 } |
| 409 | 312 |
| 410 #endif | 313 #endif |
| 411 | 314 |
| 412 } // namespace WebCore | 315 } // namespace WebCore |
| OLD | NEW |