⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 169000 in webkit


Ignore:
Timestamp:
May 17, 2014, 4:24:34 PM (12 years ago)
Author:
andersca@apple.com
Message:

Give user scripts custom URLs
​https://bugs.webkit.org/show_bug.cgi?id=133035

Reviewed by Beth Dakin.

  • UIProcess/API/Cocoa/WKUserContentController.mm:

(-[WKUserContentController addUserScript:]):
Create a user-script:<number> URL for user scripts.

  • UIProcess/API/Cocoa/WKUserScript.h:

Move the init method after the properties.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r168999 r169000  
     12014-05-17  Anders Carlsson  <andersca@apple.com>
     2
     3        Give user scripts custom URLs
     4        https://bugs.webkit.org/show_bug.cgi?id=133035
     5
     6        Reviewed by Beth Dakin.
     7
     8        * UIProcess/API/Cocoa/WKUserContentController.mm:
     9        (-[WKUserContentController addUserScript:]):
     10        Create a user-script:<number> URL for user scripts.
     11
     12        * UIProcess/API/Cocoa/WKUserScript.h:
     13        Move the init method after the properties.
     14
    1152014-05-17  Anders Carlsson  <andersca@apple.com>
    216
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUserContentController.mm

    r168994 r169000  
    3333#import "_WKScriptWorld.h"
    3434#import <WebCore/UserScript.h>
     35#import <wtf/text/StringBuilder.h>
    3536
    3637@implementation WKUserContentController {
    … …  
    7273    [_userScripts addObject:userScript];
    7374
    74     _userContentControllerProxy->addUserScript(WebCore::UserScript { userScript->_source.get(), WebCore::blankURL(), { }, { }, toWebCoreUserScriptInjectionTime(userScript->_injectionTime), userScript->_forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames });
     75    StringBuilder urlStringBuilder;
     76    urlStringBuilder.append("user-script:");
     77    urlStringBuilder.appendNumber([_userScripts count]);
     78
     79    WebCore::URL url { WebCore::URL { }, urlStringBuilder.toString() };
     80    _userContentControllerProxy->addUserScript(WebCore::UserScript { userScript->_source.get(), url, { }, { }, toWebCoreUserScriptInjectionTime(userScript->_injectionTime), userScript->_forMainFrameOnly ? WebCore::InjectInTopFrameOnly : WebCore::InjectInAllFrames });
    7581}
    7682
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUserScript.h

    r168994 r169000  
    4545@interface WKUserScript : NSObject <NSCopying>
    4646
    47 /*! @abstract Returns an initialized user script that can be added to a @link WKUserContentController @/link.
    48  @param source The script source.
    49  @param injectionTime When the script should be injected.
    50  @param forMainFrameOnly Whether the script should be injected into all frames or just the main frame.
    51  */
    52 - (instancetype)initWithSource:(NSString *)source injectionTime:(WKUserScriptInjectionTime)injectionTime forMainFrameOnly:(BOOL)forMainFrameOnly;
    53 
    5447/* @abstract The script source code. */
    5548@property (nonatomic, readonly) NSString *source;
    … …  
    6154@property (nonatomic, readonly, getter=isForMainFrameOnly) BOOL forMainFrameOnly;
    6255
     56/*! @abstract Returns an initialized user script that can be added to a @link WKUserContentController @/link.
     57 @param source The script source.
     58 @param injectionTime When the script should be injected.
     59 @param forMainFrameOnly Whether the script should be injected into all frames or just the main frame.
     60 */
     61- (instancetype)initWithSource:(NSString *)source injectionTime:(WKUserScriptInjectionTime)injectionTime forMainFrameOnly:(BOOL)forMainFrameOnly;
     62
    6363@end
    6464
Note: See TracChangeset for help on using the changeset viewer.