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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc

Issue 6837021: Disable bookmark editing (views UI). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 bool BookmarkContextMenuControllerViews::IsItemChecked(int id) const { 223 bool BookmarkContextMenuControllerViews::IsItemChecked(int id) const {
224 DCHECK(id == IDC_BOOKMARK_BAR_ALWAYS_SHOW); 224 DCHECK(id == IDC_BOOKMARK_BAR_ALWAYS_SHOW);
225 return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); 225 return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar);
226 } 226 }
227 227
228 bool BookmarkContextMenuControllerViews::IsCommandEnabled(int id) const { 228 bool BookmarkContextMenuControllerViews::IsCommandEnabled(int id) const {
229 bool is_root_node = 229 bool is_root_node =
230 (selection_.size() == 1 && 230 (selection_.size() == 1 &&
231 selection_[0]->parent() == model_->root_node()); 231 selection_[0]->parent() == model_->root_node());
232 bool can_edit =
233 profile_->GetPrefs()->GetBoolean(prefs::kEditBookmarksEnabled);
232 switch (id) { 234 switch (id) {
233 case IDC_BOOKMARK_BAR_OPEN_INCOGNITO: 235 case IDC_BOOKMARK_BAR_OPEN_INCOGNITO:
234 return !profile_->IsOffTheRecord() && 236 return !profile_->IsOffTheRecord() &&
235 profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled); 237 profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled);
236 238
237 case IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO: 239 case IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO:
238 return HasURLs() && !profile_->IsOffTheRecord() && 240 return HasURLs() && !profile_->IsOffTheRecord() &&
239 profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled); 241 profile_->GetPrefs()->GetBoolean(prefs::kIncognitoEnabled);
240 242
241 case IDC_BOOKMARK_BAR_OPEN_ALL: 243 case IDC_BOOKMARK_BAR_OPEN_ALL:
242 case IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW: 244 case IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW:
243 return HasURLs(); 245 return HasURLs();
244 246
245 case IDC_BOOKMARK_BAR_RENAME_FOLDER: 247 case IDC_BOOKMARK_BAR_RENAME_FOLDER:
246 case IDC_BOOKMARK_BAR_EDIT: 248 case IDC_BOOKMARK_BAR_EDIT:
247 return selection_.size() == 1 && !is_root_node; 249 return selection_.size() == 1 && !is_root_node && can_edit;
248 250
249 case IDC_BOOKMARK_BAR_REMOVE: 251 case IDC_BOOKMARK_BAR_REMOVE:
250 return !selection_.empty() && !is_root_node; 252 return !selection_.empty() && !is_root_node && can_edit;
251 253
252 case IDC_BOOKMARK_BAR_NEW_FOLDER: 254 case IDC_BOOKMARK_BAR_NEW_FOLDER:
253 case IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK: 255 case IDC_BOOKMARK_BAR_ADD_NEW_BOOKMARK:
254 return bookmark_utils::GetParentForNewNodes( 256 return can_edit && bookmark_utils::GetParentForNewNodes(
255 parent_, selection_, NULL) != NULL; 257 parent_, selection_, NULL) != NULL;
256 258
257 case IDC_BOOKMARK_BAR_ALWAYS_SHOW: 259 case IDC_BOOKMARK_BAR_ALWAYS_SHOW:
258 return !profile_->GetPrefs()->IsManagedPreference( 260 return !profile_->GetPrefs()->IsManagedPreference(
259 prefs::kEnableBookmarkBar); 261 prefs::kEnableBookmarkBar);
260 262
261 case IDC_COPY: 263 case IDC_COPY:
262 case IDC_CUT: 264 case IDC_CUT:
263 return !selection_.empty() && !is_root_node; 265 return !selection_.empty() && !is_root_node &&
266 (id == IDC_COPY || can_edit);
264 267
265 case IDC_PASTE: 268 case IDC_PASTE:
266 // Paste to selection from the Bookmark Bar, to parent_ everywhere else 269 // Paste to selection from the Bookmark Bar, to parent_ everywhere else
267 return (!selection_.empty() && 270 return can_edit &&
268 bookmark_utils::CanPasteFromClipboard(selection_[0])) || 271 ((!selection_.empty() &&
269 bookmark_utils::CanPasteFromClipboard(parent_); 272 bookmark_utils::CanPasteFromClipboard(selection_[0])) ||
273 bookmark_utils::CanPasteFromClipboard(parent_));
270 } 274 }
271 return true; 275 return true;
272 } 276 }
273 277
274 void BookmarkContextMenuControllerViews::BookmarkModelChanged() { 278 void BookmarkContextMenuControllerViews::BookmarkModelChanged() {
275 delegate_->CloseMenu(); 279 delegate_->CloseMenu();
276 } 280 }
277 281
278 BookmarkModel* BookmarkContextMenuControllerViews::RemoveModelObserver() { 282 BookmarkModel* BookmarkContextMenuControllerViews::RemoveModelObserver() {
279 BookmarkModel* model = model_; 283 BookmarkModel* model = model_;
280 model_->RemoveObserver(this); 284 model_->RemoveObserver(this);
281 model_ = NULL; 285 model_ = NULL;
282 return model; 286 return model;
283 } 287 }
284 288
285 bool BookmarkContextMenuControllerViews::HasURLs() const { 289 bool BookmarkContextMenuControllerViews::HasURLs() const {
286 for (size_t i = 0; i < selection_.size(); ++i) { 290 for (size_t i = 0; i < selection_.size(); ++i) {
287 if (bookmark_utils::NodeHasURLs(selection_[i])) 291 if (bookmark_utils::NodeHasURLs(selection_[i]))
288 return true; 292 return true;
289 } 293 }
290 return false; 294 return false;
291 } 295 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698