summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcsilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-01 20:43:43 +0000
committercsilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-01 20:43:43 +0000
commit9effe6e6d6b885d6cdc71e1aa946d5c6f469d71e (patch)
tree48063ad09f460021d7d6f1cbd53603b7ac60eb3f
parent5249afba3c44b941606b573feaca363282c1809b (diff)
downloadchromium_src-9effe6e6d6b885d6cdc71e1aa946d5c6f469d71e.zip
chromium_src-9effe6e6d6b885d6cdc71e1aa946d5c6f469d71e.tar.gz
chromium_src-9effe6e6d6b885d6cdc71e1aa946d5c6f469d71e.tar.bz2
[ntp4] Remove bookmarks page implementation and resources.
BUG=105941 TEST=Verify NTP4 page continues to function properly. Review URL: http://codereview.chromium.org/8760003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112525 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd6
-rw-r--r--chrome/browser/about_flags.cc7
-rw-r--r--chrome/browser/resources/ntp4/bookmarks_page.css178
-rw-r--r--chrome/browser/resources/ntp4/bookmarks_page.js652
-rw-r--r--chrome/browser/resources/ntp4/new_tab.html35
-rw-r--r--chrome/browser/resources/ntp4/new_tab.js62
-rw-r--r--chrome/browser/resources/ntp4/page_list_view.js33
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_private.mm5
-rw-r--r--chrome/browser/ui/webui/ntp/bookmarks_handler.cc338
-rw-r--r--chrome/browser/ui/webui/ntp/bookmarks_handler.h94
-rw-r--r--chrome/browser/ui/webui/ntp/new_tab_ui.cc13
-rw-r--r--chrome/browser/ui/webui/ntp/new_tab_ui.h3
-rw-r--r--chrome/browser/ui/webui/ntp/ntp_resource_cache.cc4
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
16 files changed, 5 insertions, 1431 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 1c1098d..ce1f394 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4823,12 +4823,6 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_WEBUI_LOCK_DESCRIPTION" desc="Description for the flag to disable WebUI lock screen.">
Disable the new HTML implementation of the lock screen.
</message>
- <message name="IDS_FLAGS_ENABLE_NTP_BOOKMARK_FEATURES_NAME" desc="Title for the flag to enable NTP bookmark features.">
- Enable NTP bookmark features
- </message>
- <message name="IDS_FLAGS_ENABLE_NTP_BOOKMARK_FEATURES_DESCRIPTION" desc="Description for the flag to enable NTP bookmark features.">
- Enable experimental bookmark features within the NewTabPage.
- </message>
<message name="IDS_FLAGS_ENABLE_VIDEO_TRACK_NAME" desc="Title for the flag to enable the &lt;track&gt; element for &lt;video&gt; elements.">
Enable &lt;track&gt; element
</message>
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 5d27dd75..34633ea 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -375,13 +375,6 @@ const Experiment kExperiments[] = {
#endif
},
{
- "enable-ntp-bookmark-features",
- IDS_FLAGS_ENABLE_NTP_BOOKMARK_FEATURES_NAME,
- IDS_FLAGS_ENABLE_NTP_BOOKMARK_FEATURES_DESCRIPTION,
- kOsAll,
- SINGLE_VALUE_TYPE(switches::kEnableNTPBookmarkFeatures)
- },
- {
"enable-video-track",
IDS_FLAGS_ENABLE_VIDEO_TRACK_NAME,
IDS_FLAGS_ENABLE_VIDEO_TRACK_DESCRIPTION,
diff --git a/chrome/browser/resources/ntp4/bookmarks_page.css b/chrome/browser/resources/ntp4/bookmarks_page.css
deleted file mode 100644
index afa3198..0000000
--- a/chrome/browser/resources/ntp4/bookmarks_page.css
+++ /dev/null
@@ -1,178 +0,0 @@
-/* Copyright (c) 2011 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Bookmark Tiles ************************************************************/
-
-.bookmark {
- display: -webkit-box;
- position: absolute;
- -webkit-box-orient: vertical;
-}
-
-.bookmark-fills-parent {
- bottom: 0;
- display: -webkit-box;
- left: 0;
- position: absolute;
- right: 0;
- top: 0;
-}
-
-.bookmark.removable .close-button {
- display: block;
- opacity: 0;
- position: absolute;
- right: 0;
- top: 0;
- z-index: 5;
- -webkit-transition: opacity 150ms;
-}
-
-.bookmark .close-button {
- display: none;
-}
-
-html[dir=rtl] .bookmark .close-button {
- left: 0;
- right: auto;
-}
-
-.bookmark:hover .close-button {
- opacity: 1;
- -webkit-transition-delay: 500ms;
-}
-
-.bookmark .favicon {
- background: no-repeat 5% 90%;
-}
-
-.bookmark .color-stripe {
- border-bottom-left-radius: 3px 3px;
- border-bottom-right-radius: 3px 3px;
- /* Matches height of title. */
- bottom: 23px;
- height: 3px;
- /* Matches padding-top of the title. */
- margin-bottom: 8px;
- position: absolute;
- width: 100%;
- z-index: 100;
-}
-
-.bookmark .title {
- cursor: pointer;
- display: block;
- height: 23px;
- overflow: hidden;
- padding-top: 8px;
- text-align: center;
- text-decoration: none;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.bookmark .button {
- cursor: pointer;
- background-color: rgba(0, 0, 0, 0.15);
- border: 1px solid transparent;
- border-radius: 5px;
- bottom: 70px;
- position: relative;
- z-index: 5;
- -webkit-box-flex: 1;
- -webkit-transition: background-color 150ms;
-}
-
-.bookmark:hover .button {
- background-color: rgba(0, 0, 0, 0.3);
-}
-
-.bookmark .button-frame {
- background-color: #fff;
- border-radius: 5px;
-}
-
-.bookmark:hover .button-frame {
- background-color: #f7f7f7;
-}
-
-/* The bookmark gets a shadow when clicked, but not when the click is on the
- * close button. */
-.bookmark:active .close-button:not(:active) + .button-frame {
- -webkit-box-shadow: inset 0 1px 10px rgba(0, 0, 0, 0.2);
-}
-
-/* Bookmark Titles ************************************************************/
-
-#bookmarks-title-wrapper {
- /* this color matches the gradiant end color for the #footer element. */
- background-color: rgba(242, 242, 242, 0.9);
- border-bottom: 1px solid;
- color: #777;
- display: -webkit-box;
- font-size: 16px;
- height: 48px;
- line-height: 48px;
- overflow: hidden;
- white-space: nowrap;
-}
-
-#bookmarks-title-wrapper .title-crumb {
- cursor: pointer;
- margin: 0 25px;
-}
-
-#bookmarks-title-wrapper .title-crumb-active {
- color: #7f7f7f;
- cursor: default;
- font-weight: bold;
- -webkit-margin-end: 0;
- -webkit-padding-end: 10px;
-}
-
-.section-title {
- display: -webkit-box;
- left: 0;
- overflow: hidden;
- position: absolute;
- right: 0;
- top: 0;
- -webkit-box-flex: 1;
- -webkit-box-orient: horizontal;
-}
-
-.bookmark-separator {
- background: -webkit-canvas(bookmark-chevron) center center no-repeat;
- border: 0;
- height: 44px;
- margin: 2px 0;
- width: 10px;
-}
-
-html[dir="rtl"] .bookmark-separator {
- -webkit-transform: scale(-1, 1);
-}
-
-#bookmarks-top-link-wrapper {
- left: 10px;
- position: absolute;
- right: 10px;
- text-align: end;
- top: 10px;
-}
-
-#bookmarks-bottom-link-wrapper {
- height: 40px;
- /* Matches .tile-page-content padding-right - 10px */
- margin: 0px -70px;
- text-align: end;
-}
-
-.bookmarks-import-data-link-wrapper {
- left: 0;
- position: absolute;
- right: 0;
- top: 33%;
-}
diff --git a/chrome/browser/resources/ntp4/bookmarks_page.js b/chrome/browser/resources/ntp4/bookmarks_page.js
deleted file mode 100644
index 6816270..0000000
--- a/chrome/browser/resources/ntp4/bookmarks_page.js
+++ /dev/null
@@ -1,652 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('ntp4', function() {
- 'use strict';
-
- var localStrings = new LocalStrings;
-
- /**
- * A running count of bookmark tiles that we create so that each will have
- * a unique ID.
- */
- var tileId = 0;
-
- /**
- * The maximum number of tiles that we will display on this page. If there
- * are not enough spaces to show all bookmarks, we'll include a link to the
- * Bookmarks manager.
- * TODO(csilv): Eliminate the need for this restraint.
- * @type {number}
- * @const
- */
- var MAX_BOOKMARK_TILES = 18;
-
- /**
- * The root node's ID. We need this to determine removable items (direct
- * children aren't removable).
- * @type {number}
- * @const
- */
- var ROOT_NODE_ID = '0';
-
- /**
- * The bookmark bar's ID. We need this to allow combining the root and
- * bookmarks bars at the top level of the folder hierarchy/bookmarks page.
- * aren't removable).
- * @type {number}
- * @const
- */
- var BOOKMARKS_BAR_ID = '1';
-
- /**
- * Creates a new bookmark object.
- * @param {Object} data The url and title.
- * @constructor
- * @extends {HTMLDivElement}
- */
- function Bookmark(data) {
- var el = $('bookmark-template').cloneNode(true);
- el.__proto__ = Bookmark.prototype;
- el.initialize(data);
-
- return el;
- }
-
- Bookmark.prototype = {
- __proto__: HTMLDivElement.prototype,
-
- /**
- * Initialize the bookmark object.
- * @param {Object} data The bookmark data (url, title, etc).
- */
- initialize: function(data) {
- this.data = data;
- this.hidden = false;
-
- var id = tileId++;
- this.id = 'bookmark_tile_' + id;
-
- var title = this.querySelector('.title');
- title.textContent = this.data.title;
-
- // Sets the tooltip.
- this.title = this.data.title;
-
- if (this.data.url) {
- var button = this.querySelector('.button');
- button.href = title.href = this.data.url;
- }
-
- var faviconDiv = this.querySelector('.favicon');
- var faviconUrl;
- if (this.data.url) {
- faviconUrl = 'chrome://favicon/size/16/' + this.data.url;
- chrome.send('getFaviconDominantColor', [faviconUrl, this.id]);
- } else {
- faviconUrl = 'chrome://theme/IDR_BOOKMARK_BAR_FOLDER';
- // TODO(csilv): Should we vary this color by platform?
- this.stripeColor = '#919191';
- }
- faviconDiv.style.backgroundImage = url(faviconUrl);
-
- if (this.canBeRemoved())
- this.classList.add('removable');
-
- this.addEventListener('click', this.handleClick_.bind(this));
- },
-
- /**
- * Sets the color of the favicon dominant color bar.
- * @param {string} color The css-parsable value for the color.
- */
- set stripeColor(color) {
- this.querySelector('.color-stripe').style.backgroundColor = color;
- },
-
- /**
- * Set the size and position of the bookmark tile.
- * @param {number} size The total size of |this|.
- * @param {number} x The x-position.
- * @param {number} y The y-position.
- * animate.
- */
- setBounds: function(size, x, y) {
- this.style.width = size + 'px';
- this.style.height = heightForWidth(size) + 'px';
-
- this.style.left = x + 'px';
- this.style.right = x + 'px';
- this.style.top = y + 'px';
- },
-
- /**
- * Set some data on the drag when it starts.
- * @param {DataTransfer} dataTransfer A data transfer object from the
- * current drag.
- */
- setDragData: function(dataTransfer) {
- // OS X requires extra data drag data to consider a drag useful, so we're
- // appending some semi-useful data at the end to force drags to work on
- // this OS. Don't use this data for anything -- this is just a hack to
- // ensure drag works the same as on other platforms.
- dataTransfer.setData('Text', this.data.id);
- },
-
- /**
- * Invoked when a bookmark is clicked
- * @param {Event} e The click event.
- * @private
- */
- handleClick_: function(e) {
- if (e.target.classList.contains('close-button')) {
- e.preventDefault();
- this.removeFromChrome();
- } else if (!this.data.url) {
- chrome.send('getBookmarksData', [this.data.id]);
- e.preventDefault();
- }
- },
-
- /** @inheritDoc */
- removeFromChrome: function() {
- chrome.send('removeBookmark', [this.data.id]);
- },
-
- /**
- * All bookmarks except for children of the root node.
- * @return {boolean} Whether or not the item can be removed.
- */
- canBeRemoved: function() {
- return this.data.parentId !== ROOT_NODE_ID;
- },
- };
-
- /**
- * Creates a new bookmark title object.
- * @param {Object} data The url and title.
- * @constructor
- * @extends {HTMLDivElement}
- */
- function BookmarkTitle(data) {
- var el = cr.doc.createElement('div');
- el.__proto__ = BookmarkTitle.prototype;
- el.initialize(data);
-
- return el;
- }
-
- BookmarkTitle.prototype = {
- __proto__: HTMLDivElement.prototype,
-
- /**
- * Initialize the bookmark title object.
- */
- initialize: function(data) {
- this.className = 'title-crumb';
- this.folderId = data.id;
- this.textContent = data.parentId ? data.title :
- localStrings.getString('bookmarksPage');
-
- this.addEventListener('click', this.handleClick_);
- },
-
- /**
- * Invoked when a bookmark title is clicked
- * @param {Event} e The click event.
- * @private
- */
- handleClick_: function(e) {
- chrome.send('getBookmarksData', [this.folderId]);
- },
- };
-
- var TilePage = ntp4.TilePage;
-
- var bookmarksPageGridValues = {
- // The fewest tiles we will show in a row.
- minColCount: 3,
- // The most tiles we will show in a row.
- maxColCount: 6,
-
- // The smallest a tile can be.
- minTileWidth: 64,
- // The biggest a tile can be.
- maxTileWidth: 96,
-
- // The padding between tiles, as a fraction of the tile width.
- tileSpacingFraction: 1 / 2,
- };
- TilePage.initGridValues(bookmarksPageGridValues);
-
- /**
- * Calculates the height for a bookmarks tile for a given width. The size
- * is based on a desired size of 96x72 ratio.
- * @return {number} The height.
- */
- function heightForWidth(width) {
- // The 2s are for borders, the 31 is for the title.
- return (width - 2) * 72 / 96 + 2 + 31;
- }
-
- /**
- * Creates a new BookmarksPage object.
- * @constructor
- * @extends {TilePage}
- */
- function BookmarksPage() {
- var el = new TilePage(bookmarksPageGridValues);
- el.__proto__ = BookmarksPage.prototype;
- el.initialize();
-
- return el;
- }
-
- BookmarksPage.prototype = {
- __proto__: TilePage.prototype,
-
- /**
- * Initialize the bookmarks page object.
- */
- initialize: function() {
- this.classList.add('bookmarks-page');
-
- // Insert the bookmark titles header which is unique to bookmark pages.
- var titleWrapper = $('bookmarks-title-wrapper')
- titleWrapper.hidden = false;
- this.insertBefore(titleWrapper, this.firstChild);
-
- // Insert the top & bottom links for the Bookmarks Manager page.
- var pageContent = this.querySelector('.tile-page-content');
- var topWrapper = $('bookmarks-top-link-wrapper');
- pageContent.insertBefore(topWrapper, pageContent.firstChild);
- topWrapper.hidden = false;
- pageContent.appendChild($('bookmarks-bottom-link-wrapper'));
- },
-
- /**
- * Build the bookmark titles bar (ie, navigation hiearchy).
- * @param {Array} items The parent hiearchy of the current folder.
- * @private
- */
- updateBookmarkTitles_: function(items) {
- var wrapper = $('bookmarks-title-wrapper');
- var title = wrapper.querySelector('.section-title');
- title.innerHTML = '';
-
- for (var i = items.length - 1; i > 0; i--) {
- title.appendChild(new BookmarkTitle(items[i]));
-
- var separator = document.createElement('hr');
- separator.className = 'bookmark-separator';
- title.appendChild(separator);
- }
-
- var titleCrumb = new BookmarkTitle(items[0]);
- titleCrumb.classList.add('title-crumb-active');
- title.appendChild(titleCrumb);
- },
-
- /**
- * Build the bookmark tiles.
- * @param {Array} items The contents of the current folder.
- * @private
- */
- updateBookmarkTiles_: function(items) {
- this.removeAllTiles();
- var tile_count = Math.min(items.length, MAX_BOOKMARK_TILES);
- for (var i = 0; i < tile_count; i++)
- this.appendTile(new Bookmark(items[i]), false);
-
- var folder_id = this.id == ROOT_NODE_ID ? BOOKMARKS_BAR_ID : this.id;
- var top_link = $('bookmarks-top-link-wrapper').querySelector('a');
- top_link.href = 'chrome://bookmarks/#' + folder_id;
-
- var wrapper = $('bookmarks-bottom-link-wrapper');
- if (items.length > MAX_BOOKMARK_TILES) {
- var bottom_link = wrapper.querySelector('a');
- bottom_link.href = 'chrome://bookmarks/#' + folder_id;
- wrapper.hidden = false;
- } else {
- wrapper.hidden = true;
- }
-
- if (this.id === ROOT_NODE_ID && !tile_count && !cr.isChromeOS)
- this.showImportPromo_();
- },
-
- /**
- * Determine whether a bookmark ID matches a folder in the current
- * hierarchy.
- * @param {string} id The bookmark ID to search for.
- * @private
- */
- isBookmarkInParentHierarchy_: function(id) {
- var titlesWrapper = $('bookmarks-title-wrapper');
- var titles = titlesWrapper.querySelectorAll('.title-crumb');
- for (var i = 0; i < titles.length; i++) {
- var bookmarkTitle = titles[i];
- if (bookmarkTitle.folderId == id)
- return true;
- }
- return false;
- },
-
- /**
- * Tells if we're in currently in the given folder.
- * @param {String} id The folder node's ID.
- * @returns {boolean} If it's in that folder (visually).
- */
- currentlyInFolder_: function(id) {
- return id === this.id || (this.id === ROOT_NODE_ID &&
- id === BOOKMARKS_BAR_ID);
- },
-
- /** @inheritDoc */
- shouldAcceptDrag: function(e) {
- var tile = ntp4.getCurrentlyDraggingTile();
- if (tile)
- return !!tile.querySelector('.most-visited, .bookmark');
- // If there was no dragging tile, look for a URL in the drag data.
- return e.dataTransfer && e.dataTransfer.types &&
- e.dataTransfer.types.indexOf('url') != -1;
- },
-
- /** @inheritDoc */
- heightForWidth: heightForWidth,
-
- /**
- * Invoked before a batch import begins. We will ignore added/changed
- * notifications while the operation is in progress.
- */
- bookmarkImportBegan: function() {
- this.importing = true;
- },
-
- /**
- * Invoked after a batch import finishes. We will reload the bookmarks
- * page to reflect the new state.
- */
- bookmarkImportEnded: function() {
- this.importing = false;
- chrome.send('getBookmarksData', []);
- },
-
- /**
- * Invoked when a node has been added.
- * @param {string} id The id of the newly created bookmark node.
- * @param {Object} bookmark The new bookmark node.
- * @param {boolean} fromCurrentPage True if the action was from this page.
- */
- bookmarkNodeAdded: function(id, bookmark, fromCurrentPage) {
- if (this.importing) return;
- if (this.currentlyInFolder_(bookmark.parentId)) {
- // Hide the import promo if it exists.
- this.hideImportPromo_();
- // Only add the item if it should be visible.
- if (bookmark.index < MAX_BOOKMARK_TILES) {
- // If source of the add came from this page, show an animated
- // insertion, otherwise just quietly do it.
- this.addTileAt(new Bookmark(bookmark), bookmark.index,
- fromCurrentPage);
- // Delete extra tiles if they exist.
- while (this.tiles.length > MAX_BOOKMARK_TILES) {
- var tile = this.tiles[this.tiles.length - 1];
- this.removeTile(tile, false);
- }
- this.repositionTiles_();
- }
- }
- },
-
- /**
- * Invoked when the title or url of a node changes.
- * @param {string} id The id of the changed node.
- * @param {Object} changeInfo Details of the changed node.
- */
- bookmarkNodeChanged: function(id, changeInfo) {
- if (this.importing) return;
-
- // If the current folder or parent is being re-named, reload the page.
- // TODO(csilv): Optimize this to reload just the titles.
- if (this.isBookmarkInParentHierarchy_(id)) {
- chrome.send('getBookmarksData', [this.id]);
- return;
- }
-
- // If the target item is contained in this folder, update just that item.
- for (var i = 0; i < this.tiles.length; i++) {
- var tile = this.tiles[i];
- var data = tile.firstChild.data;
-
- if (data.id == id) {
- data.title = changeInfo.title;
- var title = tile.querySelector('.title');
- title.textContent = data.title;
-
- if (changeInfo.url) {
- data.url = changeInfo.url;
- var button = tile.querySelector('.button');
- button.href = title.href = data.url;
- }
- break;
- }
- }
- },
-
- /**
- * Invoked when the children (just direct children, not descendants) of
- * a folder have been reordered in some way, such as sorted.
- * @param {string} id The id of the reordered bookmark node.
- * @param {!Object} reorderInfo Details of the reordered bookmark node.
- */
- bookmarkNodeChildrenReordered: function(id, reorderInfo) {
- if (this.currentlyInFolder_(id))
- chrome.send('getBookmarksData', [this.id]);
- },
-
- /**
- * Invoked when a node has moved.
- * @param {string} id The id of the moved bookmark node.
- * @param {!Object} moveInfo Details of the moved bookmark.
- */
- bookmarkNodeMoved: function(id, moveInfo) {
- // TODO(csilv): Optimize this by doing less than reloading the folder.
- // Reload the current page if the target item is the current folder
- // or a parent of the current folder.
- if (this.isBookmarkInParentHierarchy_(id)) {
- chrome.send('getBookmarksData', [this.id]);
- return;
- }
-
- // Reload the current page if the target item is being moved to/from the
- // current folder.
- if (this.currentlyInFolder_(moveInfo.parentId) ||
- this.currentlyInFolder_(moveInfo.oldParentId)) {
- chrome.send('getBookmarksData', [this.id]);
- }
- },
-
- /**
- * Invoked when a node has been removed from a folder.
- * @param {string} id The id of the removed bookmark node.
- * @param {!Object} removeInfo Details of the removed bookmark node.
- * @param {boolearn} fromCurrentPage If the event was from this page.
- */
- bookmarkNodeRemoved: function(id, removeInfo, fromCurrentPage) {
- // If the target item is the visibile folder or a parent folder, load
- // the parent of the removed item.
- if (this.isBookmarkInParentHierarchy_(id)) {
- chrome.send('getBookmarksData', [removeInfo.parentId]);
- return;
- }
-
- // If the target item is contained in the visible folder, find the
- // matching tile and delete it.
- if (this.currentlyInFolder_(removeInfo.parentId)) {
- for (var i = 0; i < this.tiles.length; i++) {
- var tile = this.tiles[i];
- if (tile.firstChild.data.id == id) {
- this.removeTile(tile, fromCurrentPage);
- break;
- }
- }
- }
- },
-
- /**
- * Set the bookmark data that should be displayed, replacing any existing
- * data.
- * @param {Object} data Data that shoudl be displayed. Contains arrays
- * 'items' and 'navigationItems'.
- */
- set data(data) {
- this.id = data.navigationItems[0].id;
- this.updateBookmarkTiles_(data.items);
- this.updateBookmarkTitles_(data.navigationItems);
- },
-
- /** @inheritDoc */
- get extraBottomPadding() {
- return 40;
- },
-
- /** @inheritDoc */
- setDropEffect: function(dataTransfer) {
- var tile = ntp4.getCurrentlyDraggingTile();
- if (tile && tile.querySelector('.bookmark'))
- ntp4.setCurrentDropEffect(dataTransfer, 'move');
- else
- ntp4.setCurrentDropEffect(dataTransfer, 'copy');
- },
-
- /** @inheritDoc */
- addDragData: function(dataTransfer, index) {
- var parentId = ROOT_NODE_ID == this.id ? BOOKMARKS_BAR_ID : this.id;
- var currentlyDraggingTile = ntp4.getCurrentlyDraggingTile();
- if (currentlyDraggingTile) {
- var tileContents = currentlyDraggingTile.firstChild;
- if (tileContents.classList.contains('most-visited')) {
- this.generateBookmarkForLink(parentId, index,
- tileContents.textContent,
- tileContents.href);
- }
- } else {
- this.addOutsideData_(dataTransfer, parentId, index);
- }
- },
-
- /**
- * If we got an outside drag from a page or the URL bar.
- * @param {!DataTransfer} dataTransfer The drag data transfer object.
- * @param {number} parentId The parent ID for the current bookmark level.
- * @param {number} index Position it will be inserted relative to siblings.
- */
- addOutsideData_: function(dataTransfer, parentId, index) {
- var url = dataTransfer.getData('url');
- assert(url && url !== window.location.href);
- // Look for any text/html types first (links, etc.).
- var title, html = dataTransfer.getData('text/html');
- if (html) {
- // NOTE: Don't insert this into the DOM! It could XSS the page!
- var node = this.ownerDocument.createElement('div');
- node.innerHTML = html;
- var text = node.textContent, img = node.firstChild;
- // OS X prepends a <meta> tag to the html for some reason...
- if ('META' == img.nodeName)
- img = img.nextSibling;
- // Use the combined text (if it exists), otherwise fall back to an
- // image's alternate text (if they dragged an image onto this page).
- title = text || ('IMG' == img.nodeName && img.alt);
- }
- // If we *still* don't have a title, just use the URL.
- if (!title)
- title = url;
- // Create a bookmark for the dropped data.
- this.generateBookmarkForLink(parentId, index, title, url);
- },
-
- /**
- * Show the 'Import bookmarks' promo.
- * @private
- */
- showImportPromo_: function() {
- var importTemplate = $('bookmarks-import-data-link-template');
- var importWrapper = importTemplate.cloneNode(true);
- importWrapper.id = '';
- importWrapper.hidden = false;
- this.querySelector('.tile-page-content').appendChild(importWrapper);
- },
-
- /**
- * Hide the 'Import bookmarks' promo.
- * @private
- */
- hideImportPromo_: function() {
- var wrapper = this.querySelector('.bookmarks-import-data-link-wrapper');
- if (wrapper)
- wrapper.parentNode.removeChild(wrapper);
- },
-
- /**
- * Create a bookmark from a title/url.
- * @param {!string} parentId Stringified int64 of the parent node's ID.
- * @param {number} index Sibling relative index, i.e. 3rd on this level.
- * @param {string} title More human readable title of the bookmark.
- * @param {string} url URL of the bookmark to be created.
- */
- generateBookmarkForLink: function(parentId, index, title, url) {
- // Bookmark creation actually only *requires* a parent ID, as if we just
- // pass a parent ID it's created as a folder with blank title as a child
- // of that parent.
- assert(parentId);
- chrome.send('createBookmark', [parentId, index, title, url]);
- },
-
- /** @inheritDoc */
- tileMoved: function(tile, prevIndex) {
- var parentId = ROOT_NODE_ID == this.id ? BOOKMARKS_BAR_ID : this.id;
- chrome.send('moveBookmark', [tile.firstChild.data.id, parentId,
- tile.index + (prevIndex < tile.index)]);
- },
- };
-
- /**
- * Initializes and renders the bookmark chevron canvas. This needs to be
- * performed after the page has been loaded so that we have access to the
- * style sheet values.
- */
- function initBookmarkChevron() {
- var wrapperStyle = window.getComputedStyle($('bookmarks-title-wrapper'));
- var width = 10;
- var height = parseInt(wrapperStyle.height, 10);
- var ctx = document.getCSSCanvasContext('2d', 'bookmark-chevron',
- width, height);
- ctx.strokeStyle = wrapperStyle.borderBottomColor;
- ctx.beginPath();
- ctx.moveTo(0, 0);
- ctx.lineTo(width, height / 2);
- ctx.lineTo(0, height);
- ctx.stroke();
- }
-
- /**
- * Set the dominant color for a bookmark tile. This is the callback method
- * from a request made when the tile was created.
- * @param {string} id The ID of the bookmark tile.
- * @param {string} color The color represented as a CSS string.
- */
- function setBookmarksFaviconDominantColor(id, color) {
- var tile = $(id);
- if (tile)
- tile.stripeColor = color;
- }
-
- return {
- BookmarksPage: BookmarksPage,
- initBookmarkChevron: initBookmarkChevron,
- };
-});
-
-window.addEventListener('load', ntp4.initBookmarkChevron);
diff --git a/chrome/browser/resources/ntp4/new_tab.html b/chrome/browser/resources/ntp4/new_tab.html
index bb79acd..5433909 100644
--- a/chrome/browser/resources/ntp4/new_tab.html
+++ b/chrome/browser/resources/ntp4/new_tab.html
@@ -25,7 +25,6 @@
<link rel="stylesheet" href="../shared/css/expandable_bubble.css">
<link rel="stylesheet" href="../shared/css/menu.css">
<link rel="stylesheet" href="apps_page.css">
-<link rel="stylesheet" href="bookmarks_page.css">
<link rel="stylesheet" href="most_visited_page.css">
<link rel="stylesheet" href="nav_dot.css">
<link rel="stylesheet" href="new_tab.css">
@@ -53,7 +52,6 @@
<script src="tile_page.js"></script>
<script src="apps_page.js"></script>
-<script src="bookmarks_page.js"></script>
<script src="dot_list.js"></script>
<script src="most_visited_page.js"></script>
<script src="trash.js"></script>
@@ -162,37 +160,4 @@
<span class="title"></span>
</div>
-<!-- Bookmark -->
-<div id="bookmark-template" class="bookmark" hidden>
- <a class="button bookmark-fills-parent">
- <div class="close-button" hidden></div>
- <span class="button-frame bookmark-fills-parent"></span>
- <span class="favicon bookmark-fills-parent"></span>
- </a>
- <div class="color-stripe"></div>
- <a class="title"></a>
-</div>
-
-<!-- Bookmarks Title Wrapper -->
-<div id="bookmarks-title-wrapper" class="section-title-wrapper" hidden>
- <div class="section-title"></div>
-</div>
-
-<!-- Bookmarks Top Link -->
-<div id="bookmarks-top-link-wrapper" hidden>
- <a i18n-content="bookmarksManagerLinkTitle" class="link-color"></a>
-</div>
-
-<!-- Bookmarks Bottom Link -->
-<div id="bookmarks-bottom-link-wrapper" hidden>
- <a i18n-content="bookmarksShowAllLinkTitle" class="link-color"></a>
-</div>
-
-<!-- Bookmarks Import Data Link -->
-<div id="bookmarks-import-data-link-template"
- class="bookmarks-import-data-link-wrapper" hidden>
- <a href="chrome://settings/importData"
- i18n-content="importDataLinkTitle" class="link-color"></a>
-</div>
-
</html>
diff --git a/chrome/browser/resources/ntp4/new_tab.js b/chrome/browser/resources/ntp4/new_tab.js
index 53f3a53..c4c7766 100644
--- a/chrome/browser/resources/ntp4/new_tab.js
+++ b/chrome/browser/resources/ntp4/new_tab.js
@@ -155,14 +155,6 @@ cr.define('ntp4', function() {
infoBubble.show();
}
- var bookmarkFeatures = localStrings.getString('bookmark_features');
- if (bookmarkFeatures == 'true') {
- newTabView.appendTilePage(new ntp4.BookmarksPage(),
- localStrings.getString('bookmarksPage'),
- false);
- chrome.send('getBookmarksData');
- }
-
var serverpromo = localStrings.getString('serverpromo');
if (serverpromo) {
showNotification(parseHtmlSubset(serverpromo), [], function() {
@@ -294,52 +286,6 @@ cr.define('ntp4', function() {
newTabView.mostVisitedPage.data = data;
}
- function setBookmarksData(data) {
- newTabView.bookmarksPage.data = data;
- }
-
- function bookmarkImportBegan() {
- newTabView.bookmarksPage.bookmarkImportBegan.apply(
- newTabView.bookmarksPage,
- arguments);
- }
-
- function bookmarkImportEnded() {
- newTabView.bookmarksPage.bookmarkImportEnded.apply(
- newTabView.bookmarksPage,
- arguments);
- }
-
- function bookmarkNodeAdded() {
- newTabView.bookmarksPage.bookmarkNodeAdded.apply(
- newTabView.bookmarksPage,
- arguments);
- }
-
- function bookmarkNodeChanged() {
- newTabView.bookmarksPage.bookmarkNodeChanged.apply(
- newTabView.bookmarksPage,
- arguments);
- }
-
- function bookmarkNodeChildrenReordered() {
- newTabView.bookmarksPage.bookmarkNodeChildrenReordered.apply(
- newTabView.bookmarksPage,
- arguments);
- }
-
- function bookmarkNodeMoved() {
- newTabView.bookmarksPage.bookmarkNodeMoved.apply(
- newTabView.bookmarksPage,
- arguments);
- }
-
- function bookmarkNodeRemoved() {
- newTabView.bookmarksPage.bookmarkNodeRemoved.apply(
- newTabView.bookmarksPage,
- arguments);
- }
-
/**
* Set the dominant color for a node. This will be called in response to
* getFaviconDominantColor. The node represented by |id| better have a setter
@@ -424,13 +370,6 @@ cr.define('ntp4', function() {
appAdded: appAdded,
appRemoved: appRemoved,
appsPrefChangeCallback: appsPrefChangeCallback,
- bookmarkImportBegan: bookmarkImportBegan,
- bookmarkImportEnded: bookmarkImportEnded,
- bookmarkNodeAdded: bookmarkNodeAdded,
- bookmarkNodeChanged: bookmarkNodeChanged,
- bookmarkNodeChildrenReordered: bookmarkNodeChildrenReordered,
- bookmarkNodeMoved: bookmarkNodeMoved,
- bookmarkNodeRemoved: bookmarkNodeRemoved,
enterRearrangeMode: enterRearrangeMode,
getAppsCallback: getAppsCallback,
getAppsPageIndex: getAppsPageIndex,
@@ -439,7 +378,6 @@ cr.define('ntp4', function() {
leaveRearrangeMode: leaveRearrangeMode,
saveAppPageName: saveAppPageName,
setAppToBeHighlighted: setAppToBeHighlighted,
- setBookmarksData: setBookmarksData,
setMostVisitedPages: setMostVisitedPages,
setRecentlyClosedTabs: setRecentlyClosedTabs,
setStripeColor: setStripeColor,
diff --git a/chrome/browser/resources/ntp4/page_list_view.js b/chrome/browser/resources/ntp4/page_list_view.js
index 7db35c0..dbbe5ea 100644
--- a/chrome/browser/resources/ntp4/page_list_view.js
+++ b/chrome/browser/resources/ntp4/page_list_view.js
@@ -65,12 +65,6 @@ cr.define('ntp4', function() {
mostVisitedPage: undefined,
/**
- * The Bookmarks page.
- * @type {!Element|undefined}
- */
- bookmarksPage: undefined,
-
- /**
* The 'dots-list' element.
* @type {!Element|undefined}
*/
@@ -189,7 +183,7 @@ cr.define('ntp4', function() {
},
/**
- * Appends a tile page (for bookmarks or most visited).
+ * Appends a tile page.
*
* @param {TilePage} page The page element.
* @param {string} title The title of the tile page.
@@ -200,24 +194,16 @@ cr.define('ntp4', function() {
* the page list.
*/
appendTilePage: function(page, title, titleIsEditable, opt_refNode) {
- // If no opt_refNode given, use bookmarksPage (if any).
- if (!opt_refNode)
- opt_refNode = this.bookmarksPage;
-
// When opt_refNode is falsey, insertBefore acts just like appendChild.
this.pageList.insertBefore(page, opt_refNode);
- // Remember special MostVisitedPage and BookmarksPage.
+ // Remember special MostVisitedPage.
if (typeof ntp4.MostVisitedPage != 'undefined' &&
page instanceof ntp4.MostVisitedPage) {
assert(this.tilePages.length == 1,
'MostVisitedPage should be added as first tile page');
this.mostVisitedPage = page;
}
- if (typeof ntp4.BookmarksPage != 'undefined' &&
- page instanceof ntp4.BookmarksPage) {
- this.bookmarksPage = page;
- }
// If we're appending an AppsPage and it's a temporary page, animate it.
var animate = page instanceof ntp4.AppsPage &&
@@ -380,14 +366,10 @@ cr.define('ntp4', function() {
$(data.apps[i].id).appData = data.apps[i];
}
- // Set the App dot names. Skip the first and last dots (Most Visited and
- // Bookmarks).
+ // Set the App dot names. Skip the first dot (Most Visited).
var dots = this.dotList.getElementsByClassName('dot');
- // TODO(csilv): Remove this calcluation if/when we remove the flag for
- // for the bookmarks page.
var start = this.mostVisitedPage ? 1 : 0;
- var length = this.bookmarksPage ? dots.length - 1 : dots.length;
- for (var i = start; i < length; ++i) {
+ for (var i = start; i < dots.length; ++i) {
dots[i].displayTitle = data.appPageNames[i - start] || '';
}
},
@@ -407,10 +389,6 @@ cr.define('ntp4', function() {
this.appsPages[Math.min(this.shownPageIndex,
this.appsPages.length - 1)]);
break;
- case templateData['bookmarks_page_id']:
- if (this.bookmarksPage)
- this.cardSlider.selectCardByValue(this.bookmarksPage);
- break;
case templateData['most_visited_page_id']:
if (this.mostVisitedPage)
this.cardSlider.selectCardByValue(this.mostVisitedPage);
@@ -536,9 +514,6 @@ cr.define('ntp4', function() {
} else if (page.classList.contains('most-visited-page')) {
this.shownPage = templateData['most_visited_page_id'];
this.shownPageIndex = 0;
- } else if (page.classList.contains('bookmarks-page')) {
- this.shownPage = templateData['bookmarks_page_id'];
- this.shownPageIndex = 0;
} else {
console.error('unknown page selected');
}
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index 8bffae0..b4416f8 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -30,7 +30,6 @@
#import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
-#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
#include "chrome/common/pref_names.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -533,10 +532,6 @@ willPositionSheet:(NSWindow*)sheet
}
- (BOOL)shouldShowDetachedBookmarkBar {
- // Don't show detatched bookmarks when NTP4 bookmark features exist.
- if (NewTabUI::NTP4BookmarkFeaturesEnabled())
- return NO;
-
DCHECK(browser_.get());
TabContentsWrapper* tab = browser_->GetSelectedTabContentsWrapper();
return (tab && tab->bookmark_tab_helper()->ShouldShowBookmarkBar() &&
diff --git a/chrome/browser/ui/webui/ntp/bookmarks_handler.cc b/chrome/browser/ui/webui/ntp/bookmarks_handler.cc
deleted file mode 100644
index e36859b..0000000
--- a/chrome/browser/ui/webui/ntp/bookmarks_handler.cc
+++ /dev/null
@@ -1,338 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/ntp/bookmarks_handler.h"
-
-#include "base/auto_reset.h"
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/string_number_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/bookmarks/bookmark_extension_api_constants.h"
-#include "chrome/browser/bookmarks/bookmark_model.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/sync/profile_sync_service.h"
-#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
-#include "chrome/common/chrome_notification_types.h"
-#include "chrome/common/pref_names.h"
-
-// TODO(csilv):
-// Much of this implementation is based on the classes defined in
-// extension_bookmarks_module.cc. Longer term we should consider migrating
-// NTP into an embedded extension which would allow us to leverage the same
-// bookmark APIs as the bookmark manager.
-
-namespace keys = bookmark_extension_api_constants;
-
-BookmarksHandler::BookmarksHandler() : model_(NULL),
- dom_ready_(false),
- from_current_page_(false) {
-}
-
-BookmarksHandler::~BookmarksHandler() {
- if (model_)
- model_->RemoveObserver(this);
-}
-
-WebUIMessageHandler* BookmarksHandler::Attach(WebUI* web_ui) {
- WebUIMessageHandler::Attach(web_ui);
- model_ = Profile::FromWebUI(web_ui)->GetBookmarkModel();
- if (model_)
- model_->AddObserver(this);
- return this;
-}
-
-void BookmarksHandler::RegisterMessages() {
- web_ui_->RegisterMessageCallback("createBookmark",
- base::Bind(&BookmarksHandler::HandleCreateBookmark,
- base::Unretained(this)));
- web_ui_->RegisterMessageCallback("getBookmarksData",
- base::Bind(&BookmarksHandler::HandleGetBookmarksData,
- base::Unretained(this)));
- web_ui_->RegisterMessageCallback("moveBookmark",
- base::Bind(&BookmarksHandler::HandleMoveBookmark,
- base::Unretained(this)));
- web_ui_->RegisterMessageCallback("removeBookmark",
- base::Bind(&BookmarksHandler::HandleRemoveBookmark,
- base::Unretained(this)));
-}
-
-void BookmarksHandler::Loaded(BookmarkModel* model, bool ids_reassigned) {
- if (dom_ready_)
- HandleGetBookmarksData(NULL);
-}
-
-void BookmarksHandler::BookmarkModelBeingDeleted(BookmarkModel* model) {
- // If this occurs it probably means that this tab will close shortly.
- // Discard our reference to the model so that we won't use it again.
- model_ = NULL;
-}
-
-void BookmarksHandler::BookmarkNodeMoved(BookmarkModel* model,
- const BookmarkNode* old_parent,
- int old_index,
- const BookmarkNode* new_parent,
- int new_index) {
- if (!dom_ready_) return;
- const BookmarkNode* node = new_parent->GetChild(new_index);
- base::StringValue id(base::Int64ToString(node->id()));
- base::DictionaryValue move_info;
- move_info.SetString(keys::kParentIdKey,
- base::Int64ToString(new_parent->id()));
- move_info.SetInteger(keys::kIndexKey, new_index);
- move_info.SetString(keys::kOldParentIdKey,
- base::Int64ToString(old_parent->id()));
- move_info.SetInteger(keys::kOldIndexKey, old_index);
- base::FundamentalValue from_page(from_current_page_);
-
- web_ui_->CallJavascriptFunction("ntp4.bookmarkNodeMoved", id, move_info,
- from_page);
-}
-
-void BookmarksHandler::BookmarkNodeAdded(BookmarkModel* model,
- const BookmarkNode* parent,
- int index) {
- if (!dom_ready_) return;
- const BookmarkNode* node = parent->GetChild(index);
- base::StringValue id(base::Int64ToString(node->id()));
- scoped_ptr<base::DictionaryValue> node_info(GetNodeDictionary(node));
- base::FundamentalValue from_page(from_current_page_);
-
- web_ui_->CallJavascriptFunction("ntp4.bookmarkNodeAdded", id, *node_info,
- from_page);
-}
-
-void BookmarksHandler::BookmarkNodeRemoved(BookmarkModel* model,
- const BookmarkNode* parent,
- int index,
- const BookmarkNode* node) {
- if (!dom_ready_) return;
-
- base::StringValue id(base::Int64ToString(node->id()));
- base::DictionaryValue remove_info;
- remove_info.SetString(keys::kParentIdKey, base::Int64ToString(parent->id()));
- remove_info.SetInteger(keys::kIndexKey, index);
- base::FundamentalValue from_page(from_current_page_);
-
- web_ui_->CallJavascriptFunction("ntp4.bookmarkNodeRemoved", id, remove_info,
- from_page);
-}
-
-void BookmarksHandler::BookmarkNodeChanged(BookmarkModel* model,
- const BookmarkNode* node) {
- if (!dom_ready_) return;
- base::StringValue id(base::Int64ToString(node->id()));
- base::DictionaryValue change_info;
- change_info.SetString(keys::kTitleKey, node->GetTitle());
- if (node->is_url())
- change_info.SetString(keys::kUrlKey, node->url().spec());
- base::FundamentalValue from_page(from_current_page_);
-
- web_ui_->CallJavascriptFunction("ntp4.bookmarkNodeChanged", id, change_info,
- from_page);
-}
-
-void BookmarksHandler::BookmarkNodeFaviconChanged(BookmarkModel* model,
- const BookmarkNode* node) {
- // Favicons are handled by through use of the chrome://favicon protocol, so
- // there's nothing for us to do here (but we need to provide an
- // implementation).
-}
-
-void BookmarksHandler::BookmarkNodeChildrenReordered(BookmarkModel* model,
- const BookmarkNode* node) {
- if (!dom_ready_) return;
- base::StringValue id(base::Int64ToString(node->id()));
- base::ListValue* children = new base::ListValue;
- for (int i = 0; i < node->child_count(); ++i) {
- const BookmarkNode* child = node->GetChild(i);
- Value* child_id = new StringValue(base::Int64ToString(child->id()));
- children->Append(child_id);
- }
- base::DictionaryValue reorder_info;
- reorder_info.Set(keys::kChildIdsKey, children);
- base::FundamentalValue from_page(from_current_page_);
-
- web_ui_->CallJavascriptFunction("ntp4.bookmarkNodeChildrenReordered", id,
- reorder_info, from_page);
-}
-
-void BookmarksHandler::BookmarkImportBeginning(BookmarkModel* model) {
- if (dom_ready_)
- web_ui_->CallJavascriptFunction("ntp4.bookmarkImportBegan");
-}
-
-void BookmarksHandler::BookmarkImportEnding(BookmarkModel* model) {
- if (dom_ready_)
- web_ui_->CallJavascriptFunction("ntp4.bookmarkImportEnded");
-}
-
-void BookmarksHandler::HandleCreateBookmark(const ListValue* args) {
- if (!model_) return;
-
- // This is the only required argument - a stringified int64 parent ID.
- std::string parent_id_string;
- CHECK(args->GetString(0, &parent_id_string));
- int64 parent_id;
- CHECK(base::StringToInt64(parent_id_string, &parent_id));
-
- const BookmarkNode* parent = model_->GetNodeByID(parent_id);
- if (!parent) return;
-
- double index;
- if (!args->GetDouble(1, &index) ||
- (index > parent->child_count() || index < 0)) {
- index = parent->child_count();
- }
-
- // If they didn't pass the argument, just use a blank string.
- string16 title;
- if (!args->GetString(2, &title))
- title = string16();
-
- // We'll be creating either a bookmark or a folder, so set this for both.
- AutoReset<bool> from_page(&from_current_page_, true);
-
- // According to the bookmarks API, "If url is NULL or missing, it will be a
- // folder.". Let's just follow the same behavior.
- std::string url_string;
- if (args->GetString(3, &url_string)) {
- GURL url(url_string);
- if (!url.is_empty() && url.is_valid()) {
- // Only valid case for a bookmark as opposed to folder.
- model_->AddURL(parent, static_cast<int>(index), title, url);
- return;
- }
- }
-
- // We didn't have all the valid parts for a bookmark, just make a folder.
- model_->AddFolder(parent, static_cast<int>(index), title);
-}
-
-void BookmarksHandler::HandleGetBookmarksData(const base::ListValue* args) {
- dom_ready_ = true;
-
- // At startup, Bookmarks may not be fully loaded. If this is the case,
- // we'll wait for the notification to arrive.
- Profile* profile = Profile::FromWebUI(web_ui_);
- BookmarkModel* model = profile->GetBookmarkModel();
- if (!model->IsLoaded()) return;
-
- int64 id;
- std::string id_string;
- PrefService* prefs = profile->GetPrefs();
- if (args && args->GetString(0, &id_string) &&
- base::StringToInt64(id_string, &id)) {
- // A folder ID was requested, so persist this value.
- prefs->SetInt64(prefs::kNTPShownBookmarksFolder, id);
- } else {
- // No folder ID was requested, so get the default (persisted) value.
- id = prefs->GetInt64(prefs::kNTPShownBookmarksFolder);
- }
-
- const BookmarkNode* node = model->GetNodeByID(id);
- if (!node)
- node = model->root_node();
-
- // We wish to merge the root node with the bookmarks bar node.
- if (model->is_root_node(node))
- node = model->bookmark_bar_node();
-
- base::ListValue* items = new base::ListValue;
- for (int i = 0; i < node->child_count(); ++i) {
- const BookmarkNode* child = node->GetChild(i);
- AddNode(child, items);
- }
- if (node == model->bookmark_bar_node() && model->other_node()->child_count())
- AddNode(model->other_node(), items);
-
- base::ListValue* navigation_items = new base::ListValue;
- while (node) {
- if (node != model->bookmark_bar_node())
- AddNode(node, navigation_items);
- node = node->parent();
- }
-
- base::DictionaryValue bookmarksData;
- bookmarksData.Set("items", items);
- bookmarksData.Set("navigationItems", navigation_items);
- web_ui_->CallJavascriptFunction("ntp4.setBookmarksData", bookmarksData);
-}
-
-void BookmarksHandler::HandleRemoveBookmark(const ListValue* args) {
- if (!model_) return;
-
- std::string id_string;
- CHECK(args->GetString(0, &id_string));
- int64 id;
- CHECK(base::StringToInt64(id_string, &id));
-
- const BookmarkNode* node = model_->GetNodeByID(id);
- if (!node) return;
-
- AutoReset<bool> from_page(&from_current_page_, true);
- model_->Remove(node->parent(), node->parent()->GetIndexOf(node));
-}
-
-void BookmarksHandler::HandleMoveBookmark(const ListValue* args) {
- if (!model_) return;
-
- std::string id_string;
- CHECK(args->GetString(0, &id_string));
- int64 id;
- CHECK(base::StringToInt64(id_string, &id));
-
- std::string parent_id_string;
- CHECK(args->GetString(1, &parent_id_string));
- int64 parent_id;
- CHECK(base::StringToInt64(parent_id_string, &parent_id));
-
- double index;
- args->GetDouble(2, &index);
-
- const BookmarkNode* parent = model_->GetNodeByID(parent_id);
- if (!parent) return;
-
- const BookmarkNode* node = model_->GetNodeByID(id);
- if (!node) return;
-
- AutoReset<bool> from_page(&from_current_page_, true);
- model_->Move(node, parent, static_cast<int>(index));
-}
-
-base::DictionaryValue* BookmarksHandler::GetNodeDictionary(
- const BookmarkNode* node) {
- base::DictionaryValue* dict = new base::DictionaryValue();
- dict->SetString(keys::kIdKey, base::Int64ToString(node->id()));
-
- const BookmarkNode* parent = node->parent();
- if (parent) {
- dict->SetString(keys::kParentIdKey, base::Int64ToString(parent->id()));
- dict->SetInteger(keys::kIndexKey, parent->GetIndexOf(node));
- }
-
- NewTabUI::SetURLTitleAndDirection(dict, node->GetTitle(), node->url());
-
- if (!node->is_folder())
- dict->SetString(keys::kUrlKey, node->url().spec());
-
- return dict;
-}
-
-void BookmarksHandler::AddNode(const BookmarkNode* node,
- base::ListValue* list) {
- if (node->IsVisible()) {
- base::DictionaryValue* dict = GetNodeDictionary(node);
- list->Append(dict);
- }
-}
-
-// static
-void BookmarksHandler::RegisterUserPrefs(PrefService* prefs) {
- // Default folder is the root node.
- // TODO(csilv): Should we sync this preference?
- prefs->RegisterInt64Pref(prefs::kNTPShownBookmarksFolder, 0,
- PrefService::UNSYNCABLE_PREF);
-}
diff --git a/chrome/browser/ui/webui/ntp/bookmarks_handler.h b/chrome/browser/ui/webui/ntp/bookmarks_handler.h
deleted file mode 100644
index 7479cb5..0000000
--- a/chrome/browser/ui/webui/ntp/bookmarks_handler.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_NTP_BOOKMARKS_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_NTP_BOOKMARKS_HANDLER_H_
-#pragma once
-
-#include "chrome/browser/bookmarks/bookmark_model_observer.h"
-#include "content/browser/webui/web_ui.h"
-
-class PrefService;
-
-// The handler for Javascript messages related to the "bookmarks" view.
-class BookmarksHandler : public WebUIMessageHandler,
- public BookmarkModelObserver {
- public:
- explicit BookmarksHandler();
- virtual ~BookmarksHandler();
-
- // WebUIMessageHandler implementation.
- virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE;
- virtual void RegisterMessages() OVERRIDE;
-
- // BookmarkModelObserver implementation.
- virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE;
- virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE;
- virtual void BookmarkNodeMoved(BookmarkModel* model,
- const BookmarkNode* old_parent,
- int old_index,
- const BookmarkNode* new_parent,
- int new_index) OVERRIDE;
- virtual void BookmarkNodeAdded(BookmarkModel* model,
- const BookmarkNode* parent,
- int index) OVERRIDE;
- virtual void BookmarkNodeRemoved(BookmarkModel* model,
- const BookmarkNode* parent,
- int old_index,
- const BookmarkNode* node) OVERRIDE;
- virtual void BookmarkNodeChanged(BookmarkModel* model,
- const BookmarkNode* node) OVERRIDE;
- virtual void BookmarkNodeFaviconChanged(BookmarkModel* model,
- const BookmarkNode* node) OVERRIDE;
- virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
- const BookmarkNode* node) OVERRIDE;
- virtual void BookmarkImportBeginning(BookmarkModel* model) OVERRIDE;
- virtual void BookmarkImportEnding(BookmarkModel* model) OVERRIDE;
-
- // Callback for the "createBookmark" message. This handler could be sent as
- // many as four arguments. The first argument is a stringified int64 with the
- // parent ID of the node we're going to create the bookmark in. The additional
- // 3 optional parameters start with an integer index denoting where the
- // bookmark is relative to its siblings, a string for the title (which is
- // otherwise blank), and a string of the url (without this we interpret as a
- // folder).
- void HandleCreateBookmark(const base::ListValue* args);
-
- // Callback for the "getBoomarksData" message.
- void HandleGetBookmarksData(const base::ListValue* args);
-
- // Callback for the "moveBookmark" message. The arguments passed to this
- // handler are the bookmark ID (as a string to be converted to int64), parent
- // ID (as a string to be converted to int64), and index to be inserted into
- // that level.
- void HandleMoveBookmark(const base::ListValue* args);
-
- // Callback for the "removeBookmark" message. The argument passed to this
- // handler is a stringified int64 bookmark ID of the node we want to delete
- // (can be either a bookmark or a folder).
- void HandleRemoveBookmark(const base::ListValue* args);
-
- // Convert a BookMark node into a DictionaryValue representation.
- base::DictionaryValue* GetNodeDictionary(const BookmarkNode* node);
-
- // Add a dictionary representation of |node| to the ListValue.
- void AddNode(const BookmarkNode* node, base::ListValue* list);
-
- // Register NTP preferences.
- static void RegisterUserPrefs(PrefService* prefs);
-
- private:
- // A weak reference to the current bookmarks model.
- BookmarkModel* model_; // weak
-
- // True if the DOM layer is ready.
- bool dom_ready_;
-
- // True when we are handling a chrome.send call.
- bool from_current_page_;
-
- DISALLOW_COPY_AND_ASSIGN(BookmarksHandler);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_NTP_BOOKMARKS_HANDLER_H_
diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui.cc b/chrome/browser/ui/webui/ntp/new_tab_ui.cc
index 9b34883..5974c53 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_ui.cc
+++ b/chrome/browser/ui/webui/ntp/new_tab_ui.cc
@@ -25,7 +25,6 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/webui/metrics_handler.h"
#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
-#include "chrome/browser/ui/webui/ntp/bookmarks_handler.h"
#include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h"
#include "chrome/browser/ui/webui/ntp/foreign_session_handler.h"
#include "chrome/browser/ui/webui/ntp/most_visited_handler.h"
@@ -97,7 +96,6 @@ NewTabUI::NewTabUI(TabContents* contents)
AddMessageHandler((new AppLauncherHandler(service))->Attach(this));
AddMessageHandler((new NewTabPageHandler())->Attach(this));
- AddMessageHandler((new BookmarksHandler())->Attach(this));
AddMessageHandler((new FaviconWebUIHandler())->Attach(this));
}
@@ -171,9 +169,7 @@ bool NewTabUI::CanShowBookmarkBar() const {
bool disabled_by_policy =
prefs->IsManagedPreference(prefs::kShowBookmarkBar) &&
!prefs->GetBoolean(prefs::kShowBookmarkBar);
- return browser_defaults::bookmarks_enabled &&
- !disabled_by_policy &&
- !NTP4BookmarkFeaturesEnabled();
+ return browser_defaults::bookmarks_enabled && !disabled_by_policy;
}
void NewTabUI::Observe(int type,
@@ -210,7 +206,6 @@ void NewTabUI::RegisterUserPrefs(PrefService* prefs) {
NewTabPageHandler::RegisterUserPrefs(prefs);
AppLauncherHandler::RegisterUserPrefs(prefs);
MostVisitedHandler::RegisterUserPrefs(prefs);
- BookmarksHandler::RegisterUserPrefs(prefs);
}
// static
@@ -249,12 +244,6 @@ void NewTabUI::SetURLTitleAndDirection(DictionaryValue* dictionary,
dictionary->SetString("direction", direction);
}
-// static
-bool NewTabUI::NTP4BookmarkFeaturesEnabled() {
- CommandLine* cl = CommandLine::ForCurrentProcess();
- return cl->HasSwitch(switches::kEnableNTPBookmarkFeatures);
-}
-
///////////////////////////////////////////////////////////////////////////////
// NewTabHTMLSource
diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui.h b/chrome/browser/ui/webui/ntp/new_tab_ui.h
index 00281a3..43f2e1a 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_ui.h
+++ b/chrome/browser/ui/webui/ntp/new_tab_ui.h
@@ -44,9 +44,6 @@ class NewTabUI : public ChromeWebUI,
// The current preference version.
static int current_pref_version() { return current_pref_version_; }
- // Returns whether NTP4 bookmark features are enabled.
- static bool NTP4BookmarkFeaturesEnabled();
-
class NewTabHTMLSource : public ChromeURLDataManager::DataSource {
public:
explicit NewTabHTMLSource(Profile* profile);
diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
index 182f2b3..bf8a1d2 100644
--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -381,10 +381,6 @@ void NTPResourceCache::CreateNewTabHTML() {
UserMetrics::RecordAction(UserMetricsAction("NTPPromoShown"));
}
- // Enable or disable bookmark features based on an about flag.
- localized_strings.SetString("bookmark_features",
- NewTabUI::NTP4BookmarkFeaturesEnabled() ? "true" : "false");
-
// Load the new tab page appropriate for this build
std::string full_html;
base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance().
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 3732558..54219b3 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3759,8 +3759,6 @@
'browser/ui/webui/net_internals_ui.h',
'browser/ui/webui/ntp/app_launcher_handler.cc',
'browser/ui/webui/ntp/app_launcher_handler.h',
- 'browser/ui/webui/ntp/bookmarks_handler.cc',
- 'browser/ui/webui/ntp/bookmarks_handler.h',
'browser/ui/webui/ntp/favicon_webui_handler.cc',
'browser/ui/webui/ntp/favicon_webui_handler.h',
'browser/ui/webui/ntp/foreign_session_handler.cc',
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 1991f88..c50c5d7 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -516,9 +516,6 @@ const char kEnableNaCl[] = "enable-nacl";
// Enables debugging via RSP over a socket.
const char kEnableNaClDebug[] = "enable-nacl-debug";
-// Enabled integrated bookmark features in the New Tab pane.
-const char kEnableNTPBookmarkFeatures[] = "enable-ntp-bookmark-features";
-
// Enables advanced app capabilities.
const char kEnablePlatformApps[] = "enable-platform-apps";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 11f4a19a..2e9a2d7 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -148,7 +148,6 @@ extern const char kEnableMacCookies[];
extern const char kEnableMemoryInfo[];
extern const char kEnableNaCl[];
extern const char kEnableNaClDebug[];
-extern const char kEnableNTPBookmarkFeatures[];
extern const char kEnablePlatformApps[];
extern const char kEnablePreconnect[];
extern const char kEnableProfiling[];