diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-28 02:12:07 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-28 02:12:07 +0000 |
commit | ffd87ddce66fe585c49efeca0602fece11339ed0 (patch) | |
tree | 6ac044506d104a3f38cf64266eafcbe6c0eee1b3 /chrome | |
parent | 13ac7b415d9c03f7861b634695af5c4887574013 (diff) | |
download | chromium_src-ffd87ddce66fe585c49efeca0602fece11339ed0.zip chromium_src-ffd87ddce66fe585c49efeca0602fece11339ed0.tar.gz chromium_src-ffd87ddce66fe585c49efeca0602fece11339ed0.tar.bz2 |
Windows/Views: delete native bookmark manager code.
Context menu code still needs cleanup/refactoring.
String resources still need to be deleted.
BUG=38908
TEST=everything still works
Review URL: http://codereview.chromium.org/1730015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45776 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
26 files changed, 10 insertions, 3689 deletions
diff --git a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc index 02df337..4f9c140 100644 --- a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc +++ b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc @@ -8,7 +8,6 @@ #include "base/compiler_specific.h" #include "chrome/browser/bookmarks/bookmark_editor.h" #include "chrome/browser/bookmarks/bookmark_folder_editor_controller.h" -#include "chrome/browser/bookmarks/bookmark_manager.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/browser.h" @@ -35,29 +34,6 @@ bool NodeHasURLs(const BookmarkNode* node) { return false; } -// SelectOnCreationHandler ---------------------------------------------------- - -// Used when adding a new bookmark. If a new bookmark is created it is selected -// in the bookmark manager. -class SelectOnCreationHandler : public BookmarkEditor::Handler { - public: - explicit SelectOnCreationHandler(Profile* profile) : profile_(profile) { - } - - virtual void NodeCreated(const BookmarkNode* new_node) { -// TODO(viettrungluu): I don't know if this is really needed, but it'll be -// deleted soon. -#if defined(OS_WIN) - BookmarkManager::SelectInTree(profile_, new_node); -#endif - } - - private: - Profile* profile_; - - DISALLOW_COPY_AND_ASSIGN(SelectOnCreationHandler); -}; - } // namespace BookmarkContextMenuController::BookmarkContextMenuController( @@ -112,15 +88,6 @@ void BookmarkContextMenuController::BuildMenu() { AddItem(IDS_BOOKMARK_BAR_EDIT); } -// TODO(viettrungluu): I don't know if this is really needed, but it'll be -// deleted soon. -#if defined(OS_WIN) - if (configuration_ == BOOKMARK_MANAGER_TABLE_OTHER || - configuration_ == BOOKMARK_MANAGER_ORGANIZE_MENU_OTHER) { - AddItem(IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER); - } -#endif - AddSeparator(); AddItem(IDS_CUT); AddItem(IDS_COPY); @@ -236,21 +203,14 @@ void BookmarkContextMenuController::ExecuteCommand(int id) { UserMetricsAction("BookmarkBar_ContextMenu_Add"), profile_); - BookmarkEditor::Configuration editor_config; - BookmarkEditor::Handler* handler = NULL; - if (configuration_ == BOOKMARK_BAR) { - editor_config = BookmarkEditor::SHOW_TREE; - } else { - editor_config = BookmarkEditor::NO_TREE; - // This is owned by the BookmarkEditorView. - handler = new SelectOnCreationHandler(profile_); - } + BookmarkEditor::Configuration editor_config = + (configuration_ == BOOKMARK_BAR) ? BookmarkEditor::SHOW_TREE : + BookmarkEditor::NO_TREE; // TODO: this should honor the index from GetParentForNewNodes. BookmarkEditor::Show( parent_window_, profile_, bookmark_utils::GetParentForNewNodes(parent_, selection_, NULL), - BookmarkEditor::EditDetails(), editor_config, - handler); + BookmarkEditor::EditDetails(), editor_config, NULL); break; } @@ -273,23 +233,6 @@ void BookmarkContextMenuController::ExecuteCommand(int id) { bookmark_utils::ToggleWhenVisible(profile_); break; -// TODO(viettrungluu): I don't know if this is really needed, but it'll be -// deleted soon. -#if defined(OS_WIN) - case IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER: - UserMetrics::RecordAction( - UserMetricsAction("BookmarkBar_ContextMenu_ShowInFolder"), - profile_); - - if (selection_.size() != 1) { - NOTREACHED(); - break; - } - - BookmarkManager::SelectInTree(profile_, selection_[0]); - break; -#endif - case IDS_BOOKMARK_MANAGER: UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager"), profile_); @@ -362,15 +305,6 @@ bool BookmarkContextMenuController::IsCommandIdEnabled(int command_id) const { case IDS_BOOKMARK_BAR_REMOVE: return !selection_.empty() && !is_root_node; -// TODO(viettrungluu): I don't know if this is really needed, but it'll be -// deleted soon. -#if defined(OS_WIN) - case IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER: - return (configuration_ == BOOKMARK_MANAGER_TABLE_OTHER || - configuration_ == BOOKMARK_MANAGER_ORGANIZE_MENU_OTHER) && - selection_.size() == 1; -#endif - case IDS_BOOKMARK_MANAGER_SORT: return parent_ && parent_ != model_->root_node(); diff --git a/chrome/browser/bookmarks/bookmark_folder_editor_controller.cc b/chrome/browser/bookmarks/bookmark_folder_editor_controller.cc index 0d04891..4966c7c 100644 --- a/chrome/browser/bookmarks/bookmark_folder_editor_controller.cc +++ b/chrome/browser/bookmarks/bookmark_folder_editor_controller.cc @@ -5,7 +5,6 @@ #include "chrome/browser/bookmarks/bookmark_folder_editor_controller.h" #include "app/l10n_util.h" -#include "chrome/browser/bookmarks/bookmark_manager.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/profile.h" #include "grit/generated_resources.h" @@ -62,20 +61,10 @@ bool BookmarkFolderEditorController::IsValid(const std::wstring& text) { } void BookmarkFolderEditorController::InputAccepted(const std::wstring& text) { - if (IsNew()) { -#if defined(OS_WIN) - // TODO(viettrungluu): Implement this the following for the tabbed bookmark - // manager? - ALLOW_UNUSED const BookmarkNode* node = - model_->AddGroup(node_, index_, text); - if ((details_ & SHOW_IN_MANAGER) != 0) - BookmarkManager::SelectInTree(profile_, node); -#else + if (IsNew()) model_->AddGroup(node_, index_, text); -#endif - } else { + else model_->SetTitle(node_, text); - } } void BookmarkFolderEditorController::InputCanceled() { diff --git a/chrome/browser/bookmarks/bookmark_folder_tree_model.cc b/chrome/browser/bookmarks/bookmark_folder_tree_model.cc deleted file mode 100644 index e8b3827..0000000 --- a/chrome/browser/bookmarks/bookmark_folder_tree_model.cc +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) 2006-2008 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/bookmarks/bookmark_folder_tree_model.h" - -#include "app/l10n_util.h" -#include "app/resource_bundle.h" -#include "chrome/browser/bookmarks/bookmark_model.h" -#include "grit/generated_resources.h" -#include "grit/theme_resources.h" -#include "third_party/skia/include/core/SkBitmap.h" - -BookmarkFolderTreeModel::BookmarkFolderTreeModel(BookmarkModel* model) - : TreeNodeModel<FolderNode>(new FolderNode(NULL)), - model_(model), - recently_bookmarked_node_(new FolderNode(NULL)), - search_node_(new FolderNode(NULL)) { - recently_bookmarked_node_->SetTitle( - l10n_util::GetString(IDS_BOOKMARK_TREE_RECENTLY_BOOKMARKED_NODE_TITLE)); - search_node_->SetTitle( - l10n_util::GetString(IDS_BOOKMARK_TREE_SEARCH_NODE_TITLE)); - if (model_->IsLoaded()) - AddRootChildren(); - model_->AddObserver(this); -} - -BookmarkFolderTreeModel::~BookmarkFolderTreeModel() { - if (model_) - model_->RemoveObserver(this); -} - -BookmarkFolderTreeModel::NodeType BookmarkFolderTreeModel::GetNodeType( - TreeModelNode* node) { - if (node == recently_bookmarked_node_) - return RECENTLY_BOOKMARKED; - if (node == search_node_) - return SEARCH; - if (node == GetRoot()) - return NONE; - return BOOKMARK; -} - -FolderNode* BookmarkFolderTreeModel::GetFolderNodeForBookmarkNode( - const BookmarkNode* node) { - if (!node->is_folder()) - return NULL; - - return GetFolderNodeForBookmarkNode(AsNode(GetRoot()), node); -} - -const BookmarkNode* BookmarkFolderTreeModel::TreeNodeAsBookmarkNode( - TreeModelNode* node) { - if (GetNodeType(node) != BOOKMARK) - return NULL; - return AsNode(node)->value; -} - -void BookmarkFolderTreeModel::Loaded(BookmarkModel* model) { - AddRootChildren(); -} - -void BookmarkFolderTreeModel::BookmarkModelBeingDeleted(BookmarkModel* model) { - DCHECK(model_); - model_->RemoveObserver(this); - model_ = NULL; -} - -void BookmarkFolderTreeModel::BookmarkNodeMoved(BookmarkModel* model, - const BookmarkNode* old_parent, - int old_index, - const BookmarkNode* new_parent, - int new_index) { - const BookmarkNode* moved_node = new_parent->GetChild(new_index); - if (!moved_node->is_folder()) - return; // We're only showing folders, so we can ignore this. - - FolderNode* moved_folder_node = GetFolderNodeForBookmarkNode(moved_node); - DCHECK(moved_folder_node); - int old_folder_index = - moved_folder_node->GetParent()->IndexOfChild(moved_folder_node); - Remove(moved_folder_node->GetParent(), old_folder_index); - int new_folder_index = CalculateIndexForChild(moved_node); - Add(GetFolderNodeForBookmarkNode(new_parent), new_folder_index, - moved_folder_node); -} - -void BookmarkFolderTreeModel::BookmarkNodeAdded(BookmarkModel* model, - const BookmarkNode* parent, - int index) { - const BookmarkNode* new_node = parent->GetChild(index); - if (!new_node->is_folder()) - return; // We're only showing folders, so we can ignore this. - - int folder_index = CalculateIndexForChild(new_node); - Add(GetFolderNodeForBookmarkNode(parent), folder_index, - CreateFolderNode(new_node)); -} - -void BookmarkFolderTreeModel::BookmarkNodeRemoved(BookmarkModel* model, - const BookmarkNode* parent, - int index, - const BookmarkNode* node) { - if (!node->is_folder()) - return; // We're only showing folders. - - FolderNode* folder_node = GetFolderNodeForBookmarkNode(parent); - DCHECK(folder_node); - for (int i = 0; i < folder_node->GetChildCount(); ++i) { - if (folder_node->GetChild(i)->value == node) { - scoped_ptr<FolderNode> removed_node(Remove(folder_node, i)); - return; - } - } - - // If we get here it means a folder was removed that we didn't know about, - // which shouldn't happen. - NOTREACHED(); -} - -void BookmarkFolderTreeModel::BookmarkNodeChanged(BookmarkModel* model, - const BookmarkNode* node) { - if (!node->is_folder()) - return; - - FolderNode* folder_node = GetFolderNodeForBookmarkNode(node); - if (!folder_node) - return; - - folder_node->SetTitle(node->GetTitle()); - FOR_EACH_OBSERVER(TreeModelObserver, - observer_list(), - TreeNodeChanged(this, folder_node)); -} - -void BookmarkFolderTreeModel::BookmarkNodeChildrenReordered( - BookmarkModel* model, - const BookmarkNode* node) { - FolderNode* folder_node = GetFolderNodeForBookmarkNode(node); - DCHECK(folder_node); - if (folder_node->GetChildCount() <= 1) - return; // Order won't have changed if 1 or fewer nodes. - - // Build a map between folder node and bookmark node. - std::map<const BookmarkNode*, FolderNode*> bn_to_folder; - for (int i = 0; i < folder_node->GetChildCount(); ++i) - bn_to_folder[folder_node->GetChild(i)->value] = folder_node->GetChild(i); - - // Remove all the folder nodes. - int original_count = folder_node->GetChildCount(); - folder_node->RemoveAll(); - - // And add them back in the new order. - for (int i = 0; i < node->GetChildCount(); ++i) { - const BookmarkNode* child = node->GetChild(i); - if (child->is_folder()) { - DCHECK(bn_to_folder.find(child) != bn_to_folder.end()); - folder_node->Add(folder_node->GetChildCount(), bn_to_folder[child]); - } - } - // The new count better match the original count, otherwise we're leaking and - // treeview is likely to get way out of sync. - DCHECK(original_count == folder_node->GetChildCount()); - - // Finally, notify observers. - FOR_EACH_OBSERVER(TreeModelObserver, - observer_list(), - TreeNodeChildrenReordered(this, folder_node)); -} - -void BookmarkFolderTreeModel::GetIcons(std::vector<SkBitmap>* icons) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - icons->push_back(*rb.GetBitmapNamed(IDR_BOOKMARK_MANAGER_RECENT_ICON)); - icons->push_back(*rb.GetBitmapNamed(IDR_BOOKMARK_MANAGER_SEARCH_ICON)); -} - -int BookmarkFolderTreeModel::GetIconIndex(TreeModelNode* node) { - if (node == recently_bookmarked_node_) - return 0; - if (node == search_node_) - return 1; - - // Return -1 to use the default. - return -1; -} - -void BookmarkFolderTreeModel::AddRootChildren() { - Add(AsNode(GetRoot()), 0, CreateFolderNode(model_->GetBookmarkBarNode())); - Add(AsNode(GetRoot()), 1, CreateFolderNode(model_->other_node())); - Add(AsNode(GetRoot()), 2, recently_bookmarked_node_); - Add(AsNode(GetRoot()), 3, search_node_); -} - -FolderNode* BookmarkFolderTreeModel::GetFolderNodeForBookmarkNode( - FolderNode* folder_node, - const BookmarkNode* node) { - DCHECK(node->is_folder()); - if (folder_node->value == node) - return folder_node; - for (int i = 0; i < folder_node->GetChildCount(); ++i) { - FolderNode* result = - GetFolderNodeForBookmarkNode(folder_node->GetChild(i), node); - if (result) - return result; - } - return NULL; -} - -FolderNode* BookmarkFolderTreeModel::CreateFolderNode( - const BookmarkNode* node) { - DCHECK(node->is_folder()); - FolderNode* folder_node = new FolderNode(node); - folder_node->SetTitle(node->GetTitle()); - - // And clone the children folders. - for (int i = 0; i < node->GetChildCount(); ++i) { - const BookmarkNode* child = node->GetChild(i); - if (child->is_folder()) - folder_node->Add(folder_node->GetChildCount(), CreateFolderNode(child)); - } - return folder_node; -} - -int BookmarkFolderTreeModel::CalculateIndexForChild(const BookmarkNode* node) { - const BookmarkNode* parent = node->GetParent(); - DCHECK(parent); - for (int i = 0, folder_count = 0; i < parent->GetChildCount(); ++i) { - const BookmarkNode* child = parent->GetChild(i); - if (child == node) - return folder_count; - if (child->is_folder()) - folder_count++; - } - NOTREACHED(); - return 0; -} diff --git a/chrome/browser/bookmarks/bookmark_folder_tree_model.h b/chrome/browser/bookmarks/bookmark_folder_tree_model.h deleted file mode 100644 index 9d7480c..0000000 --- a/chrome/browser/bookmarks/bookmark_folder_tree_model.h +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2006-2008 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_BOOKMARKS_BOOKMARK_FOLDER_TREE_MODEL_H_ -#define CHROME_BROWSER_BOOKMARKS_BOOKMARK_FOLDER_TREE_MODEL_H_ - -#include <vector> - -#include "app/tree_node_model.h" -#include "chrome/browser/bookmarks/bookmark_model_observer.h" - -// The type of nodes created by BookmarkFolderTreeModel. -typedef TreeNodeWithValue<const BookmarkNode*> FolderNode; - -// TreeModel implementation that shows the folders from the BookmarkModel. -// The root node contains the following nodes: -// bookmark bar, other folders, recently bookmarked and search. -class BookmarkFolderTreeModel : public TreeNodeModel<FolderNode>, - public BookmarkModelObserver { - public: - // Type of the node. - enum NodeType { - // Represents an entry from the BookmarkModel. - BOOKMARK, - RECENTLY_BOOKMARKED, - SEARCH, - NONE // Used for no selection. - }; - - explicit BookmarkFolderTreeModel(BookmarkModel* model); - ~BookmarkFolderTreeModel(); - - // The tree is not editable. - virtual void SetTitle(TreeModelNode* node, const std::wstring& title) { - NOTREACHED(); - } - - // Returns the type of the specified node. - NodeType GetNodeType(TreeModelNode* node); - - // Returns the FolderNode for the specified BookmarkNode. - FolderNode* GetFolderNodeForBookmarkNode(const BookmarkNode* node); - - // Converts the tree node into a BookmarkNode. Returns NULL if |node| is NULL - // or not of NodeType::BOOKMARK. - const BookmarkNode* TreeNodeAsBookmarkNode(TreeModelNode* node); - - // Returns the search node. - FolderNode* search_node() const { return search_node_; } - - // BookmarkModelObserver implementation. - virtual void Loaded(BookmarkModel* model); - virtual void BookmarkModelBeingDeleted(BookmarkModel* model); - virtual void BookmarkNodeMoved(BookmarkModel* model, - const BookmarkNode* old_parent, - int old_index, - const BookmarkNode* new_parent, - int new_index); - virtual void BookmarkNodeAdded(BookmarkModel* model, - const BookmarkNode* parent, - int index); - virtual void BookmarkNodeRemoved(BookmarkModel* model, - const BookmarkNode* parent, - int index, - const BookmarkNode* node); - virtual void BookmarkNodeChanged(BookmarkModel* model, - const BookmarkNode* node); - virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, - const BookmarkNode* node); - // Folders don't have favicons, so we ignore this. - virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model, - const BookmarkNode* node) {} - - // The following are overriden to return custom icons for the recently - // bookmarked and search nodes. - virtual void GetIcons(std::vector<SkBitmap>* icons); - virtual int GetIconIndex(TreeModelNode* node); - - private: - // Invoked from the constructor to create the children of the root node. - void AddRootChildren(); - - // Implementation of GetFolderNodeForBookmarkNode. If the |folder_node| - // represents |node|, |folder_node| is returned, otherwise this recurses - // through the children. - FolderNode* GetFolderNodeForBookmarkNode(FolderNode* folder_node, - const BookmarkNode* node); - - // Creates a new folder node for |node| and all its children. - FolderNode* CreateFolderNode(const BookmarkNode* node); - - // Returns the number of folders that precede |node| in |node|s parent. - // The returned value is the index of the folder node representing |node| - // in its parent. - // This is used when new bookmarks are created to determine where the - // corresponding folder node should be created. - int CalculateIndexForChild(const BookmarkNode* node); - - // The model we're getting data from. Owned by the Profile. - BookmarkModel* model_; - - // The two special nodes. These are owned by the root tree node owned by - // TreeNodeModel. - FolderNode* recently_bookmarked_node_; - FolderNode* search_node_; - - DISALLOW_COPY_AND_ASSIGN(BookmarkFolderTreeModel); -}; - -#endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_FOLDER_TREE_MODEL_H_ diff --git a/chrome/browser/bookmarks/bookmark_folder_tree_model_unittest.cc b/chrome/browser/bookmarks/bookmark_folder_tree_model_unittest.cc deleted file mode 100644 index c1c9a68..0000000 --- a/chrome/browser/bookmarks/bookmark_folder_tree_model_unittest.cc +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright (c) 2006-2008 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 "base/message_loop.h" -#include "base/string_util.h" -#include "chrome/browser/bookmarks/bookmark_folder_tree_model.h" -#include "chrome/browser/chrome_thread.h" -#include "chrome/test/testing_profile.h" -#include "grit/generated_resources.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "views/controls/tree/tree_view.h" - -// Base class for bookmark model tests. -// Initial state of the bookmark model is as follows: -// bb -// url1 -// f1 -// f11 -// o -// url2 -// f2 -// url3 -// a1 -// g1 -class BookmarkFolderTreeModelTest : public testing::Test, - public TreeModelObserver { - public: - BookmarkFolderTreeModelTest() - : url1_("http://1"), - url2_("http://2"), - url3_("http://3"), - added_count_(0), - removed_count_(0), - changed_count_(0), - reordered_count_(0), - ui_thread_(ChromeThread::UI, &loop_), - file_thread_(ChromeThread::FILE, &loop_) { - } - - virtual void SetUp() { - profile_.reset(new TestingProfile()); - profile_->CreateBookmarkModel(true); - profile_->BlockUntilBookmarkModelLoaded(); - // Populate with some default data. - const BookmarkNode* bb = bookmark_model()->GetBookmarkBarNode(); - bookmark_model()->AddURL(bb, 0, L"url1", url1_); - const BookmarkNode* f1 = bookmark_model()->AddGroup(bb, 1, L"f1"); - bookmark_model()->AddGroup(f1, 0, L"f11"); - - const BookmarkNode* other = bookmark_model()->other_node(); - bookmark_model()->AddURL(other, 0, L"url2", url2_); - bookmark_model()->AddGroup(other, 1, L"f2"); - bookmark_model()->AddURL(other, 2, L"url3", url3_); - - model_.reset(new BookmarkFolderTreeModel(bookmark_model())); - model_->AddObserver(this); - } - - virtual void TearDown() { - model_.reset(NULL); - profile_.reset(NULL); - } - - BookmarkModel* bookmark_model() const { - return profile_->GetBookmarkModel(); - } - - virtual void TreeNodesAdded(TreeModel* model, - TreeModelNode* parent, - int start, - int count) { - added_count_++; - } - - virtual void TreeNodesRemoved(TreeModel* model, - TreeModelNode* parent, - int start, - int count) { - removed_count_++; - } - - virtual void TreeNodeChanged(TreeModel* model, - TreeModelNode* node) { - changed_count_++; - } - - virtual void TreeNodeChildrenReordered(TreeModel* model, - TreeModelNode* parent) { - reordered_count_++; - } - - void VerifyAndClearObserverCounts(int changed_count, - int added_count, - int removed_count, - int reordered_count) { - EXPECT_EQ(changed_count, changed_count_); - EXPECT_EQ(added_count, added_count_); - EXPECT_EQ(removed_count, removed_count_); - EXPECT_EQ(reordered_count, reordered_count_); - ResetCounts(); - } - - void ResetCounts() { - changed_count_ = removed_count_ = added_count_ = reordered_count_ = 0; - } - - scoped_ptr<BookmarkFolderTreeModel> model_; - - const GURL url1_; - const GURL url2_; - const GURL url3_; - - private: - int changed_count_; - int added_count_; - int removed_count_; - int reordered_count_; - scoped_ptr<TestingProfile> profile_; - MessageLoop loop_; - ChromeThread ui_thread_; - ChromeThread file_thread_; -}; - -// Verifies the root node has 4 nodes, and the contents of the bookmark bar -// and other folders matches the initial state. -TEST_F(BookmarkFolderTreeModelTest, InitialState) { - // Verify the first 4 nodes. - TreeModelNode* root = model_->GetRoot(); - ASSERT_EQ(4, model_->GetChildCount(root)); - EXPECT_EQ(BookmarkFolderTreeModel::BOOKMARK, - model_->GetNodeType(model_->GetChild(root, 0))); - EXPECT_EQ(BookmarkFolderTreeModel::BOOKMARK, - model_->GetNodeType(model_->GetChild(root, 1))); - EXPECT_EQ(BookmarkFolderTreeModel::RECENTLY_BOOKMARKED, - model_->GetNodeType(model_->GetChild(root, 2))); - EXPECT_EQ(BookmarkFolderTreeModel::SEARCH, - model_->GetNodeType(model_->GetChild(root, 3))); - - // Verify the contents of the bookmark bar node. - TreeModelNode* bb_node = model_->GetChild(root, 0); - EXPECT_TRUE(model_->TreeNodeAsBookmarkNode(bb_node) == - bookmark_model()->GetBookmarkBarNode()); - ASSERT_EQ(1, model_->GetChildCount(bb_node)); - EXPECT_TRUE(model_->TreeNodeAsBookmarkNode(model_->GetChild(bb_node, 0)) == - bookmark_model()->GetBookmarkBarNode()->GetChild(1)); - - // Verify the contents of the other folders node. - TreeModelNode* other_node = model_->GetChild(root, 1); - EXPECT_TRUE(model_->TreeNodeAsBookmarkNode(other_node) == - bookmark_model()->other_node()); - ASSERT_EQ(1, model_->GetChildCount(other_node)); - EXPECT_TRUE(model_->TreeNodeAsBookmarkNode(model_->GetChild(other_node, 0)) == - bookmark_model()->other_node()->GetChild(1)); -} - -// Removes a URL node and makes sure we don't get any notification. -TEST_F(BookmarkFolderTreeModelTest, RemoveURL) { - bookmark_model()->Remove(bookmark_model()->GetBookmarkBarNode(), 0); - VerifyAndClearObserverCounts(0, 0, 0, 0); -} - -// Changes the title of a URL and makes sure we don't get any notification. -TEST_F(BookmarkFolderTreeModelTest, ChangeURL) { - bookmark_model()->SetTitle( - bookmark_model()->GetBookmarkBarNode()->GetChild(0), L"BLAH"); - VerifyAndClearObserverCounts(0, 0, 0, 0); -} - -// Adds a URL and make sure we don't get notification. -TEST_F(BookmarkFolderTreeModelTest, AddURL) { - bookmark_model()->AddURL( - bookmark_model()->other_node(), 0, L"url1", url1_); - VerifyAndClearObserverCounts(0, 0, 0, 0); -} - -// Removes a folder and makes sure we get the right notification. -TEST_F(BookmarkFolderTreeModelTest, RemoveFolder) { - bookmark_model()->Remove(bookmark_model()->GetBookmarkBarNode(), 1); - VerifyAndClearObserverCounts(0, 0, 1, 0); - // Make sure the node was removed. - EXPECT_EQ(0, model_->GetRoot()->GetChild(0)->GetChildCount()); -} - -// Adds a folder and makes sure we get the right notification. -TEST_F(BookmarkFolderTreeModelTest, AddFolder) { - const BookmarkNode* new_group = - bookmark_model()->AddGroup( - bookmark_model()->GetBookmarkBarNode(), 0, L"fa"); - VerifyAndClearObserverCounts(0, 1, 0, 0); - // Make sure the node was added at the right place. - // Make sure the node was removed. - ASSERT_EQ(2, model_->GetRoot()->GetChild(0)->GetChildCount()); - EXPECT_TRUE(new_group == model_->TreeNodeAsBookmarkNode( - model_->GetRoot()->GetChild(0)->GetChild(0))); -} - -// Changes the title of a folder and makes sure we don't get any notification. -TEST_F(BookmarkFolderTreeModelTest, ChangeFolder) { - bookmark_model()->SetTitle( - bookmark_model()->GetBookmarkBarNode()->GetChild(1)->GetChild(0), - L"BLAH"); - VerifyAndClearObserverCounts(1, 0, 0, 0); -} - -// Sorts the other folder, making sure the resulting order is correct and the -// appropriate notification is sent. -TEST_F(BookmarkFolderTreeModelTest, Sort) { - const BookmarkNode* other = bookmark_model()->other_node(); - bookmark_model()->AddGroup(other, 3, L"a1"); - bookmark_model()->AddGroup(other, 4, L"g1"); - ResetCounts(); - - bookmark_model()->SortChildren(other); - - // Make sure we got notification. - VerifyAndClearObserverCounts(0, 0, 0, 1); - - // Make sure the resulting order matches. - FolderNode* other_folder_node = - model_->GetFolderNodeForBookmarkNode(bookmark_model()->other_node()); - ASSERT_EQ(3, other_folder_node->GetChildCount()); - EXPECT_TRUE(other_folder_node->GetChild(0)->GetTitle() == L"a1"); - EXPECT_TRUE(other_folder_node->GetChild(1)->GetTitle() == L"f2"); - EXPECT_TRUE(other_folder_node->GetChild(2)->GetTitle() == L"g1"); -} diff --git a/chrome/browser/bookmarks/bookmark_manager.h b/chrome/browser/bookmarks/bookmark_manager.h deleted file mode 100644 index 4116b76..0000000 --- a/chrome/browser/bookmarks/bookmark_manager.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2009 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_BOOKMARKS_BOOKMARK_MANAGER_H_ -#define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MANAGER_H_ - -class BookmarkNode; -class PrefService; -class Profile; - -// Cross-platform API for interacting with BookmarkManager views. -// Implemented alongside the platform-specific view classes. -class BookmarkManager { - public: - // Select |node| in the tree view of the bookmark manager, but only if the - // manager is showing and is for |profile|. - static void SelectInTree(Profile* profile, const BookmarkNode* node); - - // Show the bookmark manager for |profile|. Only one bookmark manager shows - // at a time, so if another one is showing, this does nothing. - static void Show(Profile* profile); -}; - -#endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MANAGER_H_ diff --git a/chrome/browser/bookmarks/bookmark_table_model.cc b/chrome/browser/bookmarks/bookmark_table_model.cc deleted file mode 100644 index 0ac5416..0000000 --- a/chrome/browser/bookmarks/bookmark_table_model.cc +++ /dev/null @@ -1,412 +0,0 @@ -// Copyright (c) 2010 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/bookmarks/bookmark_table_model.h" - -#include <limits> - -#include "app/l10n_util.h" -#include "app/resource_bundle.h" -#include "app/table_model_observer.h" -#include "base/i18n/rtl.h" -#include "base/i18n/time_formatting.h" -#include "base/string_util.h" -#include "chrome/browser/bookmarks/bookmark_model.h" -#include "chrome/browser/bookmarks/bookmark_utils.h" -#include "chrome/browser/pref_service.h" -#include "chrome/browser/profile.h" -#include "chrome/common/pref_names.h" -#include "googleurl/src/gurl.h" -#include "grit/app_resources.h" -#include "grit/generated_resources.h" -#include "grit/theme_resources.h" -#include "net/base/escape.h" -#include "net/base/net_util.h" - -namespace { - -// Number of bookmarks shown in recently bookmarked. -const int kRecentlyBookmarkedCount = 50; - -// VectorBackedBookmarkTableModel ---------------------------------------------- - -class VectorBackedBookmarkTableModel : public BookmarkTableModel { - public: - explicit VectorBackedBookmarkTableModel(BookmarkModel* model) - : BookmarkTableModel(model) { - } - - virtual const BookmarkNode* GetNodeForRow(int row) { - return nodes_[row]; - } - - virtual int RowCount() { - return static_cast<int>(nodes_.size()); - } - - virtual void BookmarkNodeMoved(BookmarkModel* model, - const BookmarkNode* old_parent, - int old_index, - const BookmarkNode* new_parent, - int new_index) { - NotifyObserverOfChange(new_parent->GetChild(new_index)); - } - - virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model, - const BookmarkNode* node) { - NotifyObserverOfChange(node); - } - - virtual void BookmarkNodeChanged(BookmarkModel* model, - const BookmarkNode* node) { - NotifyObserverOfChange(node); - } - - protected: - void NotifyObserverOfChange(const BookmarkNode* node) { - if (!observer()) - return; - - int index = IndexOfNode(node); - if (index != -1) - observer()->OnItemsChanged(index, 1); - } - - typedef std::vector<const BookmarkNode*> Nodes; - Nodes& nodes() { return nodes_; } - - private: - Nodes nodes_; - - DISALLOW_COPY_AND_ASSIGN(VectorBackedBookmarkTableModel); -}; - -// FolderBookmarkTableModel ---------------------------------------------------- - -// FolderBookmarkTableModel is a TableModel implementation backed by the -// contents of a bookmark folder. FolderBookmarkTableModel caches the contents -// of the folder so that it can send out the correct events when a bookmark -// node is moved. -class FolderBookmarkTableModel : public VectorBackedBookmarkTableModel { - public: - FolderBookmarkTableModel(BookmarkModel* model, const BookmarkNode* root_node) - : VectorBackedBookmarkTableModel(model), - root_node_(root_node) { - PopulateNodesFromRoot(); - } - - virtual void BookmarkNodeMoved(BookmarkModel* model, - const BookmarkNode* old_parent, - int old_index, - const BookmarkNode* new_parent, - int new_index) { - if (old_parent == root_node_) { - nodes().erase(nodes().begin() + old_index); - if (observer()) - observer()->OnItemsRemoved(old_index, 1); - } - if (new_parent == root_node_) { - nodes().insert(nodes().begin() + new_index, - root_node_->GetChild(new_index)); - if (observer()) - observer()->OnItemsAdded(new_index, 1); - } - } - - virtual void BookmarkNodeAdded(BookmarkModel* model, - const BookmarkNode* parent, - int index) { - if (root_node_ == parent) { - nodes().insert(nodes().begin() + index, parent->GetChild(index)); - if (observer()) - observer()->OnItemsAdded(index, 1); - } - } - - virtual void BookmarkNodeRemoved(BookmarkModel* model, - const BookmarkNode* parent, - int index, - const BookmarkNode* node) { - if (root_node_->HasAncestor(node)) { - // We, or one of our ancestors was removed. - root_node_ = NULL; - nodes().clear(); - if (observer()) - observer()->OnModelChanged(); - return; - } - if (root_node_ == parent) { - nodes().erase(nodes().begin() + index); - if (observer()) - observer()->OnItemsRemoved(index, 1); - } - } - - virtual void BookmarkNodeChanged(BookmarkModel* model, - const BookmarkNode* node) { - NotifyChanged(node); - } - - virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model, - const BookmarkNode* node) { - NotifyChanged(node); - } - - virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, - const BookmarkNode* node) { - if (node != root_node_) - return; - - nodes().clear(); - PopulateNodesFromRoot(); - - if (observer()) - observer()->OnModelChanged(); - } - - private: - void NotifyChanged(const BookmarkNode* node) { - if (node->GetParent() == root_node_ && observer()) - observer()->OnItemsChanged(node->GetParent()->IndexOfChild(node), 1); - } - - void PopulateNodesFromRoot() { - for (int i = 0; i < root_node_->GetChildCount(); ++i) - nodes().push_back(root_node_->GetChild(i)); - } - - // The node we're showing the children of. This is set to NULL if the node - // (or one of its ancestors) is removed from the model. - const BookmarkNode* root_node_; - - DISALLOW_COPY_AND_ASSIGN(FolderBookmarkTableModel); -}; - -// RecentlyBookmarkedTableModel ------------------------------------------------ - -class RecentlyBookmarkedTableModel : public VectorBackedBookmarkTableModel { - public: - explicit RecentlyBookmarkedTableModel(BookmarkModel* model) - : VectorBackedBookmarkTableModel(model) { - UpdateRecentlyBookmarked(); - } - - virtual void BookmarkNodeAdded(BookmarkModel* model, - const BookmarkNode* parent, - int index) { - if (parent->GetChild(index)->is_url()) - UpdateRecentlyBookmarked(); - } - - virtual void BookmarkNodeRemoved(BookmarkModel* model, - const BookmarkNode* parent, - int old_index, - const BookmarkNode* old_node) { - if (old_node->is_url()) - UpdateRecentlyBookmarked(); - } - - private: - void UpdateRecentlyBookmarked() { - nodes().clear(); - bookmark_utils::GetMostRecentlyAddedEntries(model(), - kRecentlyBookmarkedCount, - &nodes()); - if (observer()) - observer()->OnModelChanged(); - } - - DISALLOW_COPY_AND_ASSIGN(RecentlyBookmarkedTableModel); -}; - -// BookmarkSearchTableModel ---------------------------------------------------- - -class BookmarkSearchTableModel : public VectorBackedBookmarkTableModel { - public: - BookmarkSearchTableModel(BookmarkModel* model, - const std::wstring& search_text, - const std::wstring& languages) - : VectorBackedBookmarkTableModel(model), - search_text_(search_text), - languages_(languages) { - bookmark_utils::GetBookmarksContainingText( - model, search_text, std::numeric_limits<int>::max(), - languages, &nodes()); - } - - virtual void BookmarkNodeAdded(BookmarkModel* model, - const BookmarkNode* parent, - int index) { - const BookmarkNode* node = parent->GetChild(index); - if (bookmark_utils::DoesBookmarkContainText( - node, search_text_, languages_)) { - nodes().push_back(node); - if (observer()) - observer()->OnItemsAdded(static_cast<int>(nodes().size() - 1), 1); - } - } - - virtual void BookmarkNodeRemoved(BookmarkModel* model, - const BookmarkNode* parent, - int index, - const BookmarkNode* node) { - int internal_index = IndexOfNode(node); - if (internal_index == -1) - return; - - nodes().erase(nodes().begin() + static_cast<int>(internal_index)); - if (observer()) - observer()->OnItemsRemoved(internal_index, 1); - } - - private: - const std::wstring search_text_; - const std::wstring languages_; - - DISALLOW_COPY_AND_ASSIGN(BookmarkSearchTableModel); -}; - -} // namespace - -// BookmarkTableModel ---------------------------------------------------------- - -// static -BookmarkTableModel* BookmarkTableModel::CreateRecentlyBookmarkedModel( - BookmarkModel* model) { - return new RecentlyBookmarkedTableModel(model); -} - -// static -BookmarkTableModel* BookmarkTableModel::CreateBookmarkTableModelForFolder( - BookmarkModel* model, const BookmarkNode* node) { - return new FolderBookmarkTableModel(model, node); -} - -// static -BookmarkTableModel* BookmarkTableModel::CreateSearchTableModel( - BookmarkModel* model, - const std::wstring& text, - const std::wstring& languages) { - return new BookmarkSearchTableModel(model, text, languages); -} - -BookmarkTableModel::BookmarkTableModel(BookmarkModel* model) - : model_(model), - observer_(NULL) { - model_->AddObserver(this); -} - -BookmarkTableModel::~BookmarkTableModel() { - if (model_) - model_->RemoveObserver(this); -} - -std::wstring BookmarkTableModel::GetText(int row, int column_id) { - const BookmarkNode* node = GetNodeForRow(row); - switch (column_id) { - case IDS_BOOKMARK_TABLE_TITLE: { - std::wstring title = node->GetTitle(); - // Adjust the text as well, for example, put LRE-PDF pair around LTR text - // in RTL enviroment, so that the ending punctuation in the text will not - // be rendered incorrectly (such as rendered as the leftmost character, - // and/or rendered as a mirrored punctuation character). - // - // TODO(xji): Consider adding a special case if the title text is a URL, - // since those should always be displayed LTR. Please refer to - // http://crbug.com/6726 for more information. - base::i18n::AdjustStringForLocaleDirection(title, &title); - return title; - } - - case IDS_BOOKMARK_TABLE_URL: { - if (!node->is_url()) - return std::wstring(); - std::wstring languages = model_ && model_->profile() - ? model_->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages) - : std::wstring(); - std::wstring url_text = net::FormatUrl(node->GetURL(), languages, - net::kFormatUrlOmitAll, UnescapeRule::SPACES, NULL, NULL, NULL); - if (base::i18n::IsRTL()) - base::i18n::WrapStringWithLTRFormatting(&url_text); - return url_text; - } - - case IDS_BOOKMARK_TABLE_PATH: { - std::wstring path; - BuildPath(node->GetParent(), &path); - // Force path to have LTR directionality. The whole path (but not every - // single path component) is marked with LRE-PDF. For example, - // ALEPH/BET/GIMEL (using uppercase English for Hebrew) is supposed to - // appear (visually) as LEMIG/TEB/HPELA; foo/C/B/A.doc refers to file - // C.doc in directory B in directory A in directory foo, not to file - // A.doc in directory B in directory C in directory foo. The reason to - // mark the whole path, but not every single path component, as LTR is - // because paths need to get written in text documents, and that is how - // they will appear there. Being a saint and doing the tedious formatting - // to every single path component to get it to come out in the logical - // order will accomplish nothing but confuse people, since they will now - // see both formats being used, and will never know what anything means. - // Furthermore, doing the "logical" formatting with characters like LRM, - // LRE, and PDF to every single path component means that when someone - // copy/pastes your path, it will still contain those characters, and - // trying to access the file will fail because of them. Windows Explorer, - // Firefox, IE, Nautilus, gedit choose to format only the whole path as - // LTR too. The point here is to display the path the same way as it's - // displayed by other software. - if (base::i18n::IsRTL()) - base::i18n::WrapStringWithLTRFormatting(&path); - return path; - } - } - NOTREACHED(); - return std::wstring(); -} - -SkBitmap BookmarkTableModel::GetIcon(int row) { - static SkBitmap* folder_icon = ResourceBundle::GetSharedInstance(). - GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); - static SkBitmap* default_icon = ResourceBundle::GetSharedInstance(). - GetBitmapNamed(IDR_DEFAULT_FAVICON); - - const BookmarkNode* node = GetNodeForRow(row); - if (node->is_folder()) - return *folder_icon; - - if (model_->GetFavIcon(node).empty()) - return *default_icon; - - return model_->GetFavIcon(node); -} - -void BookmarkTableModel::BookmarkModelBeingDeleted(BookmarkModel* model) { - model_->RemoveObserver(this); - model_ = NULL; -} - -int BookmarkTableModel::IndexOfNode(const BookmarkNode* node) { - for (int i = RowCount() - 1; i >= 0; --i) { - if (GetNodeForRow(i) == node) - return i; - } - return -1; -} - -void BookmarkTableModel::BuildPath(const BookmarkNode* node, - std::wstring* path) { - if (!node) { - NOTREACHED(); - return; - } - if (node == model()->GetBookmarkBarNode()) { - *path = l10n_util::GetString(IDS_BOOKMARK_TABLE_BOOKMARK_BAR_PATH); - return; - } - if (node == model()->other_node()) { - *path = l10n_util::GetString(IDS_BOOKMARK_TABLE_OTHER_BOOKMARKS_PATH); - return; - } - BuildPath(node->GetParent(), path); - path->append(l10n_util::GetString(IDS_BOOKMARK_TABLE_PATH_SEPARATOR)); - path->append(node->GetTitle()); -} diff --git a/chrome/browser/bookmarks/bookmark_table_model.h b/chrome/browser/bookmarks/bookmark_table_model.h deleted file mode 100644 index 4bc4fed..0000000 --- a/chrome/browser/bookmarks/bookmark_table_model.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2006-2008 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_BOOKMARKS_BOOKMARK_TABLE_MODEL_H_ -#define CHROME_BROWSER_BOOKMARKS_BOOKMARK_TABLE_MODEL_H_ - -#include "app/table_model.h" -#include "build/build_config.h" -#include "chrome/browser/bookmarks/bookmark_model_observer.h" - -// BookmarkTableModel provides a view of the BookmarkModel as a TableModel. -// Three variations are provided: -// . Recently created bookmarks. -// . The children of a particular folder. -// . All bookmarks matching the specified text. -class BookmarkTableModel : public TableModel, - public BookmarkModelObserver { - public: - // Methods for creating the various BookmarkTableModels. Ownership passes - // to the caller. - // |languages| is the kAcceptLanguages value of the user preference. It is - // used to decode IDN. - static BookmarkTableModel* CreateRecentlyBookmarkedModel( - BookmarkModel* model); - static BookmarkTableModel* CreateBookmarkTableModelForFolder( - BookmarkModel* model, const BookmarkNode* node); - static BookmarkTableModel* CreateSearchTableModel( - BookmarkModel* model, - const std::wstring& text, - const std::wstring& languages); - - explicit BookmarkTableModel(BookmarkModel* model); - virtual ~BookmarkTableModel(); - - // TableModel methods. - virtual std::wstring GetText(int row, int column_id); - virtual SkBitmap GetIcon(int row); - virtual void SetObserver(TableModelObserver* observer) { - observer_ = observer; - } - - // BookmarkModelObserver methods. - virtual void Loaded(BookmarkModel* model) {} - virtual void BookmarkModelBeingDeleted(BookmarkModel* model); - virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, - const BookmarkNode* node) {} - - - // Returns the index of the specified node, or -1 if the node isn't in the - // model. - virtual int IndexOfNode(const BookmarkNode* node); - - // Returns the BookmarkNode at the specified index. - virtual const BookmarkNode* GetNodeForRow(int row) = 0; - - // Returns the underlying BookmarkModel. - BookmarkModel* model() const { return model_; } - - protected: - TableModelObserver* observer() const { return observer_; } - - private: - // Builds the path shown in the path column for the specified node. - void BuildPath(const BookmarkNode* node, std::wstring* path); - - BookmarkModel* model_; - TableModelObserver* observer_; - - DISALLOW_COPY_AND_ASSIGN(BookmarkTableModel); -}; - -#endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_TABLE_MODEL_H_ diff --git a/chrome/browser/bookmarks/bookmark_table_model_unittest.cc b/chrome/browser/bookmarks/bookmark_table_model_unittest.cc deleted file mode 100644 index 5cc3d6d..0000000 --- a/chrome/browser/bookmarks/bookmark_table_model_unittest.cc +++ /dev/null @@ -1,329 +0,0 @@ -// Copyright (c) 2006-2008 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 "app/table_model_observer.h" -#include "base/message_loop.h" -#include "base/string_util.h" -#include "base/time.h" -#include "chrome/browser/bookmarks/bookmark_table_model.h" -#include "chrome/browser/chrome_thread.h" -#include "chrome/test/testing_profile.h" -#include "grit/generated_resources.h" -#include "testing/gtest/include/gtest/gtest.h" - -using base::Time; -using base::TimeDelta; - -// Base class for bookmark model tests. -// Initial state of the bookmark model is as follows: -// bb -// url1 (t0) -// f1 -// o -// url2 (t0 + 2) -// f2 -// url3 (t0 + 1) -class BookmarkTableModelTest : public testing::Test, - public TableModelObserver { - public: - BookmarkTableModelTest() - : url1_("http://1"), - url2_("http://2"), - url3_("http://3"), - changed_count_(0), - item_changed_count_(0), - added_count_(0), - removed_count_(0), - ui_thread_(ChromeThread::UI, &loop_), - file_thread_(ChromeThread::FILE, &loop_) { - } - - virtual void SetUp() { - profile_.reset(new TestingProfile()); - profile_->CreateBookmarkModel(true); - profile_->BlockUntilBookmarkModelLoaded(); - // Populate with some default data. - Time t0 = Time::Now(); - const BookmarkNode* bb = bookmark_model()->GetBookmarkBarNode(); - bookmark_model()->AddURLWithCreationTime(bb, 0, L"a", url1_, t0); - bookmark_model()->AddGroup(bb, 1, L"f1"); - - const BookmarkNode* other = bookmark_model()->other_node(); - bookmark_model()->AddURLWithCreationTime(other, 0, L"b", - url2_, t0 + TimeDelta::FromDays(2)); - bookmark_model()->AddGroup(other, 1, L"f2"); - bookmark_model()->AddURLWithCreationTime(other, 2, L"c", url3_, - t0 + TimeDelta::FromDays(1)); - } - - virtual void TearDown() { - model_.reset(NULL); - profile_.reset(NULL); - } - - BookmarkModel* bookmark_model() const { - return profile_->GetBookmarkModel(); - } - - virtual void OnModelChanged() { - changed_count_++; - } - - virtual void OnItemsChanged(int start, int length) { - item_changed_count_++; - } - - virtual void OnItemsAdded(int start, int length) { - added_count_++; - } - - virtual void OnItemsRemoved(int start, int length) { - removed_count_++; - } - - void VerifyAndClearOberserverCounts(int changed_count, int item_changed_count, - int added_count, int removed_count) { - EXPECT_EQ(changed_count, changed_count_); - EXPECT_EQ(item_changed_count, item_changed_count_); - EXPECT_EQ(added_count, added_count_); - EXPECT_EQ(removed_count, removed_count_); - ResetCounts(); - } - - void ResetCounts() { - changed_count_ = item_changed_count_ = removed_count_ = added_count_ = 0; - } - - void SetModel(BookmarkTableModel* model) { - if (model_.get()) - model_->SetObserver(NULL); - model_.reset(model); - if (model_.get()) - model_->SetObserver(this); - } - - scoped_ptr<BookmarkTableModel> model_; - - const GURL url1_; - const GURL url2_; - const GURL url3_; - - private: - int changed_count_; - int item_changed_count_; - int added_count_; - int removed_count_; - scoped_ptr<TestingProfile> profile_; - MessageLoop loop_; - ChromeThread ui_thread_; - ChromeThread file_thread_; -}; - -// Verifies the count when showing various nodes. -TEST_F(BookmarkTableModelTest, FolderInitialState) { - SetModel(BookmarkTableModel::CreateBookmarkTableModelForFolder( - bookmark_model(), bookmark_model()->GetBookmarkBarNode())); - ASSERT_EQ(2, model_->RowCount()); - EXPECT_TRUE(bookmark_model()->GetBookmarkBarNode()->GetChild(0) == - model_->GetNodeForRow(0)); - EXPECT_TRUE(bookmark_model()->GetBookmarkBarNode()->GetChild(1) == - model_->GetNodeForRow(1)); - - SetModel(BookmarkTableModel::CreateBookmarkTableModelForFolder( - bookmark_model(), bookmark_model()->other_node())); - EXPECT_EQ(3, model_->RowCount()); -} - -// Verifies adding an item to folder model generates the correct event. -TEST_F(BookmarkTableModelTest, AddToFolder) { - const BookmarkNode* other = bookmark_model()->other_node(); - SetModel(BookmarkTableModel::CreateBookmarkTableModelForFolder( - bookmark_model(), other)); - const BookmarkNode* new_node = bookmark_model()->AddURL(other, 0, L"new", - url1_); - // Should have gotten notification of the add. - VerifyAndClearOberserverCounts(0, 0, 1, 0); - ASSERT_EQ(4, model_->RowCount()); - EXPECT_TRUE(new_node == model_->GetNodeForRow(0)); - - // Add to the bookmark bar, this shouldn't generate an event. - bookmark_model()->AddURL(bookmark_model()->GetBookmarkBarNode(), 0, L"new", - url1_); - VerifyAndClearOberserverCounts(0, 0, 0, 0); -} - -// Verifies sort sends out notification and results in a sort. -TEST_F(BookmarkTableModelTest, SortFolder) { - const BookmarkNode* other = bookmark_model()->other_node(); - SetModel(BookmarkTableModel::CreateBookmarkTableModelForFolder( - bookmark_model(), other)); - ASSERT_EQ(3, model_->RowCount()); - bookmark_model()->SortChildren(other); - - // Sorting should trigger change notification. - VerifyAndClearOberserverCounts(1, 0, 0, 0); - - // Make sure things reordered. - EXPECT_TRUE(other->GetChild(0) == model_->GetNodeForRow(0)); - EXPECT_TRUE(other->GetChild(1) == model_->GetNodeForRow(1)); - EXPECT_TRUE(other->GetChild(2) == model_->GetNodeForRow(2)); -} - -// Verifies removing an item from folder model generates the correct event. -TEST_F(BookmarkTableModelTest, RemoveFromFolder) { - const BookmarkNode* other = bookmark_model()->other_node(); - SetModel(BookmarkTableModel::CreateBookmarkTableModelForFolder( - bookmark_model(), other)); - bookmark_model()->Remove(other, 0); - - // Should have gotten notification of the remove. - VerifyAndClearOberserverCounts(0, 0, 0, 1); - EXPECT_EQ(2, model_->RowCount()); - - // Remove from the bookmark bar, this shouldn't generate an event. - bookmark_model()->Remove(bookmark_model()->GetBookmarkBarNode(), 0); - VerifyAndClearOberserverCounts(0, 0, 0, 0); -} - -// Verifies changing an item in the folder model generates the correct event. -TEST_F(BookmarkTableModelTest, ChangeFolder) { - const BookmarkNode* other = bookmark_model()->other_node(); - SetModel(BookmarkTableModel::CreateBookmarkTableModelForFolder( - bookmark_model(), other)); - bookmark_model()->SetTitle(other->GetChild(0), L"new"); - - // Should have gotten notification of the change. - VerifyAndClearOberserverCounts(0, 1, 0, 0); - EXPECT_EQ(3, model_->RowCount()); - - // Change a node in the bookmark bar, this shouldn't generate an event. - bookmark_model()->SetTitle( - bookmark_model()->GetBookmarkBarNode()->GetChild(0), L"new2"); - VerifyAndClearOberserverCounts(0, 0, 0, 0); -} - -// Verifies show recently added shows the recently added, in order. -TEST_F(BookmarkTableModelTest, RecentlyBookmarkedOrder) { - SetModel(BookmarkTableModel::CreateRecentlyBookmarkedModel(bookmark_model())); - EXPECT_EQ(3, model_->RowCount()); - - const BookmarkNode* bb = bookmark_model()->GetBookmarkBarNode(); - const BookmarkNode* other = bookmark_model()->other_node(); - EXPECT_TRUE(other->GetChild(0) == model_->GetNodeForRow(0)); - EXPECT_TRUE(other->GetChild(2) == model_->GetNodeForRow(1)); - EXPECT_TRUE(bb->GetChild(0) == model_->GetNodeForRow(2)); -} - -// Verifies adding an item to recently added notifies observer. -TEST_F(BookmarkTableModelTest, AddToRecentlyBookmarked) { - SetModel(BookmarkTableModel::CreateRecentlyBookmarkedModel(bookmark_model())); - bookmark_model()->AddURL(bookmark_model()->other_node(), 0, L"new", url1_); - // Should have gotten notification of the add. - VerifyAndClearOberserverCounts(1, 0, 0, 0); - EXPECT_EQ(4, model_->RowCount()); - - // Add a folder, this shouldn't change the model. - bookmark_model()->AddGroup(bookmark_model()->GetBookmarkBarNode(), 0, L"new"); - VerifyAndClearOberserverCounts(0, 0, 0, 0); -} - -// Verifies removing an item from recently added notifies observer. -TEST_F(BookmarkTableModelTest, RemoveFromRecentlyBookmarked) { - SetModel(BookmarkTableModel::CreateRecentlyBookmarkedModel(bookmark_model())); - bookmark_model()->Remove(bookmark_model()->other_node(), 0); - // Should have gotten notification of the remove. - VerifyAndClearOberserverCounts(1, 0, 0, 0); - EXPECT_EQ(2, model_->RowCount()); - - // Remove a folder, this shouldn't change the model. - bookmark_model()->Remove(bookmark_model()->other_node(), 0); - VerifyAndClearOberserverCounts(0, 0, 0, 0); -} - -// Verifies changing an item in recently added notifies observer. -TEST_F(BookmarkTableModelTest, ChangeRecentlyBookmarked) { - SetModel(BookmarkTableModel::CreateRecentlyBookmarkedModel(bookmark_model())); - bookmark_model()->SetTitle(bookmark_model()->other_node()->GetChild(0), - L"new"); - // Should have gotten notification of the change. - VerifyAndClearOberserverCounts(0, 1, 0, 0); - - // Change a folder, this shouldn't change the model. - bookmark_model()->SetTitle(bookmark_model()->other_node()->GetChild(1), - L"new"); - VerifyAndClearOberserverCounts(0, 0, 0, 0); -} - -// Verifies search finds the correct bookmarks. -TEST_F(BookmarkTableModelTest, Search) { - SetModel(BookmarkTableModel::CreateSearchTableModel( - bookmark_model(), L"c", std::wstring())); - ASSERT_EQ(1, model_->RowCount()); - EXPECT_TRUE(bookmark_model()->other_node()->GetChild(2) == - model_->GetNodeForRow(0)); - // Make sure IndexOfNode works. - EXPECT_EQ(0, - model_->IndexOfNode(bookmark_model()->other_node()->GetChild(2))); -} - -// Verifies adding an item to search notifies observers. -TEST_F(BookmarkTableModelTest, AddToSearch) { - SetModel(BookmarkTableModel::CreateSearchTableModel( - bookmark_model(), L"c", std::wstring())); - const BookmarkNode* new_node = - bookmark_model()->AddURL(bookmark_model()->other_node(), 0, L"c", url1_); - // Should have gotten notification of the add. - VerifyAndClearOberserverCounts(0, 0, 1, 0); - ASSERT_EQ(2, model_->RowCount()); - // New node should have gone to end. - EXPECT_TRUE(model_->GetNodeForRow(1) == new_node); - - // Add a folder, this shouldn't change the model. - bookmark_model()->AddGroup(bookmark_model()->GetBookmarkBarNode(), 0, L"new"); - VerifyAndClearOberserverCounts(0, 0, 0, 0); - EXPECT_EQ(2, model_->RowCount()); - - // Add a url that doesn't match search, this shouldn't change the model. - bookmark_model()->AddGroup(bookmark_model()->GetBookmarkBarNode(), 0, L"new"); - VerifyAndClearOberserverCounts(0, 0, 0, 0); - EXPECT_EQ(2, model_->RowCount()); -} - -// Verifies removing an item updates search. -TEST_F(BookmarkTableModelTest, RemoveFromSearch) { - SetModel(BookmarkTableModel::CreateSearchTableModel( - bookmark_model(), L"c", std::wstring())); - bookmark_model()->Remove(bookmark_model()->other_node(), 2); - // Should have gotten notification of the remove. - VerifyAndClearOberserverCounts(0, 0, 0, 1); - EXPECT_EQ(0, model_->RowCount()); - - // Remove a folder, this shouldn't change the model. - bookmark_model()->Remove(bookmark_model()->other_node(), 1); - VerifyAndClearOberserverCounts(0, 0, 0, 0); - - // Remove another url that isn't in the model, this shouldn't change anything. - bookmark_model()->Remove(bookmark_model()->other_node(), 0); - VerifyAndClearOberserverCounts(0, 0, 0, 0); -} - -// Verifies changing an item in search notifies observer. -TEST_F(BookmarkTableModelTest, ChangeSearch) { - SetModel(BookmarkTableModel::CreateSearchTableModel(bookmark_model(), - L"c", std::wstring())); - bookmark_model()->SetTitle(bookmark_model()->other_node()->GetChild(2), - L"new"); - // Should have gotten notification of the change. - VerifyAndClearOberserverCounts(0, 1, 0, 0); - - // Change a folder, this shouldn't change the model. - bookmark_model()->SetTitle(bookmark_model()->other_node()->GetChild(1), - L"new"); - VerifyAndClearOberserverCounts(0, 0, 0, 0); - - // Change a url that isn't in the model, this shouldn't send change. - bookmark_model()->SetTitle(bookmark_model()->other_node()->GetChild(0), - L"new"); - VerifyAndClearOberserverCounts(0, 0, 0, 0); -} diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h index c4ff0c77a..4d2b461 100644 --- a/chrome/browser/browser_window.h +++ b/chrome/browser/browser_window.h @@ -185,9 +185,6 @@ class BrowserWindow { // Shows the Task manager. virtual void ShowTaskManager() = 0; - // Shows the Bookmark Manager window. - virtual void ShowBookmarkManager() = 0; - // Shows the Bookmark bubble. |url| is the URL being bookmarked, // |already_bookmarked| is true if the url is already bookmarked. virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) = 0; diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h index b0861f1..b79712a 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.h +++ b/chrome/browser/cocoa/browser_window_cocoa.h @@ -68,7 +68,6 @@ class BrowserWindowCocoa : public BrowserWindow, virtual void ToggleExtensionShelf(); virtual void ShowAboutChromeDialog(); virtual void ShowTaskManager(); - virtual void ShowBookmarkManager(); virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked); virtual bool IsDownloadShelfVisible() const; virtual DownloadShelf* GetDownloadShelf(); diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index 0de692f..1edee48 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -264,11 +264,6 @@ void BrowserWindowCocoa::ShowTaskManager() { TaskManagerMac::Show(); } -void BrowserWindowCocoa::ShowBookmarkManager() { - // TODO(viettrungluu): Remove function when no callers remain. crbug.com/38908 - NOTIMPLEMENTED(); -} - void BrowserWindowCocoa::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) { [controller_ showBookmarkBubbleForURL:url diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 1b8bc73..dfddbd8 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -838,10 +838,6 @@ void BrowserWindowGtk::ShowTaskManager() { TaskManagerGtk::Show(); } -void BrowserWindowGtk::ShowBookmarkManager() { - // TODO(viettrungluu): remove this function (crbug.com/38908) -} - void BrowserWindowGtk::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) { toolbar_->GetLocationBarView()->ShowStarBubble(url, !already_bookmarked); diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index 2610539..3f10f57 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -86,7 +86,6 @@ class BrowserWindowGtk : public BrowserWindow, virtual void ToggleExtensionShelf(); virtual void ShowAboutChromeDialog(); virtual void ShowTaskManager(); - virtual void ShowBookmarkManager(); virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked); virtual bool IsDownloadShelfVisible() const; virtual DownloadShelf* GetDownloadShelf(); diff --git a/chrome/browser/views/bookmark_context_menu_controller_views.cc b/chrome/browser/views/bookmark_context_menu_controller_views.cc index dc7d090..712df82 100644 --- a/chrome/browser/views/bookmark_context_menu_controller_views.cc +++ b/chrome/browser/views/bookmark_context_menu_controller_views.cc @@ -8,7 +8,6 @@ #include "base/compiler_specific.h" #include "chrome/browser/bookmarks/bookmark_editor.h" #include "chrome/browser/bookmarks/bookmark_folder_editor_controller.h" -#include "chrome/browser/bookmarks/bookmark_manager.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/browser.h" @@ -35,27 +34,6 @@ bool NodeHasURLs(const BookmarkNode* node) { return false; } -// SelectOnCreationHandler ---------------------------------------------------- - -// Used when adding a new bookmark. If a new bookmark is created it is selected -// in the bookmark manager. -class SelectOnCreationHandler : public BookmarkEditor::Handler { - public: - explicit SelectOnCreationHandler(Profile* profile) : profile_(profile) { - } - - virtual void NodeCreated(const BookmarkNode* new_node) { -#if defined(OS_WIN) - BookmarkManager::SelectInTree(profile_, new_node); -#endif - } - - private: - Profile* profile_; - - DISALLOW_COPY_AND_ASSIGN(SelectOnCreationHandler); -}; - } // namespace BookmarkContextMenuControllerViews::BookmarkContextMenuControllerViews( @@ -107,15 +85,6 @@ void BookmarkContextMenuControllerViews::BuildMenu() { delegate_->AddItem(IDS_BOOKMARK_BAR_EDIT); } -#if defined(OS_WIN) - if (configuration_ == BOOKMARK_MANAGER_TABLE || - configuration_ == BOOKMARK_MANAGER_TABLE_OTHER || - configuration_ == BOOKMARK_MANAGER_ORGANIZE_MENU || - configuration_ == BOOKMARK_MANAGER_ORGANIZE_MENU_OTHER) { - delegate_->AddItem(IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER); - } -#endif - delegate_->AddSeparator(); delegate_->AddItem(IDS_CUT); delegate_->AddItem(IDS_COPY); @@ -213,20 +182,14 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { UserMetrics::RecordAction( UserMetricsAction("BookmarkBar_ContextMenu_Add"), profile_); - BookmarkEditor::Configuration editor_config; - BookmarkEditor::Handler* handler = NULL; - if (configuration_ == BOOKMARK_BAR) { - editor_config = BookmarkEditor::SHOW_TREE; - } else { - editor_config = BookmarkEditor::NO_TREE; - // This is owned by the BookmarkEditorView. - handler = new SelectOnCreationHandler(profile_); - } + BookmarkEditor::Configuration editor_config = + (configuration_ == BOOKMARK_BAR) ? BookmarkEditor::SHOW_TREE : + BookmarkEditor::NO_TREE; // TODO: this should honor the index from GetParentForNewNodes. BookmarkEditor::Show( parent_window_, profile_, bookmark_utils::GetParentForNewNodes(parent_, selection_, NULL), - BookmarkEditor::EditDetails(), editor_config, handler); + BookmarkEditor::EditDetails(), editor_config, NULL); break; } @@ -249,21 +212,6 @@ void BookmarkContextMenuControllerViews::ExecuteCommand(int id) { bookmark_utils::ToggleWhenVisible(profile_); break; -#if defined(OS_WIN) - case IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER: - UserMetrics::RecordAction( - UserMetricsAction("BookmarkBar_ContextMenu_ShowInFolder"), - profile_); - - if (selection_.size() != 1) { - NOTREACHED(); - return; - } - - BookmarkManager::SelectInTree(profile_, selection_[0]); - break; -#endif - case IDS_BOOKMARK_MANAGER: UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager"), profile_); @@ -335,13 +283,6 @@ bool BookmarkContextMenuControllerViews::IsCommandEnabled(int id) const { case IDS_BOOKMARK_BAR_REMOVE: return !selection_.empty() && !is_root_node; -#if defined(OS_WIN) - case IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER: - return (configuration_ == BOOKMARK_MANAGER_TABLE_OTHER || - configuration_ == BOOKMARK_MANAGER_ORGANIZE_MENU_OTHER) && - selection_.size() == 1; -#endif - case IDS_BOOKMARK_MANAGER_SORT: return parent_ && parent_ != model_->root_node(); diff --git a/chrome/browser/views/bookmark_folder_tree_view.cc b/chrome/browser/views/bookmark_folder_tree_view.cc deleted file mode 100644 index 74a6dea..0000000 --- a/chrome/browser/views/bookmark_folder_tree_view.cc +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright (c) 2006-2008 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/views/bookmark_folder_tree_view.h" - -#include <commctrl.h> - -#include "app/drag_drop_types.h" -#include "app/os_exchange_data.h" -#include "app/os_exchange_data_provider_win.h" -#include "base/base_drag_source.h" -#include "chrome/browser/bookmarks/bookmark_utils.h" -#include "chrome/browser/bookmarks/bookmark_model.h" -#include "chrome/browser/bookmarks/bookmark_folder_tree_model.h" -#include "chrome/browser/profile.h" -#include "grit/generated_resources.h" -#include "views/view_constants.h" - -void BookmarkFolderTreeView::DropInfo::Scrolled() { - view_->UpdateDropInfo(); -} - -BookmarkFolderTreeView::BookmarkFolderTreeView(Profile* profile, - BookmarkFolderTreeModel* model) - : views::TreeView(), - profile_(profile), - is_dragging_(false) { - SetModel(model); - SetEditable(false); - SetRootShown(false); - set_drag_enabled(true); -} - -bool BookmarkFolderTreeView::CanDrop(const OSExchangeData& data) { - if (!profile_->GetBookmarkModel()->IsLoaded()) - return false; - - BookmarkDragData drag_data; - - if (!drag_data.Read(data)) - return false; - - drop_info_.reset(new DropInfo(this)); - drop_info_->SetData(drag_data); - - // See if there are any urls being dropped. - for (size_t i = 0; i < drop_info_->data().size(); ++i) { - if (drop_info_->data().elements[0].is_url) { - drop_info_->set_only_folders(false); - break; - } - } - - return true; -} - -void BookmarkFolderTreeView::OnDragEntered( - const views::DropTargetEvent& event) { -} - -int BookmarkFolderTreeView::OnDragUpdated(const views::DropTargetEvent& event) { - drop_info_->Update(event); - return UpdateDropInfo(); -} - -void BookmarkFolderTreeView::OnDragExited() { - SetDropPosition(DropPosition()); - - drop_info_.reset(); -} - -int BookmarkFolderTreeView::OnPerformDrop(const views::DropTargetEvent& event) { - OnPerformDropImpl(); - - int drop_operation = drop_info_->drop_operation(); - SetDropPosition(DropPosition()); - drop_info_.reset(); - return drop_operation; -} - -const BookmarkNode* BookmarkFolderTreeView::GetSelectedBookmarkNode() { - TreeModelNode* selected_node = GetSelectedNode(); - if (!selected_node) - return NULL; - return TreeNodeAsBookmarkNode(folder_model()->AsNode(selected_node)); -} - -LRESULT BookmarkFolderTreeView::OnNotify(int w_param, LPNMHDR l_param) { - switch (l_param->code) { - case TVN_BEGINDRAG: { - HTREEITEM tree_item = - reinterpret_cast<LPNMTREEVIEW>(l_param)->itemNew.hItem; - FolderNode* folder_node = - folder_model()->AsNode(GetNodeForTreeItem(tree_item)); - BeginDrag(TreeNodeAsBookmarkNode(folder_node)); - return 0; // Return value ignored. - } - } - - return TreeView::OnNotify(w_param, l_param); -} - -int BookmarkFolderTreeView::UpdateDropInfo() { - DropPosition position = - CalculateDropPosition(drop_info_->last_y(), drop_info_->only_folders()); - drop_info_->set_drop_operation(CalculateDropOperation(position)); - - if (drop_info_->drop_operation() == DragDropTypes::DRAG_NONE) - position = DropPosition(); - - SetDropPosition(position); - - return drop_info_->drop_operation(); -} - -void BookmarkFolderTreeView::BeginDrag(const BookmarkNode* node) { - BookmarkModel* model = profile_->GetBookmarkModel(); - // Only allow the drag if the user has selected a node of type bookmark and it - // isn't the bookmark bar or other bookmarks folders. - if (!node || node == model->other_node() || - node == model->GetBookmarkBarNode()) { - return; - } - - std::vector<const BookmarkNode*> nodes_to_drag; - nodes_to_drag.push_back(node); - - OSExchangeData data; - BookmarkDragData(nodes_to_drag).Write(profile_, &data); - scoped_refptr<BaseDragSource> drag_source(new BaseDragSource); - DWORD effects; - is_dragging_ = true; - DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source, - DROPEFFECT_LINK | DROPEFFECT_COPY | DROPEFFECT_MOVE, &effects); - is_dragging_ = false; -} - -BookmarkFolderTreeView::DropPosition BookmarkFolderTreeView:: - CalculateDropPosition(int y, bool only_folders) { - HWND hwnd = GetNativeControlHWND(); - HTREEITEM item = TreeView_GetFirstVisible(hwnd); - while (item) { - RECT bounds; - TreeView_GetItemRect(hwnd, item, &bounds, TRUE); - if (y < bounds.bottom) { - TreeModelNode* model_node = GetNodeForTreeItem(item); - if (folder_model()->GetNodeType(model_node) != - BookmarkFolderTreeModel::BOOKMARK) { - // Only allow drops on bookmark nodes. - return DropPosition(); - } - - FolderNode* node = folder_model()->AsNode(model_node); - if (!only_folders || !node->GetParent() || - !node->GetParent()->GetParent()) { - // If some of the elements being dropped are urls, then we only allow - // dropping on a folder. Similarly you can't drop between the - // bookmark bar and other folder nodes. - return DropPosition(node, node->GetChildCount(), true); - } - - // Drop contains all folders, allow them to be dropped between - // folders. - if (y < bounds.top + views::kDropBetweenPixels) { - return DropPosition(node->GetParent(), - node->GetParent()->IndexOfChild(node), false); - } - if (y >= bounds.bottom - views::kDropBetweenPixels) { - if (IsExpanded(node) && folder_model()->GetChildCount(node) > 0) { - // The node is expanded and has children, treat the drop as occurring - // as the first child. This is done to avoid the selection highlight - // dancing around when dragging over expanded folders. Without this - // the highlight jumps past the last expanded child of node. - return DropPosition(node, 0, false); - } - return DropPosition(node->GetParent(), - node->GetParent()->IndexOfChild(node) + 1, false); - } - return DropPosition(node, node->GetChildCount(), true); - } - item = TreeView_GetNextVisible(hwnd, item); - } - return DropPosition(); -} - -int BookmarkFolderTreeView::CalculateDropOperation( - const DropPosition& position) { - if (!position.parent) - return DragDropTypes::DRAG_NONE; - - if (drop_info_->data().IsFromProfile(profile_)) { - int bookmark_model_drop_index = FolderIndexToBookmarkIndex(position); - if (!bookmark_utils::IsValidDropLocation( - profile_, drop_info_->data(), - TreeNodeAsBookmarkNode(position.parent), - bookmark_model_drop_index)) { - return DragDropTypes::DRAG_NONE; - } - - // Data from the same profile. Prefer move, but do copy if the user wants - // that. - if (drop_info_->is_control_down()) - return DragDropTypes::DRAG_COPY; - - return DragDropTypes::DRAG_MOVE; - } - // We're going to copy, but return an operation compatible with the source - // operations so that the user can drop. - return bookmark_utils::PreferredDropOperation( - drop_info_->source_operations(), - DragDropTypes::DRAG_COPY | DragDropTypes::DRAG_LINK); -} - -void BookmarkFolderTreeView::OnPerformDropImpl() { - const BookmarkNode* parent_node = - TreeNodeAsBookmarkNode(drop_info_->position().parent); - int drop_index = FolderIndexToBookmarkIndex(drop_info_->position()); - BookmarkModel* model = profile_->GetBookmarkModel(); - // If the data is not from this profile we return an operation compatible - // with the source. As such, we need to need to check the data here too. - if (!drop_info_->data().IsFromProfile(profile_) || - drop_info_->drop_operation() == DragDropTypes::DRAG_COPY) { - bookmark_utils::CloneDragData(model, drop_info_->data().elements, - parent_node, drop_index); - return; - } - - // else, move. - std::vector<const BookmarkNode*> nodes = - drop_info_->data().GetNodes(profile_); - if (nodes.empty()) - return; - - for (size_t i = 0; i < nodes.size(); ++i) { - model->Move(nodes[i], parent_node, drop_index); - // Reset the drop_index, just in case the index didn't really change. - drop_index = parent_node->IndexOfChild(nodes[i]) + 1; - if (nodes[i]->is_folder()) { - Expand(folder_model()->GetFolderNodeForBookmarkNode(nodes[i])); - } - } - - if (is_dragging_ && nodes[0]->is_folder()) { - // We're the drag source. Select the node that was moved. - SetSelectedNode(folder_model()->GetFolderNodeForBookmarkNode(nodes[0])); - } -} - -void BookmarkFolderTreeView::SetDropPosition(const DropPosition& position) { - if (drop_info_->position().equals(position)) - return; - - // Remove the indicator over the previous location. - if (drop_info_->position().on) { - HTREEITEM item = GetTreeItemForNode(drop_info_->position().parent); - if (item) - TreeView_SetItemState(GetNativeControlHWND(), item, 0, TVIS_DROPHILITED); - } else if (drop_info_->position().index != -1) { - TreeView_SetInsertMark(GetNativeControlHWND(), NULL, FALSE); - } - - drop_info_->set_position(position); - - // And show the new indicator. - if (position.on) { - HTREEITEM item = GetTreeItemForNode(position.parent); - if (item) { - TreeView_SetItemState(GetNativeControlHWND(), item, TVIS_DROPHILITED, - TVIS_DROPHILITED); - } - } else if (position.index != -1) { - BOOL after = FALSE; - FolderNode* node = position.parent; - if (folder_model()->GetChildCount(position.parent) == position.index) { - after = TRUE; - node = folder_model()->GetChild(position.parent, position.index - 1); - } else { - node = folder_model()->GetChild(position.parent, position.index); - } - HTREEITEM item = GetTreeItemForNode(node); - if (item) - TreeView_SetInsertMark(GetNativeControlHWND(), item, after); - } -} - -BookmarkFolderTreeModel* BookmarkFolderTreeView::folder_model() const { - return static_cast<BookmarkFolderTreeModel*>(model()); -} - -const BookmarkNode* BookmarkFolderTreeView::TreeNodeAsBookmarkNode( - FolderNode* node) { - return folder_model()->TreeNodeAsBookmarkNode(node); -} - -int BookmarkFolderTreeView::FolderIndexToBookmarkIndex( - const DropPosition& position) { - const BookmarkNode* parent_node = TreeNodeAsBookmarkNode(position.parent); - if (position.on || position.index == position.parent->GetChildCount()) - return parent_node->GetChildCount(); - - if (position.index != 0) { - return parent_node->IndexOfChild( - TreeNodeAsBookmarkNode(position.parent->GetChild(position.index))); - } - - return 0; -} diff --git a/chrome/browser/views/bookmark_folder_tree_view.h b/chrome/browser/views/bookmark_folder_tree_view.h deleted file mode 100644 index 93f5205..0000000 --- a/chrome/browser/views/bookmark_folder_tree_view.h +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) 2006-2008 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_VIEWS_BOOKMARK_FOLDER_TREE_VIEW_H_ -#define CHROME_BROWSER_VIEWS_BOOKMARK_FOLDER_TREE_VIEW_H_ - -#include "base/timer.h" -#include "chrome/browser/bookmarks/bookmark_drag_data.h" -#include "chrome/browser/bookmarks/bookmark_drop_info.h" -#include "chrome/browser/bookmarks/bookmark_folder_tree_model.h" -#include "views/controls/tree/tree_view.h" - -class BookmarkModel; -class BookmarkNode; -class OSExchangeData; -class Profile; - -// BookmarkFolderTreeView is used to show the contents of a -// BookmarkFolderTreeModel and provides drag and drop support. -class BookmarkFolderTreeView : public views::TreeView { - public: - BookmarkFolderTreeView(Profile* profile, BookmarkFolderTreeModel* model); - - // Drag and drop methods. - virtual bool CanDrop(const OSExchangeData& data); - virtual void OnDragEntered(const views::DropTargetEvent& event); - virtual int OnDragUpdated(const views::DropTargetEvent& event); - virtual void OnDragExited(); - virtual int OnPerformDrop(const views::DropTargetEvent& event); - - // Returns the selected node as a BookmarkNode. This returns NULL if the - // selected node is not of type BookmarkFolderTreeModel::BOOKMARK or - // nothing is selected. - const BookmarkNode* GetSelectedBookmarkNode(); - - protected: - // Overriden to start a drag. - virtual LRESULT OnNotify(int w_param, LPNMHDR l_param); - - private: - // DropPosition identifies where the drop should occur. A DropPosition - // consists of the following: the parent FolderNode the drop is to occur at, - // whether the drop is on the parent, and the index into the parent the drop - // should occur at. - // - // WARNING: the index is in terms of the BookmarkFolderTreeModel, which is - // not the same as the BookmarkModel. - struct DropPosition { - DropPosition() : parent(NULL), index(-1), on(false) {} - DropPosition(FolderNode* parent, int index, bool on) - : parent(parent), - index(index), - on(on) {} - - // Returns true if |position| equals this. - bool equals(const DropPosition& position) const { - return (position.parent == parent && position.index == index && - position.on == on); - } - - FolderNode* parent; - int index; - bool on; - }; - - // Provides information used during a drop. - class DropInfo : public BookmarkDropInfo { - public: - explicit DropInfo(BookmarkFolderTreeView* view) - : BookmarkDropInfo(view->GetNativeControlHWND(), 0), - view_(view), - only_folders_(true) {} - - virtual void Scrolled(); - - // Does drag_data consists of folders only? - void set_only_folders(bool only_folders) { only_folders_ = only_folders; } - bool only_folders() const { return only_folders_; } - - // Position of the drop. - void set_position(const DropPosition& position) { position_ = position; } - const DropPosition& position() const { return position_; } - - private: - BookmarkFolderTreeView* view_; - DropPosition position_; - bool only_folders_; - - DISALLOW_COPY_AND_ASSIGN(DropInfo); - }; - friend class DropInfo; - - // Updates drop info. This is invoked both from OnDragUpdated and when we - // autoscroll during a drop. - int UpdateDropInfo(); - - // Starts a drag operation for the specified node. - void BeginDrag(const BookmarkNode* node); - - // Calculates the drop position. - DropPosition CalculateDropPosition(int y, bool only_folders); - - // Determines the appropriate drop operation. This returns DRAG_NONE - // if the position is not valid. - int CalculateDropOperation(const DropPosition& position); - - // Performs the drop operation. - void OnPerformDropImpl(); - - // Sets the drop position. - void SetDropPosition(const DropPosition& position); - - // Returns the model as a BookmarkFolderTreeModel. - BookmarkFolderTreeModel* folder_model() const; - - // Converts FolderNode into a BookmarkNode. - const BookmarkNode* TreeNodeAsBookmarkNode(FolderNode* node); - - // Converts the position in terms of the BookmarkFolderTreeModel to an index - // in terms of the BookmarkModel. The returned index is the index the drop - // should occur at in terms of the BookmarkModel. - int FolderIndexToBookmarkIndex(const DropPosition& position); - - Profile* profile_; - - // Non-null during a drop. - scoped_ptr<DropInfo> drop_info_; - - // Did we originate the drag? - bool is_dragging_; - - DISALLOW_COPY_AND_ASSIGN(BookmarkFolderTreeView); -}; - -#endif // CHROME_BROWSER_VIEWS_BOOKMARK_FOLDER_TREE_VIEW_H_ diff --git a/chrome/browser/views/bookmark_manager_view.cc b/chrome/browser/views/bookmark_manager_view.cc deleted file mode 100644 index 2a99fdf..0000000 --- a/chrome/browser/views/bookmark_manager_view.cc +++ /dev/null @@ -1,859 +0,0 @@ -// Copyright (c) 2010 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/views/bookmark_manager_view.h" - -#include <algorithm> - -#include "app/l10n_util.h" -#include "app/resource_bundle.h" -#include "base/keyboard_codes.h" -#include "base/thread.h" -#include "chrome/browser/bookmarks/bookmark_folder_tree_model.h" -#include "chrome/browser/bookmarks/bookmark_html_writer.h" -#include "chrome/browser/bookmarks/bookmark_manager.h" -#include "chrome/browser/bookmarks/bookmark_model.h" -#include "chrome/browser/bookmarks/bookmark_table_model.h" -#include "chrome/browser/bookmarks/bookmark_utils.h" -#include "chrome/browser/browser_list.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/importer/importer.h" -#include "chrome/browser/importer/importer_data_types.h" -#include "chrome/browser/metrics/user_metrics.h" -#include "chrome/browser/pref_service.h" -#include "chrome/browser/profile.h" -#include "chrome/browser/sync/sync_ui_util.h" -#include "chrome/browser/views/bookmark_editor_view.h" -#include "chrome/browser/views/bookmark_folder_tree_view.h" -#include "chrome/browser/views/bookmark_table_view.h" -#include "chrome/common/pref_names.h" -#include "gfx/canvas.h" -#include "gfx/color_utils.h" -#include "gfx/skia_util.h" -#include "grit/generated_resources.h" -#include "grit/locale_settings.h" -#include "grit/theme_resources.h" -#include "third_party/skia/include/core/SkShader.h" -#include "views/controls/button/menu_button.h" -#include "views/controls/label.h" -#include "views/controls/menu/menu_item_view.h" -#include "views/controls/single_split_view.h" -#include "views/grid_layout.h" -#include "views/standard_layout.h" -#include "views/widget/widget.h" -#include "views/window/window.h" - -// If non-null, there is an open editor and this is the window it is contained -// in it. -static views::Window* open_window = NULL; -// And this is the manager contained in it. -static BookmarkManagerView* manager = NULL; - -// Delay, in ms, between when the user types and when we run the search. -static const int kSearchDelayMS = 200; - -static const int kOrganizeMenuButtonID = 1; -static const int kToolsMenuButtonID = 2; - -// Background color. -static const SkColor kBackgroundColorTop = SkColorSetRGB(242, 247, 253); -static const SkColor kBackgroundColorBottom = SkColorSetRGB(223, 234, 248); -static const int kBackgroundGradientHeight = 28; - -namespace { - -// Observer installed on the importer. When done importing the newly created -// folder is selected in the bookmark manager. -class ImportObserverImpl : public ImportObserver { - public: - explicit ImportObserverImpl(Profile* profile) : profile_(profile) { - BookmarkModel* model = profile->GetBookmarkModel(); - initial_other_count_ = model->other_node()->GetChildCount(); - } - - virtual void ImportCanceled() { - delete this; - } - - virtual void ImportComplete() { - // We aren't needed anymore. - MessageLoop::current()->DeleteSoon(FROM_HERE, this); - - BookmarkManagerView* manager = BookmarkManagerView::current(); - if (!manager || manager->profile() != profile_) - return; - - BookmarkModel* model = profile_->GetBookmarkModel(); - int other_count = model->other_node()->GetChildCount(); - if (other_count == initial_other_count_ + 1) { - const BookmarkNode* imported_node = - model->other_node()->GetChild(initial_other_count_); - manager->SelectInTree(imported_node); - manager->ExpandAll(imported_node); - } - } - - private: - Profile* profile_; - // Number of children in the other bookmarks folder at the time we were - // created. - int initial_other_count_; - - DISALLOW_COPY_AND_ASSIGN(ImportObserverImpl); -}; - -// Converts a virtual keycode into the CutCopyPasteType. -BookmarkManagerView::CutCopyPasteType KeyCodeToCutCopyPaste( - base::KeyboardCode keycode) { - switch (keycode) { - case base::VKEY_INSERT: - if (GetKeyState(VK_CONTROL) < 0) - return BookmarkManagerView::COPY; - if (GetKeyState(VK_SHIFT) < 0) - return BookmarkManagerView::PASTE; - return BookmarkManagerView::NONE; - - case base::VKEY_DELETE: - if (GetKeyState(VK_SHIFT) < 0) - return BookmarkManagerView::CUT; - return BookmarkManagerView::NONE; - - case base::VKEY_C: - if (GetKeyState(VK_CONTROL) < 0) - return BookmarkManagerView::COPY; - return BookmarkManagerView::NONE; - - case base::VKEY_V: - if (GetKeyState(VK_CONTROL) < 0) - return BookmarkManagerView::PASTE; - return BookmarkManagerView::NONE; - - case base::VKEY_X: - if (GetKeyState(VK_CONTROL) < 0) - return BookmarkManagerView::CUT; - return BookmarkManagerView::NONE; - - default: - return BookmarkManagerView::NONE; - } -} - -} // namespace - -namespace browser { - -// Declared in browser_dialogs.h so others don't need to depend on our header. -void ShowBookmarkManagerView(Profile* profile) { - BookmarkManagerView::Show(profile); -} - -} // namespace browser - -// BookmarkManager ------------------------------------------------------------- - -void BookmarkManager::SelectInTree(Profile* profile, const BookmarkNode* node) { - if (manager && manager->profile() == profile) - manager->SelectInTree(node); -} - -void BookmarkManager::Show(Profile* profile) { - BookmarkManagerView::Show(profile); -} - -// ----------------------------------------------------------------------------- - -BookmarkManagerView::BookmarkManagerView(Profile* profile) - : profile_(profile->GetOriginalProfile()), - table_view_(NULL), - tree_view_(NULL), - sync_status_button_(NULL), - sync_service_(NULL), - sync_relogin_required_(false), - ALLOW_THIS_IN_INITIALIZER_LIST(search_factory_(this)) { - views::Label* search_label = new views::Label( - l10n_util::GetString(IDS_BOOKMARK_MANAGER_SEARCH_TITLE)); - search_tf_ = new views::Textfield(); - search_tf_->set_default_width_in_chars(30); - search_tf_->SetAccessibleName(search_label->GetText()); - - table_view_ = new BookmarkTableView(profile_, NULL); - table_view_->SetObserver(this); - table_view_->SetContextMenuController(this); - - tree_view_ = new BookmarkFolderTreeView(profile_, NULL); - tree_view_->SetController(this); - tree_view_->SetContextMenuController(this); - - views::MenuButton* organize_menu_button = new views::MenuButton( - NULL, l10n_util::GetString(IDS_BOOKMARK_MANAGER_ORGANIZE_MENU), - this, true); - organize_menu_button->SetID(kOrganizeMenuButtonID); - - views::MenuButton* tools_menu_button = new views::MenuButton( - NULL, l10n_util::GetString(IDS_BOOKMARK_MANAGER_TOOLS_MENU), - this, true); - tools_menu_button->SetID(kToolsMenuButtonID); - - split_view_ = new views::SingleSplitView(tree_view_, table_view_, - views::SingleSplitView::HORIZONTAL_SPLIT); - split_view_->set_resize_leading_on_bounds_change(false); - split_view_->set_background( - views::Background::CreateSolidBackground(kBackgroundColorBottom)); - - views::GridLayout* layout = new views::GridLayout(this); - SetLayoutManager(layout); - const int top_id = 1; - const int split_cs_id = 2; - layout->SetInsets(2, 0, 0, 0); // 2px padding above content. - views::ColumnSet* column_set = layout->AddColumnSet(top_id); - column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, - 0, views::GridLayout::USE_PREF, 0, 0); - column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, - 0, views::GridLayout::USE_PREF, 0, 0); - column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, - 0, views::GridLayout::USE_PREF, 0, 0); - column_set->AddPaddingColumn(1, kUnrelatedControlHorizontalSpacing); - column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, - 0, views::GridLayout::USE_PREF, 0, 0); - column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); - column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, - 0, views::GridLayout::USE_PREF, 0, 0); - column_set->AddPaddingColumn(0, 3); // 3px padding at end of row. - - column_set = layout->AddColumnSet(split_cs_id); - column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, - views::GridLayout::USE_PREF, 0, 0); - - layout->StartRow(0, top_id); - layout->AddView(organize_menu_button); - layout->AddView(tools_menu_button); - sync_status_button_ = new views::TextButton(this, std::wstring()); - layout->AddView(sync_status_button_); - layout->AddView(search_label); - layout->AddView(search_tf_); - - layout->AddPaddingRow(0, 3); // 3px padding between rows. - - layout->StartRow(1, split_cs_id); - layout->AddView(split_view_); - - // Press Ctrl-W to close bookmark manager window. - AddAccelerator(views::Accelerator(base::VKEY_W, false, true, false)); - - BookmarkModel* bookmark_model = profile_->GetBookmarkModel(); - if (!bookmark_model->IsLoaded()) - bookmark_model->AddObserver(this); - - if (profile_->GetProfileSyncService()) { - sync_service_ = profile_->GetProfileSyncService(); - sync_service_->AddObserver(this); - UpdateSyncStatus(); - } -} - -BookmarkManagerView::~BookmarkManagerView() { - if (select_file_dialog_.get()) - select_file_dialog_->ListenerDestroyed(); - - if (!GetBookmarkModel()->IsLoaded()) { - GetBookmarkModel()->RemoveObserver(this); - } else { - // The models are deleted before the views. Make sure we set the models of - // the views to NULL so that they aren't left holding a reference to a - // deleted model. - table_view_->SetModel(NULL); - tree_view_->SetModel(NULL); - } - manager = NULL; - open_window = NULL; - - if (sync_service_) - sync_service_->RemoveObserver(this); -} - -// static -void BookmarkManagerView::Show(Profile* profile) { - if (!profile->GetBookmarkModel()) - return; - - if (open_window != NULL) { - open_window->Activate(); - return; - } - - // Both of these will be deleted when the dialog closes. - manager = new BookmarkManagerView(profile); - - // Create the window. - open_window = views::Window::CreateChromeWindow(NULL, gfx::Rect(), manager); - // Let the manager know it's parented. - manager->PrepareForShow(); - // And show it. - open_window->Show(); - - // Give initial focus to the search field. - manager->search_tf_->RequestFocus(); -} - -// static -BookmarkManagerView* BookmarkManagerView::current() { - return manager; -} - -void BookmarkManagerView::SelectInTree(const BookmarkNode* node) { - if (!node) - return; - - const BookmarkNode* parent = node->is_url() ? node->GetParent() : node; - FolderNode* folder_node = tree_model_->GetFolderNodeForBookmarkNode(parent); - if (!folder_node) { - NOTREACHED(); - return; - } - - tree_view_->SetSelectedNode(folder_node); - - if (node->is_url()) { - int index = table_model_->IndexOfNode(node); - if (index != -1) - table_view_->Select(index); - // TODO(sky): this doesn't work when invoked from add page. - table_view_->RequestFocus(); - } -} - -void BookmarkManagerView::ExpandAll(const BookmarkNode* node) { - const BookmarkNode* parent = node->is_url() ? node->GetParent() : node; - FolderNode* folder_node = tree_model_->GetFolderNodeForBookmarkNode(parent); - if (!folder_node) { - NOTREACHED(); - return; - } - tree_view_->ExpandAll(folder_node); -} - -const BookmarkNode* BookmarkManagerView::GetSelectedFolder() { - return tree_view_->GetSelectedBookmarkNode(); -} - -std::vector<const BookmarkNode*> BookmarkManagerView::GetSelectedTableNodes() { - std::vector<const BookmarkNode*> nodes; - for (views::TableView::iterator i = table_view_->SelectionBegin(); - i != table_view_->SelectionEnd(); ++i) { - nodes.push_back(table_model_->GetNodeForRow(*i)); - } - // TableViews iterator iterates in reverse order. Reverse the nodes so they - // are opened in visual order. - std::reverse(nodes.begin(), nodes.end()); - return nodes; -} - -void BookmarkManagerView::PaintBackground(gfx::Canvas* canvas) { - canvas->drawColor(kBackgroundColorBottom, SkXfermode::kSrc_Mode); - - SkPaint paint; - paint.setShader(gfx::CreateGradientShader(0, kBackgroundGradientHeight, - kBackgroundColorTop, - kBackgroundColorBottom))->safeUnref(); - canvas->FillRectInt(0, 0, width(), kBackgroundGradientHeight, paint); -} - -gfx::Size BookmarkManagerView::GetPreferredSize() { - return gfx::Size(views::Window::GetLocalizedContentsSize( - IDS_BOOKMARK_MANAGER_DIALOG_WIDTH_CHARS, - IDS_BOOKMARK_MANAGER_DIALOG_HEIGHT_LINES)); -} - -std::wstring BookmarkManagerView::GetWindowTitle() const { - return l10n_util::GetString(IDS_BOOKMARK_MANAGER_TITLE); -} - -std::wstring BookmarkManagerView::GetWindowName() const { - return prefs::kBookmarkManagerPlacement; -} - -void BookmarkManagerView::WindowClosing() { - g_browser_process->local_state()->SetInteger( - prefs::kBookmarkManagerSplitLocation, split_view_->divider_offset()); -} - -void BookmarkManagerView::OnStateChanged() { - UpdateSyncStatus(); -} - -bool BookmarkManagerView::AcceleratorPressed( - const views::Accelerator& accelerator) { - // Ctrl-W to close bookmark manager. - DCHECK(accelerator.GetKeyCode() == 'W' && accelerator.IsCtrlDown()); - window()->Close(); - return true; -} - -void BookmarkManagerView::OnDoubleClick() { - std::vector<const BookmarkNode*> nodes = GetSelectedTableNodes(); - if (nodes.empty()) - return; - if (nodes.size() == 1 && nodes[0]->is_folder()) { - // Double click on a folder descends into the folder. - SelectInTree(nodes[0]); - return; - } - // TODO(sky): OnDoubleClick needs a handle to the current mouse event so that - // we can use - // event_utils::DispositionFromEventFlags(sender->mouse_event_flags()) . - bookmark_utils::OpenAll( - GetWidget()->GetNativeView(), profile_, NULL, nodes, CURRENT_TAB); -} - -void BookmarkManagerView::OnMiddleClick() { - std::vector<const BookmarkNode*> nodes = GetSelectedTableNodes(); - if (nodes.empty()) - return; - if (nodes.size() == 1 && nodes[0]->is_folder()) { - // Middle clicking on a folder results in no action. - return; - } - - bookmark_utils::OpenAll( - GetWidget()->GetNativeView(), profile_, NULL, nodes, NEW_FOREGROUND_TAB); -} - -void BookmarkManagerView::OnTableViewDelete(views::TableView* table) { - std::vector<const BookmarkNode*> nodes = GetSelectedTableNodes(); - if (nodes.empty()) - return; - for (size_t i = 0; i < nodes.size(); ++i) { - GetBookmarkModel()->Remove(nodes[i]->GetParent(), - nodes[i]->GetParent()->IndexOfChild(nodes[i])); - } -} - -void BookmarkManagerView::OnKeyDown(base::KeyboardCode keycode) { - switch (keycode) { - case base::VKEY_RETURN: { - std::vector<const BookmarkNode*> selected_nodes = GetSelectedTableNodes(); - if (selected_nodes.size() == 1 && selected_nodes[0]->is_folder()) { - SelectInTree(selected_nodes[0]); - } else { - bookmark_utils::OpenAll( - GetWidget()->GetNativeView(), profile_, NULL, selected_nodes, - CURRENT_TAB); - } - break; - } - - case base::VKEY_BACK: { - const BookmarkNode* selected_folder = GetSelectedFolder(); - if (selected_folder != NULL && - selected_folder->GetParent() != GetBookmarkModel()->root_node()) { - SelectInTree(selected_folder->GetParent()); - } - break; - } - - default: - OnCutCopyPaste(KeyCodeToCutCopyPaste(keycode), true); - break; - } -} - -void BookmarkManagerView::OnTreeViewSelectionChanged( - views::TreeView* tree_view) { - TreeModelNode* node = tree_view_->GetSelectedNode(); - - BookmarkTableModel* new_table_model = NULL; - const BookmarkNode* table_parent_node = NULL; - bool is_search = false; - - if (node) { - switch (tree_model_->GetNodeType(node)) { - case BookmarkFolderTreeModel::BOOKMARK: - table_parent_node = tree_model_->TreeNodeAsBookmarkNode(node); - new_table_model = - BookmarkTableModel::CreateBookmarkTableModelForFolder( - profile_->GetBookmarkModel(), - table_parent_node); - break; - - case BookmarkFolderTreeModel::RECENTLY_BOOKMARKED: - new_table_model = BookmarkTableModel::CreateRecentlyBookmarkedModel( - profile_->GetBookmarkModel()); - break; - - case BookmarkFolderTreeModel::SEARCH: - is_search = true; - search_factory_.RevokeAll(); - new_table_model = CreateSearchTableModel(); - break; - - default: - NOTREACHED(); - break; - } - } - - SetTableModel(new_table_model, table_parent_node, is_search); -} - -void BookmarkManagerView::OnTreeViewKeyDown(base::KeyboardCode keycode) { - switch (keycode) { - case base::VKEY_DELETE: { - const BookmarkNode* node = GetSelectedFolder(); - if (!node || node->GetParent() == GetBookmarkModel()->root_node()) - return; - - const BookmarkNode* parent = node->GetParent(); - GetBookmarkModel()->Remove(parent, parent->IndexOfChild(node)); - break; - } - - default: - OnCutCopyPaste(KeyCodeToCutCopyPaste(keycode), false); - break; - } -} - -void BookmarkManagerView::ButtonPressed(views::Button* sender, - const views::Event& event) { - if (sender == sync_status_button_) { - if (sync_relogin_required_) { - DCHECK(sync_service_); - sync_service_->ShowLoginDialog(); - } else { - UserMetrics::RecordAction(UserMetricsAction("BookmarkManager_Sync"), - profile_); - sync_ui_util::OpenSyncMyBookmarksDialog( - profile_, ProfileSyncService::START_FROM_BOOKMARK_MANAGER); - } - } -} - -void BookmarkManagerView::Loaded(BookmarkModel* model) { - model->RemoveObserver(this); - LoadedImpl(); -} - -void BookmarkManagerView::ContentsChanged(views::Textfield* sender, - const std::wstring& new_contents) { - search_factory_.RevokeAll(); - MessageLoop::current()->PostDelayedTask(FROM_HERE, - search_factory_.NewRunnableMethod(&BookmarkManagerView::PerformSearch), - kSearchDelayMS); -} - -bool BookmarkManagerView::HandleKeystroke( - views::Textfield* sender, - const views::Textfield::Keystroke& key) { - if (key.GetKeyboardCode() == base::VKEY_RETURN) { - PerformSearch(); - search_tf_->SelectAll(); - } - - return false; -} - -void BookmarkManagerView::ShowContextMenu(views::View* source, - const gfx::Point& p, - bool is_mouse_gesture) { - DCHECK(source == table_view_ || source == tree_view_); - bool is_table = (source == table_view_); - ShowMenu(p, is_table ? - BookmarkContextMenuControllerViews::BOOKMARK_MANAGER_TABLE : - BookmarkContextMenuControllerViews::BOOKMARK_MANAGER_TREE); -} - -void BookmarkManagerView::RunMenu(views::View* source, const gfx::Point& pt) { - // TODO(glen): when you change the buttons around and what not, futz with - // this to make it look good. If you end up keeping padding numbers make them - // constants. - if (!GetBookmarkModel()->IsLoaded()) - return; - - gfx::Point menu_pt(pt); - menu_pt.Offset(UILayoutIsRightToLeft() ? - (source->width() - 5) : (-source->width() + 5), 2); - if (source->GetID() == kOrganizeMenuButtonID) { - ShowMenu(menu_pt, - BookmarkContextMenuControllerViews::BOOKMARK_MANAGER_ORGANIZE_MENU); - } else if (source->GetID() == kToolsMenuButtonID) { - ShowToolsMenu(menu_pt); - } else { - NOTREACHED(); - } -} - -void BookmarkManagerView::ExecuteCommand(int id) { - switch (id) { - case IDS_BOOKMARK_MANAGER_IMPORT_MENU: - UserMetrics::RecordAction(UserMetricsAction("BookmarkManager_Import"), - profile_); - ShowImportBookmarksFileChooser(); - break; - - case IDS_BOOKMARK_MANAGER_EXPORT_MENU: - UserMetrics::RecordAction(UserMetricsAction("BookmarkManager_Export"), - profile_); - ShowExportBookmarksFileChooser(); - break; - - default: - NOTREACHED(); - break; - } -} - -void BookmarkManagerView::FileSelected(const FilePath& path, - int index, - void* params) { - int id = reinterpret_cast<int>(params); - if (id == IDS_BOOKMARK_MANAGER_IMPORT_MENU) { - // ImporterHost is ref counted and will delete itself when done. - ImporterHost* host = new ImporterHost(); - ProfileInfo profile_info; - profile_info.browser_type = importer::BOOKMARKS_HTML; - profile_info.source_path = path.ToWStringHack(); - StartImportingWithUI(GetWidget()->GetNativeView(), importer::FAVORITES, - host, profile_info, profile_, - new ImportObserverImpl(profile()), false); - } else if (id == IDS_BOOKMARK_MANAGER_EXPORT_MENU) { - bookmark_html_writer::WriteBookmarks(profile(), path, NULL); - } else { - NOTREACHED(); - } -} - -void BookmarkManagerView::FileSelectionCanceled(void* params) { - select_file_dialog_ = NULL; -} - -BookmarkTableModel* BookmarkManagerView::CreateSearchTableModel() { - std::wstring search_text = search_tf_->text(); - if (search_text.empty()) - return NULL; - std::wstring languages = - profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); - return BookmarkTableModel::CreateSearchTableModel( - GetBookmarkModel(), search_text, languages); -} - -void BookmarkManagerView::SetTableModel(BookmarkTableModel* new_table_model, - const BookmarkNode* parent_node, - bool is_search) { - // Be sure and reset the model on the view before updating table_model_. - // Otherwise the view will attempt to use the deleted model when we set the - // new one. - table_view_->SetModel(NULL); - table_view_->SetShowPathColumn(!parent_node); - table_view_->SetModel(new_table_model); - table_view_->set_parent_node(parent_node); - table_model_.reset(new_table_model); - if (!is_search || (new_table_model && new_table_model->RowCount() > 0)) { - table_view_->SetAltText(std::wstring()); - } else if (search_tf_->text().empty()) { - table_view_->SetAltText( - l10n_util::GetString(IDS_BOOKMARK_MANAGER_NO_SEARCH_TEXT)); - } else { - table_view_->SetAltText( - l10n_util::GetStringF(IDS_BOOKMARK_MANAGER_NO_RESULTS, - search_tf_->text())); - } -} - -void BookmarkManagerView::PerformSearch() { - search_factory_.RevokeAll(); - // Reset the controller, otherwise when we change the selection we'll get - // notified and update the model twice. - tree_view_->SetController(NULL); - tree_view_->SetSelectedNode(tree_model_->search_node()); - tree_view_->SetController(this); - SetTableModel(CreateSearchTableModel(), NULL, true); -} - -void BookmarkManagerView::PrepareForShow() { - // Restore the split location, but don't let it get too small (or big), - // otherwise users might inadvertently not see the divider. - int split_x = g_browser_process->local_state()->GetInteger( - prefs::kBookmarkManagerSplitLocation); - if (split_x == -1) { - // First time running the bookmark manager, give a third of the width to - // the tree. - split_x = split_view_->width() / 3; - } - int min_split_size = split_view_->width() / 8; - // Make sure the user can see both the tree/table. - split_x = std::min(split_view_->width() - min_split_size, - std::max(min_split_size, split_x)); - split_view_->set_divider_offset(split_x); - if (!GetBookmarkModel()->IsLoaded()) { - search_tf_->SetReadOnly(true); - return; - } - - LoadedImpl(); -} - -void BookmarkManagerView::LoadedImpl() { - BookmarkModel* bookmark_model = GetBookmarkModel(); - const BookmarkNode* bookmark_bar_node = bookmark_model->GetBookmarkBarNode(); - table_model_.reset( - BookmarkTableModel::CreateBookmarkTableModelForFolder(bookmark_model, - bookmark_bar_node)); - table_view_->SetModel(table_model_.get()); - table_view_->set_parent_node(bookmark_bar_node); - - tree_model_.reset(new BookmarkFolderTreeModel(bookmark_model)); - tree_view_->SetModel(tree_model_.get()); - - tree_view_->ExpandAll(); - - tree_view_->SetSelectedNode( - tree_model_->GetFolderNodeForBookmarkNode(bookmark_bar_node)); - - search_tf_->SetReadOnly(false); - search_tf_->SetController(this); - - Layout(); - SchedulePaint(); -} - -BookmarkModel* BookmarkManagerView::GetBookmarkModel() const { - return profile_->GetBookmarkModel(); -} - -void BookmarkManagerView::ShowMenu( - const gfx::Point& p, - BookmarkContextMenuControllerViews::ConfigurationType config) { - if (!GetBookmarkModel()->IsLoaded()) - return; - - const BookmarkNode* parent = GetSelectedFolder(); - std::vector<const BookmarkNode*> nodes; - typedef BookmarkContextMenuControllerViews BCMCV; // Such a long name! - if (config == BCMCV::BOOKMARK_MANAGER_TABLE || - (config == BCMCV::BOOKMARK_MANAGER_ORGANIZE_MENU && - table_view_->HasFocus())) { - nodes = GetSelectedTableNodes(); - if (!parent) { - config = (config == BCMCV::BOOKMARK_MANAGER_TABLE) ? - BCMCV::BOOKMARK_MANAGER_TABLE_OTHER : - BCMCV::BOOKMARK_MANAGER_ORGANIZE_MENU_OTHER; - } - } else { - if (parent) - nodes.push_back(parent); - } - BookmarkContextMenu menu(GetWidget()->GetNativeView(), profile_, NULL, parent, - nodes, config); - menu.RunMenuAt(p); -} - -void BookmarkManagerView::OnCutCopyPaste(CutCopyPasteType type, - bool from_table) { - if (type == CUT || type == COPY) { - std::vector<const BookmarkNode*> nodes; - if (from_table) { - nodes = GetSelectedTableNodes(); - } else { - const BookmarkNode* node = GetSelectedFolder(); - if (!node || node->GetParent() == GetBookmarkModel()->root_node()) - return; - nodes.push_back(node); - } - if (nodes.empty()) - return; - - bookmark_utils::CopyToClipboard(GetBookmarkModel(), nodes, type == CUT); - } else if (type == PASTE) { - int index = from_table ? table_view_->FirstSelectedRow() : -1; - if (index != -1) - index++; - bookmark_utils::PasteFromClipboard(GetBookmarkModel(), GetSelectedFolder(), - index); - } -} - -void BookmarkManagerView::ShowToolsMenu(const gfx::Point& p) { - views::MenuItemView menu(this); - menu.AppendMenuItemWithLabel( - IDS_BOOKMARK_MANAGER_IMPORT_MENU, - l10n_util::GetString(IDS_BOOKMARK_MANAGER_IMPORT_MENU)); - menu.AppendMenuItemWithLabel( - IDS_BOOKMARK_MANAGER_EXPORT_MENU, - l10n_util::GetString(IDS_BOOKMARK_MANAGER_EXPORT_MENU)); - views::MenuItemView::AnchorPosition anchor = UILayoutIsRightToLeft() ? - views::MenuItemView::TOPRIGHT : views::MenuItemView::TOPLEFT; - menu.RunMenuAt(GetWidget()->GetNativeView(), NULL, gfx::Rect(p, gfx::Size()), - anchor, true); -} - -void BookmarkManagerView::ShowImportBookmarksFileChooser() { - if (select_file_dialog_.get()) - select_file_dialog_->ListenerDestroyed(); - - SelectFileDialog::FileTypeInfo file_type_info; - file_type_info.extensions.resize(1); - file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); - file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("htm")); - file_type_info.include_all_files = true; - select_file_dialog_ = SelectFileDialog::Create(this); - select_file_dialog_->SelectFile( - SelectFileDialog::SELECT_OPEN_FILE, std::wstring(), - FilePath(FILE_PATH_LITERAL("bookmarks.html")), &file_type_info, 0, - std::wstring(), GetWidget()->GetNativeView(), - reinterpret_cast<void*>(IDS_BOOKMARK_MANAGER_IMPORT_MENU)); -} - -void BookmarkManagerView::ShowExportBookmarksFileChooser() { - if (select_file_dialog_.get()) - select_file_dialog_->ListenerDestroyed(); - - SelectFileDialog::FileTypeInfo file_type_info; - file_type_info.extensions.resize(1); - file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); - file_type_info.include_all_files = true; - select_file_dialog_ = SelectFileDialog::Create(this); - select_file_dialog_->SelectFile( - SelectFileDialog::SELECT_SAVEAS_FILE, std::wstring(), - FilePath(FILE_PATH_LITERAL("bookmarks.html")), &file_type_info, 0, - L"html", GetWidget()->GetNativeView(), - reinterpret_cast<void*>(IDS_BOOKMARK_MANAGER_EXPORT_MENU)); -} - -void BookmarkManagerView::UpdateSyncStatus() { - DCHECK(sync_service_); - string16 status_label; - string16 link_label; - sync_relogin_required_ = sync_ui_util::GetStatusLabels(sync_service_, - &status_label, &link_label) == sync_ui_util::SYNC_ERROR; - - if (sync_relogin_required_) { - sync_status_button_->SetText( - l10n_util::GetString(IDS_SYNC_BOOKMARK_BAR_ERROR)); - // The tooltip is the only way we have to display text explaining the error - // to the user. - sync_status_button_->SetTooltipText( - l10n_util::GetString(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC)); - sync_status_button_->SetAccessibleName( - l10n_util::GetString(IDS_ACCNAME_SYNC_ERROR_BUTTON)); - sync_status_button_->SetIcon( - *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING)); - sync_status_button_->GetParent()->Layout(); - return; - } - - if (sync_service_->HasSyncSetupCompleted()) { - string16 username = sync_service_->GetAuthenticatedUsername(); - status_label = l10n_util::GetStringFUTF16(IDS_SYNC_NTP_SYNCED_TO, - username); - } else if (sync_service_->SetupInProgress()) { - status_label = l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS); - } else { - status_label = l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL); - } - sync_status_button_->SetText(status_label); - sync_status_button_->SetTooltipText(L""); - sync_status_button_->SetAccessibleName(L""); - sync_status_button_->SetIcon(SkBitmap()); - sync_status_button_->GetParent()->Layout(); -} diff --git a/chrome/browser/views/bookmark_manager_view.h b/chrome/browser/views/bookmark_manager_view.h deleted file mode 100644 index 470152f..0000000 --- a/chrome/browser/views/bookmark_manager_view.h +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright (c) 2010 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_VIEWS_BOOKMARK_MANAGER_VIEW_H_ -#define CHROME_BROWSER_VIEWS_BOOKMARK_MANAGER_VIEW_H_ - -#include "base/keyboard_codes.h" -#include "base/ref_counted.h" -#include "base/task.h" -#include "chrome/browser/bookmarks/bookmark_model_observer.h" -#include "chrome/browser/shell_dialogs.h" -#include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/browser/views/bookmark_context_menu.h" -#include "views/controls/button/text_button.h" -#include "views/controls/menu/view_menu_delegate.h" -#include "views/controls/table/table_view_observer.h" -#include "views/controls/textfield/textfield.h" -#include "views/controls/tree/tree_view.h" -#include "views/view.h" -#include "views/window/window_delegate.h" -#include "webkit/glue/window_open_disposition.h" - -class BookmarkFolderTreeModel; -class BookmarkFolderTreeView; -class BookmarkTableModel; -class BookmarkTableView; -class Profile; - -namespace views { -class SingleSplitView; -} -// A view that lets the user manage their bookmarks. The bookmark manager -// shows a tree on the left with a table on the right. The tree shows the -// folder nodes and the table the contents of the selected tree node. The -// tree is a BookmarkFolderTreeView and the table a BookmarkTableView. A -// text field is also provided that allows the user to search the contents -// of the bookmarks. -class BookmarkManagerView : public views::View, - public views::ContextMenuController, - public views::MenuDelegate, - public views::TableViewObserver, - public views::Textfield::Controller, - public views::TreeViewController, - public views::ViewMenuDelegate, - public views::WindowDelegate, - public views::ButtonListener, - public ProfileSyncServiceObserver, - public BookmarkModelObserver, - public SelectFileDialog::Listener { - public: - enum CutCopyPasteType { - CUT, - COPY, - PASTE, - NONE - }; - - explicit BookmarkManagerView(Profile* profile); - virtual ~BookmarkManagerView(); - - // Shows the bookmark manager. Only one bookmark manager exists. - static void Show(Profile* profile); - - // Returns the current manager, or NULL if the manager is not showing. - static BookmarkManagerView* current(); - - // Selects the specified node in the tree. If node is a URL it's parent is - // selected and node is selected in the table. - void SelectInTree(const BookmarkNode* node); - - // Expands all the children of the selected folder. - void ExpandAll(const BookmarkNode* node); - - // Returns the selected folder in the tree, which may be null. - const BookmarkNode* GetSelectedFolder(); - - // Returns the selection of the table. - std::vector<const BookmarkNode*> GetSelectedTableNodes(); - - virtual void PaintBackground(gfx::Canvas* canvas); - - virtual gfx::Size GetPreferredSize(); - - // WindowDelegate methods. - virtual bool CanResize() const { return true; } - virtual bool CanMaximize() const { return true; } - virtual std::wstring GetWindowTitle() const; - virtual std::wstring GetWindowName() const; - virtual View* GetContentsView() { return this; } - // TODO(sky): implement these when we have an icon. - // virtual SkBitmap GetWindowIcon(); - // virtual bool ShouldShowWindowIcon() const { return true; } - virtual void WindowClosing(); - - // ProfileSyncServiceObserver method. - virtual void OnStateChanged(); - - Profile* profile() const { return profile_; } - - protected: - // View methods. - virtual bool AcceleratorPressed(const views::Accelerator& accelerator); - - private: - // TableViewObserver methods. - virtual void OnSelectionChanged() {} - // Overriden to open the selected table nodes in the current browser. - virtual void OnDoubleClick(); - virtual void OnMiddleClick(); - virtual void OnTableViewDelete(views::TableView* table); - virtual void OnKeyDown(base::KeyboardCode keycode); - - // TreeViewController methods. - virtual void OnTreeViewSelectionChanged(views::TreeView* tree_view); - virtual void OnTreeViewKeyDown(base::KeyboardCode keycode); - - // views::ButtonListener method. - virtual void ButtonPressed(views::Button* sender, const views::Event& event); - - // BookmarkModelObserver. We're only installed as an observer until the - // bookmarks are loaded. - virtual void Loaded(BookmarkModel* model); - virtual void BookmarkModelBeingDeleted(BookmarkModel* model) {} - virtual void BookmarkNodeMoved(BookmarkModel* model, - const BookmarkNode* old_parent, - int old_index, - const BookmarkNode* new_parent, - int new_index) {} - virtual void BookmarkNodeAdded(BookmarkModel* model, - const BookmarkNode* parent, - int index) {} - virtual void BookmarkNodeRemoved(BookmarkModel* model, - const BookmarkNode* parent, - int old_index, - const BookmarkNode* node) {} - virtual void BookmarkNodeChanged(BookmarkModel* model, - const BookmarkNode* node) {} - virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, - const BookmarkNode* node) {} - virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model, - const BookmarkNode* node) {} - - // Textfield::Controller methods. - // Starts a timer to search for the search text. - virtual void ContentsChanged(views::Textfield* sender, - const std::wstring& new_contents); - // If return has been pressed this performs an immediate search. - virtual bool HandleKeystroke(views::Textfield* sender, - const views::Textfield::Keystroke& key); - - // ContextMenuController. - virtual void ShowContextMenu(views::View* source, - const gfx::Point& p, - bool is_mouse_gesture); - - // ViewMenuDelegate. - virtual void RunMenu(views::View* source, const gfx::Point& pt); - - // MenuDelegate. - virtual void ExecuteCommand(int id); - - // SelectFileDialog::Listener. - virtual void FileSelected(const FilePath& path, - int index, void* params); - virtual void FileSelectionCanceled(void* params); - - // Creates the table model to use when searching. This returns NULL if there - // is no search text. - BookmarkTableModel* CreateSearchTableModel(); - - // Sets the model of the table and its parent node. If |is_search| is true, - // it means the table is showing search results. - void SetTableModel(BookmarkTableModel* new_table_model, - const BookmarkNode* parent_node, - bool is_search); - - // Sets the table's model to the results of CreateSearchTableModel and selects - // the search node in the tree. - void PerformSearch(); - - // Invoked prior to showing. If the BookmarkModel is loaded this invokes - // LoadedImpl. - void PrepareForShow(); - - // Invoked when we're parented and the BookmarkModel is loaded. Sets the - // models of the tree/table appropriately and expands the necessary nodes. - void LoadedImpl(); - - // Returns the BookmarkModel. - BookmarkModel* GetBookmarkModel() const; - - // Shows the menu. This is invoked to show the context menu for table/tree - // as well as to show the menu from the organize button. - void ShowMenu(const gfx::Point& p, - BookmarkContextMenuControllerViews::ConfigurationType config); - - // Invoked to handle cut/copy/paste from the table or tree. If |from_table| - // is true the source is the table. - void OnCutCopyPaste(CutCopyPasteType type, bool from_table); - - // Shows the tools menu. - void ShowToolsMenu(const gfx::Point& p); - - // Shows the import/export file chooser. These invoke - // FileSelected/FileSelectionCanceled when done. - void ShowImportBookmarksFileChooser(); - void ShowExportBookmarksFileChooser(); - - void UpdateSyncStatus(); - - Profile* profile_; - BookmarkTableView* table_view_; - BookmarkFolderTreeView* tree_view_; - scoped_ptr<BookmarkTableModel> table_model_; - scoped_ptr<BookmarkFolderTreeModel> tree_model_; - views::Textfield* search_tf_; - views::SingleSplitView* split_view_; - - // Import/export file dialog. - scoped_refptr<SelectFileDialog> select_file_dialog_; - - // The sync status button that notifies the user about the current status of - // bookmarks synchronization. - views::TextButton* sync_status_button_; - - // A pointer to the ProfileSyncService instance if one exists. - ProfileSyncService* sync_service_; - - // True if the cached credentials have expired and we need to prompt the - // user to re-enter their password. - bool sync_relogin_required_; - - // Factory used for delaying search. - ScopedRunnableMethodFactory<BookmarkManagerView> search_factory_; - - DISALLOW_COPY_AND_ASSIGN(BookmarkManagerView); -}; - -#endif // CHROME_BROWSER_VIEWS_BOOKMARK_MANAGER_VIEW_H_ diff --git a/chrome/browser/views/bookmark_table_view.cc b/chrome/browser/views/bookmark_table_view.cc deleted file mode 100644 index 7a48cef..0000000 --- a/chrome/browser/views/bookmark_table_view.cc +++ /dev/null @@ -1,404 +0,0 @@ -// Copyright (c) 2010 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/views/bookmark_table_view.h" - -#include <commctrl.h> - -#include "app/drag_drop_types.h" -#include "app/l10n_util.h" -#include "app/os_exchange_data.h" -#include "app/os_exchange_data_provider_win.h" -#include "app/resource_bundle.h" -#include "base/base_drag_source.h" -#include "chrome/browser/bookmarks/bookmark_utils.h" -#include "chrome/browser/bookmarks/bookmark_model.h" -#include "chrome/browser/bookmarks/bookmark_table_model.h" -#include "chrome/browser/pref_service.h" -#include "chrome/browser/profile.h" -#include "chrome/common/pref_names.h" -#include "gfx/canvas.h" -#include "grit/generated_resources.h" -#include "views/controls/table/table_view_observer.h" -#include "views/view_constants.h" - -namespace { - -// Height of the drop indicator used when dropping between rows. -const int kDropHighlightHeight = 2; - -int GetWidthOfColumn(const std::vector<TableColumn>& columns, - const std::vector<int> widths, - int column_id) { - for (size_t i = 0; i < columns.size(); ++i) { - if (columns[i].id == column_id) - return widths[i]; - } - NOTREACHED(); - return -1; -} - -} // namespace - -void BookmarkTableView::DropInfo::Scrolled() { - view_->UpdateDropInfo(); -} - -BookmarkTableView::BookmarkTableView(Profile* profile, - BookmarkTableModel* model) - : views::TableView(model, std::vector<TableColumn>(), - views::ICON_AND_TEXT, false, true, true), - profile_(profile), - show_path_column_(false) { - UpdateColumns(); -} - -bool BookmarkTableView::CanDrop(const OSExchangeData& data) { - if (!parent_node_ || !profile_->GetBookmarkModel()->IsLoaded()) - return false; - - BookmarkDragData drag_data; - if (!drag_data.Read(data)) - return false; - - // Don't allow the user to drop an ancestor of the parent node onto the - // parent node. This would create a cycle, which is definitely a no-no. - std::vector<const BookmarkNode*> nodes = drag_data.GetNodes(profile_); - for (size_t i = 0; i < nodes.size(); ++i) { - if (parent_node_->HasAncestor(nodes[i])) - return false; - } - - drop_info_.reset(new DropInfo(this)); - drop_info_->SetData(drag_data); - return true; -} - -void BookmarkTableView::OnDragEntered(const views::DropTargetEvent& event) { -} - -int BookmarkTableView::OnDragUpdated(const views::DropTargetEvent& event) { - if (!parent_node_ || !drop_info_.get()) { - drop_info_.reset(NULL); - return false; - } - - drop_info_->Update(event); - return UpdateDropInfo(); -} - -void BookmarkTableView::OnDragExited() { - SetDropPosition(DropPosition()); - drop_info_.reset(); -} - -int BookmarkTableView::OnPerformDrop(const views::DropTargetEvent& event) { - OnPerformDropImpl(); - int drop_operation = drop_info_->drop_operation(); - SetDropPosition(DropPosition()); - drop_info_.reset(); - return drop_operation; -} - -BookmarkTableModel* BookmarkTableView::bookmark_table_model() const { - return static_cast<BookmarkTableModel*>(model()); -} - -void BookmarkTableView::SaveColumnConfiguration() { - PrefService* prefs = profile_->GetPrefs(); - if (!prefs) - return; - - if (show_path_column_) { - prefs->SetInteger(prefs::kBookmarkTableNameWidth2, - GetColumnWidth(IDS_BOOKMARK_TABLE_TITLE)); - prefs->SetInteger(prefs::kBookmarkTableURLWidth2, - GetColumnWidth(IDS_BOOKMARK_TABLE_URL)); - prefs->SetInteger(prefs::kBookmarkTablePathWidth, - GetColumnWidth(IDS_BOOKMARK_TABLE_PATH)); - } else { - prefs->SetInteger(prefs::kBookmarkTableNameWidth1, - GetColumnWidth(IDS_BOOKMARK_TABLE_TITLE)); - prefs->SetInteger(prefs::kBookmarkTableURLWidth1, - GetColumnWidth(IDS_BOOKMARK_TABLE_URL)); - } -} - -void BookmarkTableView::SetShowPathColumn(bool show_path_column) { - if (show_path_column == show_path_column_) - return; - - SaveColumnConfiguration(); - - show_path_column_ = show_path_column; - UpdateColumns(); -} - -void BookmarkTableView::PostPaint() { - PaintAltText(); - - if (!drop_info_.get() || drop_info_->position().index == -1 || - drop_info_->position().on) { - return; - } - - RECT bounds = GetDropBetweenHighlightRect(drop_info_->position().index); - HDC dc = GetDC(GetNativeControlHWND()); - HBRUSH brush = CreateSolidBrush(GetSysColor(COLOR_WINDOWTEXT)); - FillRect(dc, &bounds, brush); - DeleteObject(brush); - ReleaseDC(GetNativeControlHWND(), dc); -} - -LRESULT BookmarkTableView::OnNotify(int w_param, LPNMHDR l_param) { - switch (l_param->code) { - case LVN_BEGINDRAG: - BeginDrag(); - return 0; // Return value doesn't matter for this message. - } - - return TableView::OnNotify(w_param, l_param); -} - -int BookmarkTableView::UpdateDropInfo() { - DropPosition position = CalculateDropPosition(drop_info_->last_y()); - - drop_info_->set_drop_operation(CalculateDropOperation(position)); - - if (drop_info_->drop_operation() == DragDropTypes::DRAG_NONE) - position = DropPosition(); - - SetDropPosition(position); - - return drop_info_->drop_operation(); -} - -void BookmarkTableView::BeginDrag() { - std::vector<const BookmarkNode*> nodes_to_drag; - for (TableView::iterator i = SelectionBegin(); i != SelectionEnd(); ++i) - nodes_to_drag.push_back(bookmark_table_model()->GetNodeForRow(*i)); - if (nodes_to_drag.empty()) - return; // Nothing to drag. - - // Reverse the nodes so that they are put on the clipboard in visual order. - // We do this as SelectionBegin starts at the end of the visual order. - std::reverse(nodes_to_drag.begin(), nodes_to_drag.end()); - - OSExchangeData data; - BookmarkDragData(nodes_to_drag).Write(profile_, &data); - scoped_refptr<BaseDragSource> drag_source(new BaseDragSource); - DWORD effects; - DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source, - DROPEFFECT_LINK | DROPEFFECT_COPY | DROPEFFECT_MOVE, &effects); -} - -int BookmarkTableView::CalculateDropOperation(const DropPosition& position) { - if (drop_info_->data().IsFromProfile(profile_)) { - // Data from the same profile. Prefer move, but do copy if the user wants - // that. - if (drop_info_->is_control_down()) - return DragDropTypes::DRAG_COPY; - - int real_drop_index; - const BookmarkNode* drop_parent = GetDropParentAndIndex(position, - &real_drop_index); - if (!bookmark_utils::IsValidDropLocation( - profile_, drop_info_->data(), drop_parent, real_drop_index)) { - return DragDropTypes::DRAG_NONE; - } - return DragDropTypes::DRAG_MOVE; - } - // We're going to copy, but return an operation compatible with the source - // operations so that the user can drop. - return bookmark_utils::PreferredDropOperation( - drop_info_->source_operations(), - DragDropTypes::DRAG_COPY | DragDropTypes::DRAG_LINK); -} - -void BookmarkTableView::OnPerformDropImpl() { - int drop_index; - const BookmarkNode* drop_parent = GetDropParentAndIndex( - drop_info_->position(), &drop_index); - BookmarkModel* model = profile_->GetBookmarkModel(); - int min_selection; - int max_selection; - // If the data is not from this profile we return an operation compatible - // with the source. As such, we need to need to check the data here too. - if (!drop_info_->data().IsFromProfile(profile_) || - drop_info_->drop_operation() == DragDropTypes::DRAG_COPY) { - bookmark_utils::CloneDragData(model, drop_info_->data().elements, - drop_parent, drop_index); - min_selection = drop_index; - max_selection = drop_index + - static_cast<int>(drop_info_->data().elements.size()); - } else { - // else, move. - std::vector<const BookmarkNode*> nodes = - drop_info_->data().GetNodes(profile_); - if (nodes.empty()) - return; - - for (size_t i = 0; i < nodes.size(); ++i) { - model->Move(nodes[i], drop_parent, drop_index); - // Reset the drop_index, just in case the index didn't really change. - drop_index = drop_parent->IndexOfChild(nodes[i]) + 1; - } - min_selection = drop_parent->IndexOfChild(nodes[0]); - max_selection = min_selection + static_cast<int>(nodes.size()); - } - if (drop_info_->position().on) { - // The user dropped on a folder, select it. - int index = parent_node_->IndexOfChild(drop_parent); - if (index != -1) - Select(index); - } else if (min_selection < RowCount() && max_selection <= RowCount()) { - // Select the moved/copied rows. - Select(min_selection); - if (min_selection + 1 < max_selection) { - // SetSelectedState doesn't send notification, so we manually do it. - for (int i = min_selection + 1; i < max_selection; ++i) - SetSelectedState(i, true); - if (observer()) - observer()->OnSelectionChanged(); - } - } -} - -void BookmarkTableView::SetDropPosition(const DropPosition& position) { - if (drop_info_->position().equals(position)) - return; - - UpdateDropIndicator(drop_info_->position(), false); - - drop_info_->set_position(position); - - UpdateDropIndicator(drop_info_->position(), true); -} - -void BookmarkTableView::UpdateDropIndicator(const DropPosition& position, - bool turn_on) { - if (position.index == -1) - return; - - if (position.on) { - ListView_SetItemState(GetNativeControlHWND(), position.index, - turn_on ? LVIS_DROPHILITED : 0, LVIS_DROPHILITED); - } else { - RECT bounds = GetDropBetweenHighlightRect(position.index); - InvalidateRect(GetNativeControlHWND(), &bounds, FALSE); - } -} - -BookmarkTableView::DropPosition - BookmarkTableView::CalculateDropPosition(int y) { - HWND hwnd = GetNativeControlHWND(); - int row_count = RowCount(); - int top_index = ListView_GetTopIndex(hwnd); - if (row_count == 0 || top_index < 0) - return DropPosition(0, false); - - for (int i = top_index; i < row_count; ++i) { - RECT bounds; - ListView_GetItemRect(hwnd, i, &bounds, LVIR_BOUNDS); - if (y < bounds.top) - return DropPosition(i, false); - if (y < bounds.bottom) { - if (bookmark_table_model()->GetNodeForRow(i)->is_folder()) { - if (y < bounds.top + views::kDropBetweenPixels) - return DropPosition(i, false); - if (y >= bounds.bottom - views::kDropBetweenPixels) - return DropPosition(i + 1, false); - return DropPosition(i, true); - } - if (y < (bounds.bottom - bounds.top) / 2 + bounds.top) - return DropPosition(i, false); - return DropPosition(i + 1, false); - } - } - return DropPosition(row_count, false); -} - -const BookmarkNode* BookmarkTableView::GetDropParentAndIndex( - const DropPosition& position, - int* index) { - if (position.on) { - const BookmarkNode* parent = parent_node_->GetChild(position.index); - *index = parent->GetChildCount(); - return parent; - } - *index = position.index; - return parent_node_; -} - -RECT BookmarkTableView::GetDropBetweenHighlightRect(int index) { - RECT bounds = { 0 }; - if (RowCount() == 0) { - bounds.top = content_offset(); - bounds.left = 0; - bounds.right = width(); - } else if (index >= RowCount()) { - ListView_GetItemRect(GetNativeControlHWND(), index - 1, &bounds, - LVIR_BOUNDS); - bounds.top = bounds.bottom - kDropHighlightHeight / 2; - } else { - ListView_GetItemRect(GetNativeControlHWND(), index, &bounds, LVIR_BOUNDS); - bounds.top -= kDropHighlightHeight / 2; - } - bounds.bottom = bounds.top + kDropHighlightHeight; - return bounds; -} - -void BookmarkTableView::UpdateColumns() { - PrefService* prefs = profile_->GetPrefs(); - TableColumn name_column = - TableColumn(IDS_BOOKMARK_TABLE_TITLE, TableColumn::LEFT, -1); - TableColumn url_column = - TableColumn(IDS_BOOKMARK_TABLE_URL, TableColumn::LEFT, -1); - TableColumn path_column = - TableColumn(IDS_BOOKMARK_TABLE_PATH, TableColumn::LEFT, -1); - - std::vector<TableColumn> columns; - if (show_path_column_) { - int name_width = -1; - int url_width = -1; - int path_width = -1; - if (prefs) { - name_width = prefs->GetInteger(prefs::kBookmarkTableNameWidth2); - url_width = prefs->GetInteger(prefs::kBookmarkTableURLWidth2); - path_width = prefs->GetInteger(prefs::kBookmarkTablePathWidth); - } - if (name_width != -1 && url_width != -1 && path_width != -1) { - name_column.width = name_width; - url_column.width = url_width; - path_column.width = path_width; - } else { - name_column.percent = .5; - url_column.percent = .25; - path_column.percent= .25; - } - columns.push_back(name_column); - columns.push_back(url_column); - columns.push_back(path_column); - } else { - int name_width = -1; - int url_width = -1; - if (prefs) { - name_width = prefs->GetInteger(prefs::kBookmarkTableNameWidth1); - url_width = prefs->GetInteger(prefs::kBookmarkTableURLWidth1); - } - if (name_width != -1 && url_width != -1) { - name_column.width = name_width; - url_column.width = url_width; - } else { - name_column.percent = .5; - url_column.percent = .5; - } - columns.push_back(name_column); - columns.push_back(url_column); - } - SetColumns(columns); - for (size_t i = 0; i < columns.size(); ++i) - SetColumnVisibility(columns[i].id, true); - OnModelChanged(); -} diff --git a/chrome/browser/views/bookmark_table_view.h b/chrome/browser/views/bookmark_table_view.h deleted file mode 100644 index 90ec996..0000000 --- a/chrome/browser/views/bookmark_table_view.h +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) 2010 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_VIEWS_BOOKMARK_TABLE_VIEW_H_ -#define CHROME_BROWSER_VIEWS_BOOKMARK_TABLE_VIEW_H_ - -#include "chrome/browser/bookmarks/bookmark_drag_data.h" -#include "chrome/browser/bookmarks/bookmark_drop_info.h" -#include "views/controls/table/table_view.h" - -class BookmarkModel; -class BookmarkNode; -class BookmarkTableModel; -class OSExchangeData; -class PrefService; -class Profile; - -// A TableView implementation that shows a BookmarkTableModel. -// BookmarkTableView provides drag and drop support as well as showing a -// separate set of columns when showing search results. -class BookmarkTableView : public views::TableView { - public: - BookmarkTableView(Profile* profile, BookmarkTableModel* model); - - // Drag and drop methods. - virtual bool CanDrop(const OSExchangeData& data); - virtual void OnDragEntered(const views::DropTargetEvent& event); - virtual int OnDragUpdated(const views::DropTargetEvent& event); - virtual void OnDragExited(); - virtual int OnPerformDrop(const views::DropTargetEvent& event); - - // Sets the parent of the nodes being displayed. For search and recently - // found results |parent| is NULL. - void set_parent_node(const BookmarkNode* parent) { parent_node_ = parent; } - - // Sets whether the path column should be shown. The path column is shown - // for search results and recently bookmarked. - void SetShowPathColumn(bool show_path_column); - - // The model as a BookmarkTableModel. - BookmarkTableModel* bookmark_table_model() const; - - // Saves the widths of the table columns. - void SaveColumnConfiguration(); - - protected: - // Overriden to draw a drop indicator when dropping between rows. - virtual void PostPaint(); - - // Overriden to start a drag. - virtual LRESULT OnNotify(int w_param, LPNMHDR l_param); - - private: - // DropPosition identifies where the drop should occur. - struct DropPosition { - DropPosition() : index(-1), on(false) {} - DropPosition(int index, bool on) : index(index), on(on) {} - - bool equals(const DropPosition& position) const { - return index == position.index && on == position.on; - } - - // The index into the table model as to where the drop should occur. This - // may == the row count of the table. - int index; - - // Whether drop is on the item at the specified index. If false, the drop - // is at the specified index. - bool on; - }; - - // Information used when we're the drop target of a drag and drop operation. - class DropInfo : public BookmarkDropInfo { - public: - explicit DropInfo(BookmarkTableView* view) - : BookmarkDropInfo(view->GetNativeControlHWND(), - view->content_offset()), - view_(view) {} - - // Overriden to invoke UpdateDropInfo. - virtual void Scrolled(); - - // The position the drop is to occur at. - void set_position(const DropPosition& position) { - position_ = position; - } - const DropPosition& position() { return position_; } - - private: - DropPosition position_; - BookmarkTableView* view_; - - DISALLOW_COPY_AND_ASSIGN(DropInfo); - }; - friend class DropInfo; - - // Updates drop info. This is invoked both from OnDragUpdated and when we - // autoscroll during a drop. - int UpdateDropInfo(); - - // Starts a drop operation. - void BeginDrag(); - - // Returns the drop operation for the specified position. - int CalculateDropOperation(const DropPosition& position); - - // Performs the drop operation. - void OnPerformDropImpl(); - - // Sets the position of the drop. If this differs from the current position - // UpdateDropIndicator is invoked for old and new values. - void SetDropPosition(const DropPosition& position); - - // Invoked from SetDropPosition to update the visual indicator. |turn_on| - // indicates whether the indicator is to be turned on or off. - void UpdateDropIndicator(const DropPosition& position, bool turn_on); - - // Determines the drop position for the specified location. - DropPosition CalculateDropPosition(int y); - - // Returns the BookmarkNode the drop should occur on. - const BookmarkNode* GetDropParentAndIndex(const DropPosition& position, - int* index); - - // Returns the bounds of drop indicator shown when the drop is to occur - // between rows (drop_on is false). - RECT GetDropBetweenHighlightRect(int index); - - // Resets the columns. BookmarkTableView shows different sets of columns. - // See ShowPathColumn for details. - void UpdateColumns(); - - Profile* profile_; - - const BookmarkNode* parent_node_; - - scoped_ptr<DropInfo> drop_info_; - - bool show_path_column_; - - DISALLOW_COPY_AND_ASSIGN(BookmarkTableView); -}; - -#endif // CHROME_BROWSER_VIEWS_BOOKMARK_TABLE_VIEW_H_ diff --git a/chrome/browser/views/dialog_stubs_gtk.cc b/chrome/browser/views/dialog_stubs_gtk.cc index f59421a..01cab50 100644 --- a/chrome/browser/views/dialog_stubs_gtk.cc +++ b/chrome/browser/views/dialog_stubs_gtk.cc @@ -40,11 +40,6 @@ void ShowImporterView(views::Widget* parent, Profile* profile) { NOTIMPLEMENTED(); } -void ShowBookmarkManagerView(Profile* profile) { - // TODO(viettrungluu): remove this function (crbug.com/38908) - NOTIMPLEMENTED(); -} - void ShowPasswordsExceptionsWindowView(Profile* profile) { ShowPasswordsExceptionsWindow(profile); } diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index eb9620d..e8ee1d9 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -951,10 +951,6 @@ void BrowserView::ShowTaskManager() { browser::ShowTaskManager(); } -void BrowserView::ShowBookmarkManager() { - browser::ShowBookmarkManagerView(browser_->profile()); -} - void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) { toolbar_->location_bar()->ShowStarBubble(url, !already_bookmarked); } diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 10292bf..7e52404 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -297,7 +297,6 @@ class BrowserView : public BrowserBubbleHost, virtual void ToggleExtensionShelf(); virtual void ShowAboutChromeDialog(); virtual void ShowTaskManager(); - virtual void ShowBookmarkManager(); virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked); virtual void SetDownloadShelfVisible(bool visible); virtual bool IsDownloadShelfVisible() const; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 2178892..4677735 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -227,13 +227,10 @@ 'browser/bookmarks/bookmark_editor.h', 'browser/bookmarks/bookmark_folder_editor_controller.cc', 'browser/bookmarks/bookmark_folder_editor_controller.h', - 'browser/bookmarks/bookmark_folder_tree_model.cc', - 'browser/bookmarks/bookmark_folder_tree_model.h', 'browser/bookmarks/bookmark_index.cc', 'browser/bookmarks/bookmark_index.h', 'browser/bookmarks/bookmark_html_writer.cc', 'browser/bookmarks/bookmark_html_writer.h', - 'browser/bookmarks/bookmark_manager.h', 'browser/bookmarks/bookmark_model.cc', 'browser/bookmarks/bookmark_model.h', 'browser/bookmarks/bookmark_model_observer.h', @@ -242,8 +239,6 @@ 'browser/bookmarks/bookmark_service.h', 'browser/bookmarks/bookmark_storage.cc', 'browser/bookmarks/bookmark_storage.h', - 'browser/bookmarks/bookmark_table_model.cc', - 'browser/bookmarks/bookmark_table_model.h', 'browser/bookmarks/bookmark_utils.cc', 'browser/bookmarks/bookmark_utils.h', 'browser/browser.cc', @@ -2172,16 +2167,10 @@ 'browser/views/bookmark_context_menu_controller_views.h', 'browser/views/bookmark_editor_view.cc', 'browser/views/bookmark_editor_view.h', - 'browser/views/bookmark_folder_tree_view.cc', - 'browser/views/bookmark_folder_tree_view.h', - 'browser/views/bookmark_manager_view.cc', - 'browser/views/bookmark_manager_view.h', 'browser/views/bookmark_menu_button.cc', 'browser/views/bookmark_menu_button.h', 'browser/views/bookmark_menu_controller_views.cc', 'browser/views/bookmark_menu_controller_views.h', - 'browser/views/bookmark_table_view.cc', - 'browser/views/bookmark_table_view.h', 'browser/views/browser_actions_container.cc', 'browser/views/browser_actions_container.h', 'browser/views/browser_bubble.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 681bb0d39..4591fcb 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -585,13 +585,11 @@ 'browser/bookmarks/bookmark_codec_unittest.cc', 'browser/bookmarks/bookmark_context_menu_controller_unittest.cc', 'browser/bookmarks/bookmark_drag_data_unittest.cc', - 'browser/bookmarks/bookmark_folder_tree_model_unittest.cc', 'browser/bookmarks/bookmark_html_writer_unittest.cc', 'browser/bookmarks/bookmark_index_unittest.cc', 'browser/bookmarks/bookmark_model_test_utils.cc', 'browser/bookmarks/bookmark_model_test_utils.h', 'browser/bookmarks/bookmark_model_unittest.cc', - 'browser/bookmarks/bookmark_table_model_unittest.cc', 'browser/bookmarks/bookmark_utils_unittest.cc', 'browser/browser_commands_unittest.cc', 'browser/browser_theme_pack_unittest.cc', @@ -1177,8 +1175,6 @@ 'sources!': [ 'browser/bookmarks/bookmark_codec_unittest.cc', 'browser/bookmarks/bookmark_drag_data_unittest.cc', - 'browser/bookmarks/bookmark_folder_tree_model_unittest.cc', - 'browser/bookmarks/bookmark_table_model_unittest.cc', 'browser/browser_unittest.cc', 'browser/chrome_plugin_unittest.cc', 'browser/extensions/extension_process_manager_unittest.cc', |