diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 22:28:44 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 22:28:44 +0000 |
commit | ec12ffe60e6d1e26833fb5c518fd6c85ab0c12bb (patch) | |
tree | c5f53581aa406dc819f4a758abc1e794099fa29b /chrome/browser/views/bookmark_editor_view.cc | |
parent | 54fe13676dcdfa8a711b0ffd9a9d96a194da834d (diff) | |
download | chromium_src-ec12ffe60e6d1e26833fb5c518fd6c85ab0c12bb.zip chromium_src-ec12ffe60e6d1e26833fb5c518fd6c85ab0c12bb.tar.gz chromium_src-ec12ffe60e6d1e26833fb5c518fd6c85ab0c12bb.tar.bz2 |
Makes canceling 'bookmark all tabs' delete the folder. Or rather,
makes it so that bookmark all tabs only creates the folder if the user
presses ok. I wasn't happy adding another random arg to
BookmarkEditor::Show, so I added in a structure an enum. This makes it
clearer what Show should do.
I also fixed the following:
. On gtk we wouldn't always pick the right parent for nodes.
. The context menu item is now enabled on views/gtk.
And this now breaks the mac side. I'll straighten that out right after
landing this.
BUG=24367
TEST=Make sure 'bookmark all tabs' works, as well as the bookmark
editor work. (get to the bookmark editor by creating a new bookmark,
then clicking edit, or right clicking a bookmark on the bookmark bar and
choosing edit).
Review URL: http://codereview.chromium.org/271115
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29343 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/bookmark_editor_view.cc')
-rw-r--r-- | chrome/browser/views/bookmark_editor_view.cc | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc index 42d6447..852649b 100644 --- a/chrome/browser/views/bookmark_editor_view.cc +++ b/chrome/browser/views/bookmark_editor_view.cc @@ -49,26 +49,26 @@ static const int kNewGroupButtonID = 1002; void BookmarkEditor::Show(HWND parent_hwnd, Profile* profile, const BookmarkNode* parent, - const BookmarkNode* node, + const EditDetails& details, Configuration configuration, Handler* handler) { DCHECK(profile); BookmarkEditorView* editor = - new BookmarkEditorView(profile, parent, node, configuration, handler); + new BookmarkEditorView(profile, parent, details, configuration, handler); editor->Show(parent_hwnd); } BookmarkEditorView::BookmarkEditorView( Profile* profile, const BookmarkNode* parent, - const BookmarkNode* node, + const EditDetails& details, BookmarkEditor::Configuration configuration, BookmarkEditor::Handler* handler) : profile_(profile), tree_view_(NULL), new_group_button_(NULL), parent_(parent), - node_(node), + details_(details), running_menu_for_root_(false), show_tree_(configuration == SHOW_TREE), handler_(handler) { @@ -87,7 +87,7 @@ BookmarkEditorView::~BookmarkEditorView() { bool BookmarkEditorView::IsDialogButtonEnabled( MessageBoxFlags::DialogButton button) const { if (button == MessageBoxFlags::DIALOGBUTTON_OK) { - if (IsEditingFolder()) + if (details_.type == EditDetails::NEW_FOLDER) return !title_tf_.text().empty(); const GURL url(GetInputURL()); @@ -263,19 +263,24 @@ void BookmarkEditorView::Init() { url_tf_.SetParentOwned(false); title_tf_.SetParentOwned(false); - title_tf_.SetText(node_ ? node_->GetTitle() : std::wstring()); + std::wstring title; + if (details_.type == EditDetails::EXISTING_NODE) + title = details_.existing_node->GetTitle(); + else if (details_.type == EditDetails::NEW_FOLDER) + title = l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME); + title_tf_.SetText(title); title_tf_.SetController(this); std::wstring url_text; - if (node_ && !IsEditingFolder()) { + if (details_.type == EditDetails::EXISTING_NODE) { std::wstring languages = profile_ ? profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) : std::wstring(); // The following URL is user-editable. We specify omit_username_password= // false and unescape=false to show the original URL except IDN. url_text = - net::FormatUrl(node_->GetURL(), languages, false, UnescapeRule::NONE, - NULL, NULL); + net::FormatUrl(details_.existing_node->GetURL(), languages, false, + UnescapeRule::NONE, NULL, NULL); } url_tf_.SetText(url_text); url_tf_.SetController(this); @@ -327,7 +332,7 @@ void BookmarkEditorView::Init() { new Label(l10n_util::GetString(IDS_BOOMARK_EDITOR_NAME_LABEL))); layout->AddView(&title_tf_); - if (!IsEditingFolder()) { + if (details_.type != EditDetails::NEW_FOLDER) { layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, labels_column_set_id); @@ -366,7 +371,8 @@ void BookmarkEditorView::BookmarkNodeRemoved(BookmarkModel* model, const BookmarkNode* parent, int index, const BookmarkNode* node) { - if ((node_ && node_->HasAncestor(node)) || + if ((details_.type == EditDetails::EXISTING_NODE && + details_.existing_node->HasAncestor(node)) || (parent_ && parent_->HasAncestor(node))) { // The node, or its parent was removed. Close the dialog. window()->Close(); @@ -447,14 +453,12 @@ BookmarkEditorView::EditorNode* BookmarkEditorView::AddNewGroup( return new_node; } -bool BookmarkEditorView::IsEditingFolder() const { - return node_ && node_->is_folder(); -} - void BookmarkEditorView::ExpandAndSelect() { tree_view_->ExpandAll(); - const BookmarkNode* to_select = node_ ? node_->GetParent() : parent_; + const BookmarkNode* to_select = parent_; + if (details_.type == EditDetails::EXISTING_NODE) + to_select = details_.existing_node->GetParent(); int64 group_id_to_select = to_select->id(); EditorNode* b_node = FindNodeWithID(tree_model_->GetRoot(), group_id_to_select); @@ -478,8 +482,7 @@ void BookmarkEditorView::CreateNodes(const BookmarkNode* bb_node, BookmarkEditorView::EditorNode* b_node) { for (int i = 0; i < bb_node->GetChildCount(); ++i) { const BookmarkNode* child_bb_node = bb_node->GetChild(i); - if (child_bb_node->is_folder() && - (!IsEditingFolder() || child_bb_node != node_)) { + if (child_bb_node->is_folder()) { EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), child_bb_node->id()); b_node->Add(b_node->GetChildCount(), new_b_node); @@ -526,7 +529,7 @@ void BookmarkEditorView::ApplyEdits(EditorNode* parent) { if (!show_tree_) { bookmark_utils::ApplyEditsWithNoGroupChange( - bb_model_, parent_, node_, new_title, new_url, handler_.get()); + bb_model_, parent_, details_, new_title, new_url, handler_.get()); return; } @@ -536,7 +539,7 @@ void BookmarkEditorView::ApplyEdits(EditorNode* parent) { bb_model_->root_node(), tree_model_->GetRoot(), parent, &new_parent); bookmark_utils::ApplyEditsWithPossibleGroupChange( - bb_model_, new_parent, node_, new_title, new_url, handler_.get()); + bb_model_, new_parent, details_, new_title, new_url, handler_.get()); } void BookmarkEditorView::ApplyNameChangesAndCreateNewGroups( |