Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: chrome/browser/views/bookmark_editor_view.cc

Issue 271115: Makes canceling 'bookmark all tabs' delete the folder. Or rather,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/views/bookmark_editor_view.cc
===================================================================
--- chrome/browser/views/bookmark_editor_view.cc (revision 29276)
+++ chrome/browser/views/bookmark_editor_view.cc (working copy)
@@ -49,26 +49,26 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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(

Powered by Google App Engine
This is Rietveld 408576698