OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_vie
ws.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_vie
ws.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/bookmarks/bookmark_editor.h" | 9 #include "chrome/browser/bookmarks/bookmark_editor.h" |
10 #include "chrome/browser/bookmarks/bookmark_folder_editor_controller.h" | 10 #include "chrome/browser/bookmarks/bookmark_folder_editor_controller.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 case IDC_BOOKMARK_BAR_EDIT: | 123 case IDC_BOOKMARK_BAR_EDIT: |
124 UserMetrics::RecordAction( | 124 UserMetrics::RecordAction( |
125 UserMetricsAction("BookmarkBar_ContextMenu_Edit")); | 125 UserMetricsAction("BookmarkBar_ContextMenu_Edit")); |
126 | 126 |
127 if (selection_.size() != 1) { | 127 if (selection_.size() != 1) { |
128 NOTREACHED(); | 128 NOTREACHED(); |
129 return; | 129 return; |
130 } | 130 } |
131 | 131 |
132 if (selection_[0]->is_url()) { | 132 if (selection_[0]->is_url()) { |
| 133 #if defined(WEBUI_DIALOGS) |
| 134 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
| 135 DCHECK(browser); |
| 136 browser->OpenBookmarkManagerEditNode(selection_[0]->id()); |
| 137 #else |
133 BookmarkEditor::Show(parent_widget_->GetNativeWindow(), profile_, | 138 BookmarkEditor::Show(parent_widget_->GetNativeWindow(), profile_, |
134 parent_, BookmarkEditor::EditDetails(selection_[0]), | 139 parent_, BookmarkEditor::EditDetails(selection_[0]), |
135 BookmarkEditor::SHOW_TREE); | 140 BookmarkEditor::SHOW_TREE); |
| 141 #endif |
136 } else { | 142 } else { |
137 BookmarkFolderEditorController::Show(profile_, | 143 BookmarkFolderEditorController::Show(profile_, |
138 parent_widget_->GetNativeWindow(), selection_[0], -1, | 144 parent_widget_->GetNativeWindow(), selection_[0], -1, |
139 BookmarkFolderEditorController::EXISTING_BOOKMARK); | 145 BookmarkFolderEditorController::EXISTING_BOOKMARK); |
140 } | 146 } |
141 break; | 147 break; |
142 | 148 |
143 case IDC_BOOKMARK_BAR_REMOVE: { | 149 case IDC_BOOKMARK_BAR_REMOVE: { |
144 UserMetrics::RecordAction( | 150 UserMetrics::RecordAction( |
145 UserMetricsAction("BookmarkBar_ContextMenu_Remove")); | 151 UserMetricsAction("BookmarkBar_ContextMenu_Remove")); |
146 | 152 |
147 delegate_->WillRemoveBookmarks(selection_); | 153 delegate_->WillRemoveBookmarks(selection_); |
148 for (size_t i = 0; i < selection_.size(); ++i) { | 154 for (size_t i = 0; i < selection_.size(); ++i) { |
149 model->Remove(selection_[i]->parent(), | 155 model->Remove(selection_[i]->parent(), |
150 selection_[i]->parent()->GetIndexOf(selection_[i])); | 156 selection_[i]->parent()->GetIndexOf(selection_[i])); |
151 } | 157 } |
152 delegate_->DidRemoveBookmarks(); | 158 delegate_->DidRemoveBookmarks(); |
153 selection_.clear(); | 159 selection_.clear(); |
154 break; | 160 break; |
155 } | 161 } |
156 | 162 |
157 case IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK: { | 163 case IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK: { |
158 UserMetrics::RecordAction( | 164 UserMetrics::RecordAction( |
159 UserMetricsAction("BookmarkBar_ContextMenu_Add")); | 165 UserMetricsAction("BookmarkBar_ContextMenu_Add")); |
160 | 166 |
| 167 #if defined(WEBUI_DIALOGS) |
| 168 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
| 169 DCHECK(browser); |
| 170 browser->OpenBookmarkManagerAddNodeIn(selection_[0]->id()); |
| 171 #else |
161 // TODO: this should honor the index from GetParentForNewNodes. | 172 // TODO: this should honor the index from GetParentForNewNodes. |
162 BookmarkEditor::Show( | 173 BookmarkEditor::Show( |
163 parent_widget_->GetNativeWindow(), profile_, | 174 parent_widget_->GetNativeWindow(), profile_, |
164 bookmark_utils::GetParentForNewNodes(parent_, selection_, NULL), | 175 bookmark_utils::GetParentForNewNodes(parent_, selection_, NULL), |
165 BookmarkEditor::EditDetails(), BookmarkEditor::SHOW_TREE); | 176 BookmarkEditor::EditDetails(), BookmarkEditor::SHOW_TREE); |
| 177 #endif |
166 break; | 178 break; |
167 } | 179 } |
168 | 180 |
169 case IDC_BOOKMARK_BAR_NEW_FOLDER: { | 181 case IDC_BOOKMARK_BAR_NEW_FOLDER: { |
170 UserMetrics::RecordAction( | 182 UserMetrics::RecordAction( |
171 UserMetricsAction("BookmarkBar_ContextMenu_NewFolder")); | 183 UserMetricsAction("BookmarkBar_ContextMenu_NewFolder")); |
172 int index; | 184 int index; |
173 const BookmarkNode* parent = | 185 const BookmarkNode* parent = |
174 bookmark_utils::GetParentForNewNodes(parent_, selection_, &index); | 186 bookmark_utils::GetParentForNewNodes(parent_, selection_, &index); |
175 BookmarkFolderEditorController::Show(profile_, | 187 BookmarkFolderEditorController::Show(profile_, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 return model; | 307 return model; |
296 } | 308 } |
297 | 309 |
298 bool BookmarkContextMenuControllerViews::HasURLs() const { | 310 bool BookmarkContextMenuControllerViews::HasURLs() const { |
299 for (size_t i = 0; i < selection_.size(); ++i) { | 311 for (size_t i = 0; i < selection_.size(); ++i) { |
300 if (bookmark_utils::NodeHasURLs(selection_[i])) | 312 if (bookmark_utils::NodeHasURLs(selection_[i])) |
301 return true; | 313 return true; |
302 } | 314 } |
303 return false; | 315 return false; |
304 } | 316 } |
OLD | NEW |