Changeset 147031 in webkit


Ignore:
Timestamp:
Mar 27, 2013 5:16:07 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: Plumb and expose cookie clearing options throughout the Resources Cookies tree and views
https://bugs.webkit.org/show_bug.cgi?id=87140

Patch by PhistucK <phistuck@chromium.org> on 2013-03-27
Reviewed by Vsevolod Vlasov.

Added cookie clearing buttons and context menu options
throughout the tree and views.
Drive by -

  • Made sure the delete button is only visible

when a cookie is selected.

  • Fixed a wrong JSDoc comment.
  • inspector/front-end/CookieItemsView.js:

(WebInspector.CookieItemsView):
(WebInspector.CookieItemsView.prototype.statusBarItems):
(WebInspector.CookieItemsView.prototype._updateWithCookies):
(WebInspector.CookieItemsView.prototype.clear):
Added. Clears the entire cookie view.
(WebInspector.CookieItemsView.prototype._clearButtonClicked):
Added. Ditto (when clicking on the button).
(WebInspector.CookieItemsView.prototype._showDeleteButton):
Added. Shows the delete button when selecting a cookie row.

  • inspector/CookiesTable.js:

(WebInspector.CookiesTable):
(WebInspector.CookiesTable.prototype._clearAndRefresh):
Added. Clears the cookies of the current table and updates it.
(WebInspector.CookiesTable.prototype._handleContextMenuEvent):
Added. Manages the context menu within the table.
(WebInspector.CookiesTable.prototype.clear):
Added. Clears the cookies of the current table.
(WebInspector.CookiesTable.prototype.setCookies):

Fixed a wrong JSDoc comment structure.

  • inspector/front-end/ResourcesPanel.js:

(WebInspector.ResourcesPanel.prototype.clearCookies):
Added. Clears the cookies of the given domain view.
(WebInspector.CookieTreeElement.prototype.onattach):
Added. Adds a contextmenu handler.
(WebInspector.CookieTreeElement.prototype._handleContextMenuEvent):
Added. Manages the context menu within cookie tree.
(WebInspector.CookieTreeElement.prototype._clearCookies):
Added. Clears the cookies of the view of the tree item.

  • inspector/front-end/treeoutline.js:

(TreeOutline): Fixed a wrong JSDoc comment.

  • English.lproj/localizedStrings.js:

Added strings for the context menu options.

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r147030 r147031  
     12013-03-27  PhistucK  <phistuck@chromium.org>
     2
     3        Web Inspector: Plumb and expose cookie clearing options throughout the Resources Cookies tree and views
     4        https://bugs.webkit.org/show_bug.cgi?id=87140
     5
     6        Reviewed by Vsevolod Vlasov.
     7
     8        Added cookie clearing buttons and context menu options
     9        throughout the tree and views.
     10        Drive by -
     11        - Made sure the delete button is only visible
     12        when a cookie is selected.
     13        - Fixed a wrong JSDoc comment.
     14
     15        * inspector/front-end/CookieItemsView.js:
     16        (WebInspector.CookieItemsView):
     17        (WebInspector.CookieItemsView.prototype.statusBarItems):
     18        (WebInspector.CookieItemsView.prototype._updateWithCookies):
     19        (WebInspector.CookieItemsView.prototype.clear):
     20        Added. Clears the entire cookie view.
     21        (WebInspector.CookieItemsView.prototype._clearButtonClicked):
     22        Added. Ditto (when clicking on the button).
     23        (WebInspector.CookieItemsView.prototype._showDeleteButton):
     24        Added. Shows the delete button when selecting a cookie row.
     25        * inspector/CookiesTable.js:
     26        (WebInspector.CookiesTable):
     27        (WebInspector.CookiesTable.prototype._clearAndRefresh):
     28        Added. Clears the cookies of the current table and updates it.
     29        (WebInspector.CookiesTable.prototype._handleContextMenuEvent):
     30        Added. Manages the context menu within the table.
     31        (WebInspector.CookiesTable.prototype.clear):
     32        Added. Clears the cookies of the current table.
     33        (WebInspector.CookiesTable.prototype.setCookies):
     34         Fixed a wrong JSDoc comment structure.
     35        * inspector/front-end/ResourcesPanel.js:
     36        (WebInspector.ResourcesPanel.prototype.clearCookies):
     37        Added. Clears the cookies of the given domain view.
     38        (WebInspector.CookieTreeElement.prototype.onattach):
     39        Added. Adds a contextmenu handler.
     40        (WebInspector.CookieTreeElement.prototype._handleContextMenuEvent):
     41        Added. Manages the context menu within cookie tree.
     42        (WebInspector.CookieTreeElement.prototype._clearCookies):
     43        Added. Clears the cookies of the view of the tree item.
     44        * inspector/front-end/treeoutline.js:
     45        (TreeOutline): Fixed a wrong JSDoc comment.
     46
     47        * English.lproj/localizedStrings.js:
     48        Added strings for the context menu options.
     49
    1502013-03-27  Andrey Lushnikov  <lushnikov@chromium.org>
    251
  • trunk/Source/WebCore/English.lproj/localizedStrings.js

    r146276 r147031  
    106106localizedStrings["Calls"] = "Calls";
    107107localizedStrings["Cannot find corresponding heap snapshot node"] = "Cannot find corresponding heap snapshot node";
     108localizedStrings["Clear All"] = "Clear All";
     109localizedStrings["Clear all"] = "Clear all";
     110localizedStrings["Clear all from \"%s\""] = "Clear all from \"%s\"";
     111localizedStrings["Clear All from \"%s\""] = "Clear All from \"%s\"";
    108112localizedStrings["Clear all profiles."] = "Clear all profiles.";
    109113localizedStrings["Clear Browser Cache"] = "Clear Browser Cache";
  • trunk/Source/WebCore/inspector/front-end/CookieItemsView.js

    r145875 r147031  
    4242    this._deleteButton.addEventListener("click", this._deleteButtonClicked, this);
    4343
     44    this._clearButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear"), "clear-storage-status-bar-item");
     45    this._clearButton.visible = false;
     46    this._clearButton.addEventListener("click", this._clearButtonClicked, this);
     47
    4448    this._refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"), "refresh-storage-status-bar-item");
    4549    this._refreshButton.addEventListener("click", this._refreshButtonClicked, this);
     
    5761    get statusBarItems()
    5862    {
    59         return [this._refreshButton.element, this._deleteButton.element];
     63        return [this._refreshButton.element, this._clearButton.element, this._deleteButton.element];
    6064    },
    6165
     
    8690            // Nothing to show.
    8791            this._emptyView.show(this.element);
     92            this._clearButton.visible = false;
    8893            this._deleteButton.visible = false;
    8994            if (this._cookiesTable)
     
    9398
    9499        if (!this._cookiesTable)
    95             this._cookiesTable = isAdvanced ? new WebInspector.CookiesTable(false, this._update.bind(this)) : new WebInspector.SimpleCookiesTable();
     100            this._cookiesTable = isAdvanced ? new WebInspector.CookiesTable(false, this._update.bind(this), this._showDeleteButton.bind(this)) : new WebInspector.SimpleCookiesTable();
    96101
    97102        this._cookiesTable.setCookies(this._cookies);
     
    101106            this._treeElement.subtitle = String.sprintf(WebInspector.UIString("%d cookies (%s)"), this._cookies.length,
    102107                Number.bytesToString(this._totalSize));
    103             this._deleteButton.visible = true;
     108            this._clearButton.visible = true;
     109            this._deleteButton.visible = !!this._cookiesTable.selectedCookie();
    104110        }
    105111    },
     
    139145    },
    140146
     147    clear: function()
     148    {
     149        this._cookiesTable.clear();
     150        this._update();
     151    },
     152
     153    _clearButtonClicked: function()
     154    {
     155        this.clear();
     156    },
     157
     158    _showDeleteButton: function()
     159    {
     160        this._deleteButton.visible = true;
     161    },
     162
    141163    _deleteButtonClicked: function()
    142164    {
  • trunk/Source/WebCore/inspector/front-end/CookiesTable.js

    r146325 r147031  
    3434 * @param {boolean} expandable
    3535 * @param {function()=} refreshCallback
     36 * @param {function()=} selectedCallback
    3637 */
    37 WebInspector.CookiesTable = function(expandable, refreshCallback)
     38WebInspector.CookiesTable = function(expandable, refreshCallback, selectedCallback)
    3839{
    3940    WebInspector.View.call(this);
     
    5455    ];
    5556
    56     this._dataGrid = new WebInspector.DataGrid(columns, null, readOnly ? null : this._onDeleteCookie.bind(this), refreshCallback);
     57    if (readOnly)
     58        this._dataGrid = new WebInspector.DataGrid(columns, null, null, refreshCallback);
     59    else {
     60        this._dataGrid = new WebInspector.DataGrid(columns);
     61        this._dataGrid.element.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
     62    }
     63
    5764    this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._rebuildTable, this);
     65
     66    if (selectedCallback)
     67        this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, selectedCallback, this);
    5868
    5969    this._nextSelectedCookie = /** @type {?WebInspector.Cookie} */ (null);
     
    7080    },
    7181
    72     /*
     82    /**
     83     * @param {?string} domain
     84     */
     85    _clearAndRefresh: function(domain)
     86    {
     87        this.clear(domain);
     88        if (this._refreshCallback)
     89            this._refreshCallback();
     90    },
     91
     92    _handleContextMenuEvent: function(event)
     93    {
     94        var gridNode = this._dataGrid.dataGridNodeFromNode(event.target);
     95
     96        if (!gridNode)
     97            return;
     98
     99        var contextMenu = new WebInspector.ContextMenu(event);
     100        var cookie = gridNode.cookie;
     101
     102        if (this._refreshCallback)
     103            contextMenu.appendItem(WebInspector.UIString("Refresh"), this._refreshCallback);
     104
     105        if (cookie) {
     106            contextMenu.appendItem(WebInspector.UIString("Delete"), this._onDeleteCookie.bind(this, gridNode));
     107            contextMenu.appendSeparator();
     108            var cookieDomain = cookie.domain();
     109           
     110            contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Clear all from \"%s\"" : "Clear All from \"%s\"", cookieDomain), this._clearAndRefresh.bind(this, cookieDomain));
     111        } else
     112            contextMenu.appendSeparator();
     113
     114        contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Clear all" : "Clear All"), this._clearAndRefresh.bind(this, null));
     115
     116        contextMenu.show();
     117    },
     118
     119    /**
    73120     * @param {!Array.<!WebInspector.Cookie>} cookies
    74121     */
     
    94141        var node = this._dataGrid.selectedNode;
    95142        return node ? node.cookie : null;
     143    },
     144
     145    /**
     146     * @param {string=} domain
     147     */
     148    clear: function(domain)
     149    {
     150        for (var i = 0, length = this._data.length; i < length; ++i) {
     151            var cookies = this._data[i].cookies;
     152            for (var j = 0, cookieCount = cookies.length; j < cookieCount; ++j) {
     153                if (!domain || cookies[j].domain() === domain)
     154                    cookies[j].remove();
     155            }
     156        }
    96157    },
    97158
  • trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js

    r146614 r147031  
    514514    },
    515515
     516    /**
     517     * @param {string} cookieDomain
     518     */
     519    clearCookies: function(cookieDomain)
     520    {
     521        this._cookieViews[cookieDomain].clear();
     522    },
     523
    516524    showApplicationCache: function(frameId)
    517525    {
     
    19401948    },
    19411949
     1950    onattach: function()
     1951    {
     1952        WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
     1953        this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
     1954    },
     1955
     1956    /**
     1957     * @param {Event} event
     1958     */
     1959    _handleContextMenuEvent: function(event)
     1960    {
     1961        var contextMenu = new WebInspector.ContextMenu(event);
     1962        contextMenu.appendItem(WebInspector.UIString("Clear"), this._clearCookies.bind(this));
     1963        contextMenu.show();
     1964    },
     1965
     1966    /**
     1967     * @param {string} domain
     1968     */
     1969    _clearCookies: function(domain)
     1970    {
     1971        this._storagePanel.clearCookies(this._cookieDomain);
     1972    },
     1973
    19421974    onselect: function(selectedByUser)
    19431975    {
  • trunk/Source/WebCore/inspector/front-end/treeoutline.js

    r136706 r147031  
    2929/**
    3030 * @constructor
     31 * @param {Element} listNode
    3132 * @param {boolean=} nonFocusable
    3233 */
Note: See TracChangeset for help on using the changeset viewer.