| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/bookmark_context_menu.h" | 5 #include "chrome/browser/gtk/bookmark_context_menu_gtk.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_editor.h" | 9 #include "chrome/browser/bookmarks/bookmark_editor.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_manager.h" | 10 #include "chrome/browser/bookmarks/bookmark_manager.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_utils.h" | 12 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 13 #include "chrome/browser/browser.h" | 13 #include "chrome/browser/browser.h" |
| 14 #include "chrome/browser/browser_list.h" | 14 #include "chrome/browser/browser_list.h" |
| 15 #include "chrome/browser/input_window_dialog.h" | 15 #include "chrome/browser/input_window_dialog.h" |
| 16 #include "chrome/browser/metrics/user_metrics.h" | 16 #include "chrome/browser/metrics/user_metrics.h" |
| 17 #include "chrome/browser/profile.h" | 17 #include "chrome/browser/profile.h" |
| 18 #include "chrome/browser/tab_contents/page_navigator.h" | 18 #include "chrome/browser/tab_contents/page_navigator.h" |
| 19 #include "chrome/browser/tab_contents/tab_contents.h" | 19 #include "chrome/browser/tab_contents/tab_contents.h" |
| 20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/common/pref_service.h" | 21 #include "chrome/common/pref_service.h" |
| 22 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 23 | 23 |
| 24 // TODO(port): Port these files. | |
| 25 #if defined(OS_WIN) | |
| 26 #include "views/window/window.h" | |
| 27 #endif | |
| 28 | |
| 29 namespace { | 24 namespace { |
| 30 | 25 |
| 31 // Returns true if the specified node is of type URL, or has a descendant | 26 // Returns true if the specified node is of type URL, or has a descendant |
| 32 // of type URL. | 27 // of type URL. |
| 33 bool NodeHasURLs(const BookmarkNode* node) { | 28 bool NodeHasURLs(const BookmarkNode* node) { |
| 34 if (node->is_url()) | 29 if (node->is_url()) |
| 35 return true; | 30 return true; |
| 36 | 31 |
| 37 for (int i = 0; i < node->GetChildCount(); ++i) { | 32 for (int i = 0; i < node->GetChildCount(); ++i) { |
| 38 if (NodeHasURLs(node->GetChild(i))) | 33 if (NodeHasURLs(node->GetChild(i))) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // InputWindowDialog::Delegate methods. | 94 // InputWindowDialog::Delegate methods. |
| 100 virtual bool IsValid(const std::wstring& text) { | 95 virtual bool IsValid(const std::wstring& text) { |
| 101 return !text.empty(); | 96 return !text.empty(); |
| 102 } | 97 } |
| 103 | 98 |
| 104 virtual void InputAccepted(const std::wstring& text) { | 99 virtual void InputAccepted(const std::wstring& text) { |
| 105 if (is_new_) { | 100 if (is_new_) { |
| 106 ALLOW_UNUSED const BookmarkNode* node = | 101 ALLOW_UNUSED const BookmarkNode* node = |
| 107 model_->AddGroup(node_, node_->GetChildCount(), text); | 102 model_->AddGroup(node_, node_->GetChildCount(), text); |
| 108 if (show_in_manager_) { | 103 if (show_in_manager_) { |
| 109 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) | |
| 110 BookmarkManager::SelectInTree(profile_, node); | 104 BookmarkManager::SelectInTree(profile_, node); |
| 111 #else | |
| 112 NOTIMPLEMENTED() << "BookmarkManager not yet implemented"; | |
| 113 #endif | |
| 114 } | 105 } |
| 115 } else { | 106 } else { |
| 116 model_->SetTitle(node_, text); | 107 model_->SetTitle(node_, text); |
| 117 } | 108 } |
| 118 } | 109 } |
| 119 | 110 |
| 120 virtual void InputCanceled() { | 111 virtual void InputCanceled() { |
| 121 } | 112 } |
| 122 | 113 |
| 123 // BookmarkModelObserver methods, all invoke ModelChanged and close the | 114 // BookmarkModelObserver methods, all invoke ModelChanged and close the |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 bool is_new_; | 167 bool is_new_; |
| 177 | 168 |
| 178 // If is_new_ is true and a new node is created, it is selected in the | 169 // If is_new_ is true and a new node is created, it is selected in the |
| 179 // bookmark manager. | 170 // bookmark manager. |
| 180 bool show_in_manager_; | 171 bool show_in_manager_; |
| 181 InputWindowDialog* dialog_; | 172 InputWindowDialog* dialog_; |
| 182 | 173 |
| 183 DISALLOW_COPY_AND_ASSIGN(EditFolderController); | 174 DISALLOW_COPY_AND_ASSIGN(EditFolderController); |
| 184 }; | 175 }; |
| 185 | 176 |
| 186 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) | |
| 187 // SelectOnCreationHandler ---------------------------------------------------- | 177 // SelectOnCreationHandler ---------------------------------------------------- |
| 188 | 178 |
| 189 // Used when adding a new bookmark. If a new bookmark is created it is selected | 179 // Used when adding a new bookmark. If a new bookmark is created it is selected |
| 190 // in the bookmark manager. | 180 // in the bookmark manager. |
| 191 class SelectOnCreationHandler : public BookmarkEditor::Handler { | 181 class SelectOnCreationHandler : public BookmarkEditor::Handler { |
| 192 public: | 182 public: |
| 193 explicit SelectOnCreationHandler(Profile* profile) : profile_(profile) { | 183 explicit SelectOnCreationHandler(Profile* profile) : profile_(profile) { |
| 194 } | 184 } |
| 195 | 185 |
| 196 virtual void NodeCreated(const BookmarkNode* new_node) { | 186 virtual void NodeCreated(const BookmarkNode* new_node) { |
| 197 BookmarkManager::SelectInTree(profile_, new_node); | 187 BookmarkManager::SelectInTree(profile_, new_node); |
| 198 } | 188 } |
| 199 | 189 |
| 200 private: | 190 private: |
| 201 Profile* profile_; | 191 Profile* profile_; |
| 202 | 192 |
| 203 DISALLOW_COPY_AND_ASSIGN(SelectOnCreationHandler); | 193 DISALLOW_COPY_AND_ASSIGN(SelectOnCreationHandler); |
| 204 }; | 194 }; |
| 205 #endif // #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) | |
| 206 | 195 |
| 207 } // namespace | 196 } // namespace |
| 208 | 197 |
| 209 // BookmarkContextMenu ------------------------------------------- | 198 // BookmarkContextMenuGtk ------------------------------------------- |
| 210 | 199 |
| 211 BookmarkContextMenu::BookmarkContextMenu( | 200 BookmarkContextMenuGtk::BookmarkContextMenuGtk( |
| 212 gfx::NativeView wnd, | 201 gfx::NativeView wnd, |
| 213 Profile* profile, | 202 Profile* profile, |
| 214 Browser* browser, | 203 Browser* browser, |
| 215 PageNavigator* navigator, | 204 PageNavigator* navigator, |
| 216 const BookmarkNode* parent, | 205 const BookmarkNode* parent, |
| 217 const std::vector<const BookmarkNode*>& selection, | 206 const std::vector<const BookmarkNode*>& selection, |
| 218 ConfigurationType configuration, | 207 ConfigurationType configuration, |
| 219 Delegate* delegate) | 208 Delegate* delegate) |
| 220 : wnd_(wnd), | 209 : wnd_(wnd), |
| 221 profile_(profile), | 210 profile_(profile), |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 | 273 |
| 285 if (configuration == BOOKMARK_BAR) { | 274 if (configuration == BOOKMARK_BAR) { |
| 286 AppendSeparator(); | 275 AppendSeparator(); |
| 287 AppendItem(IDS_BOOKMARK_MANAGER); | 276 AppendItem(IDS_BOOKMARK_MANAGER); |
| 288 AppendCheckboxItem(IDS_BOOMARK_BAR_ALWAYS_SHOW); | 277 AppendCheckboxItem(IDS_BOOMARK_BAR_ALWAYS_SHOW); |
| 289 } | 278 } |
| 290 | 279 |
| 291 model_->AddObserver(this); | 280 model_->AddObserver(this); |
| 292 } | 281 } |
| 293 | 282 |
| 294 BookmarkContextMenu::~BookmarkContextMenu() { | 283 BookmarkContextMenuGtk::~BookmarkContextMenuGtk() { |
| 295 if (model_) | 284 if (model_) |
| 296 model_->RemoveObserver(this); | 285 model_->RemoveObserver(this); |
| 297 } | 286 } |
| 298 | 287 |
| 299 void BookmarkContextMenu::DelegateDestroyed() { | 288 void BookmarkContextMenuGtk::PopupAsContext(guint32 event_time) { |
| 289 menu_->PopupAsContext(event_time); |
| 290 } |
| 291 |
| 292 void BookmarkContextMenuGtk::DelegateDestroyed() { |
| 300 delegate_ = NULL; | 293 delegate_ = NULL; |
| 301 } | 294 } |
| 302 | 295 |
| 303 void BookmarkContextMenu::ExecuteCommand(int id) { | 296 void BookmarkContextMenuGtk::ExecuteCommand(int id) { |
| 304 if (delegate_) | 297 if (delegate_) |
| 305 delegate_->WillExecuteCommand(); | 298 delegate_->WillExecuteCommand(); |
| 306 | 299 |
| 307 switch (id) { | 300 switch (id) { |
| 308 case IDS_BOOMARK_BAR_OPEN_ALL: | 301 case IDS_BOOMARK_BAR_OPEN_ALL: |
| 309 case IDS_BOOMARK_BAR_OPEN_ALL_INCOGNITO: | 302 case IDS_BOOMARK_BAR_OPEN_ALL_INCOGNITO: |
| 310 case IDS_BOOMARK_BAR_OPEN_ALL_NEW_WINDOW: { | 303 case IDS_BOOMARK_BAR_OPEN_ALL_NEW_WINDOW: { |
| 311 PageNavigator* navigator = browser_ ? | 304 PageNavigator* navigator = browser_ ? |
| 312 browser_->GetSelectedTabContents() : navigator_; | 305 browser_->GetSelectedTabContents() : navigator_; |
| 313 WindowOpenDisposition initial_disposition; | 306 WindowOpenDisposition initial_disposition; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 333 case IDS_BOOKMARK_BAR_RENAME_FOLDER: | 326 case IDS_BOOKMARK_BAR_RENAME_FOLDER: |
| 334 case IDS_BOOKMARK_BAR_EDIT: | 327 case IDS_BOOKMARK_BAR_EDIT: |
| 335 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_Edit", profile_); | 328 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_Edit", profile_); |
| 336 | 329 |
| 337 if (selection_.size() != 1) { | 330 if (selection_.size() != 1) { |
| 338 NOTREACHED(); | 331 NOTREACHED(); |
| 339 return; | 332 return; |
| 340 } | 333 } |
| 341 | 334 |
| 342 if (selection_[0]->is_url()) { | 335 if (selection_[0]->is_url()) { |
| 343 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) | |
| 344 BookmarkEditor::Configuration editor_config; | 336 BookmarkEditor::Configuration editor_config; |
| 345 if (configuration_ == BOOKMARK_BAR) | 337 if (configuration_ == BOOKMARK_BAR) |
| 346 editor_config = BookmarkEditor::SHOW_TREE; | 338 editor_config = BookmarkEditor::SHOW_TREE; |
| 347 else | 339 else |
| 348 editor_config = BookmarkEditor::NO_TREE; | 340 editor_config = BookmarkEditor::NO_TREE; |
| 349 BookmarkEditor::Show(wnd_, profile_, parent_, selection_[0], | 341 BookmarkEditor::Show(wnd_, profile_, parent_, selection_[0], |
| 350 editor_config, NULL); | 342 editor_config, NULL); |
| 351 #else | |
| 352 NOTIMPLEMENTED(); | |
| 353 #endif | |
| 354 } else { | 343 } else { |
| 355 EditFolderController::Show(profile_, wnd_, selection_[0], false, | 344 EditFolderController::Show(profile_, wnd_, selection_[0], false, |
| 356 false); | 345 false); |
| 357 } | 346 } |
| 358 break; | 347 break; |
| 359 | 348 |
| 360 case IDS_BOOKMARK_BAR_REMOVE: { | 349 case IDS_BOOKMARK_BAR_REMOVE: { |
| 361 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_Remove", profile_); | 350 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_Remove", profile_); |
| 362 BookmarkModel* model = RemoveModelObserver(); | 351 BookmarkModel* model = RemoveModelObserver(); |
| 363 | 352 |
| 364 for (size_t i = 0; i < selection_.size(); ++i) { | 353 for (size_t i = 0; i < selection_.size(); ++i) { |
| 365 model->Remove(selection_[i]->GetParent(), | 354 model->Remove(selection_[i]->GetParent(), |
| 366 selection_[i]->GetParent()->IndexOfChild(selection_[i])); | 355 selection_[i]->GetParent()->IndexOfChild(selection_[i])); |
| 367 } | 356 } |
| 368 selection_.clear(); | 357 selection_.clear(); |
| 369 break; | 358 break; |
| 370 } | 359 } |
| 371 | 360 |
| 372 case IDS_BOOMARK_BAR_ADD_NEW_BOOKMARK: { | 361 case IDS_BOOMARK_BAR_ADD_NEW_BOOKMARK: { |
| 373 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_Add", profile_); | 362 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_Add", profile_); |
| 374 | 363 |
| 375 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) | |
| 376 BookmarkEditor::Configuration editor_config; | 364 BookmarkEditor::Configuration editor_config; |
| 377 BookmarkEditor::Handler* handler = NULL; | 365 BookmarkEditor::Handler* handler = NULL; |
| 378 if (configuration_ == BOOKMARK_BAR) { | 366 if (configuration_ == BOOKMARK_BAR) { |
| 379 editor_config = BookmarkEditor::SHOW_TREE; | 367 editor_config = BookmarkEditor::SHOW_TREE; |
| 380 } else { | 368 } else { |
| 381 editor_config = BookmarkEditor::NO_TREE; | 369 editor_config = BookmarkEditor::NO_TREE; |
| 382 // This is owned by the BookmarkEditorView. | 370 // This is owned by the BookmarkEditorView. |
| 383 handler = new SelectOnCreationHandler(profile_); | 371 handler = new SelectOnCreationHandler(profile_); |
| 384 } | 372 } |
| 385 BookmarkEditor::Show(wnd_, profile_, GetParentForNewNodes(), NULL, | 373 BookmarkEditor::Show(wnd_, profile_, GetParentForNewNodes(), NULL, |
| 386 editor_config, handler); | 374 editor_config, handler); |
| 387 #else | |
| 388 NOTIMPLEMENTED(); | |
| 389 #endif | |
| 390 break; | 375 break; |
| 391 } | 376 } |
| 392 | 377 |
| 393 case IDS_BOOMARK_BAR_NEW_FOLDER: { | 378 case IDS_BOOMARK_BAR_NEW_FOLDER: { |
| 394 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_NewFolder", | 379 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_NewFolder", |
| 395 profile_); | 380 profile_); |
| 396 EditFolderController::Show(profile_, wnd_, GetParentForNewNodes(), | 381 EditFolderController::Show(profile_, wnd_, GetParentForNewNodes(), |
| 397 true, (configuration_ != BOOKMARK_BAR)); | 382 true, (configuration_ != BOOKMARK_BAR)); |
| 398 break; | 383 break; |
| 399 } | 384 } |
| 400 | 385 |
| 401 case IDS_BOOMARK_BAR_ALWAYS_SHOW: | 386 case IDS_BOOMARK_BAR_ALWAYS_SHOW: |
| 402 bookmark_utils::ToggleWhenVisible(profile_); | 387 bookmark_utils::ToggleWhenVisible(profile_); |
| 403 break; | 388 break; |
| 404 | 389 |
| 405 case IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER: | 390 case IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER: |
| 406 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_ShowInFolder", | 391 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_ShowInFolder", |
| 407 profile_); | 392 profile_); |
| 408 | 393 |
| 409 if (selection_.size() != 1) { | 394 if (selection_.size() != 1) { |
| 410 NOTREACHED(); | 395 NOTREACHED(); |
| 411 return; | 396 return; |
| 412 } | 397 } |
| 413 | 398 |
| 414 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) | |
| 415 BookmarkManager::SelectInTree(profile_, selection_[0]); | 399 BookmarkManager::SelectInTree(profile_, selection_[0]); |
| 416 #else | |
| 417 NOTIMPLEMENTED() << "Bookmark Manager not implemented"; | |
| 418 #endif | |
| 419 break; | 400 break; |
| 420 | 401 |
| 421 case IDS_BOOKMARK_MANAGER: | 402 case IDS_BOOKMARK_MANAGER: |
| 422 UserMetrics::RecordAction(L"ShowBookmarkManager", profile_); | 403 UserMetrics::RecordAction(L"ShowBookmarkManager", profile_); |
| 423 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) | |
| 424 BookmarkManager::Show(profile_); | 404 BookmarkManager::Show(profile_); |
| 425 #else | |
| 426 NOTIMPLEMENTED() << "Bookmark Manager not implemented"; | |
| 427 #endif | |
| 428 break; | 405 break; |
| 429 | 406 |
| 430 case IDS_BOOKMARK_MANAGER_SORT: | 407 case IDS_BOOKMARK_MANAGER_SORT: |
| 431 UserMetrics::RecordAction(L"BookmarkManager_Sort", profile_); | 408 UserMetrics::RecordAction(L"BookmarkManager_Sort", profile_); |
| 432 model_->SortChildren(parent_); | 409 model_->SortChildren(parent_); |
| 433 break; | 410 break; |
| 434 | 411 |
| 435 case IDS_COPY: | 412 case IDS_COPY: |
| 436 case IDS_CUT: | 413 case IDS_CUT: |
| 437 bookmark_utils::CopyToClipboard(profile_->GetBookmarkModel(), | 414 bookmark_utils::CopyToClipboard(profile_->GetBookmarkModel(), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 450 bookmark_utils::PasteFromClipboard(profile_->GetBookmarkModel(), | 427 bookmark_utils::PasteFromClipboard(profile_->GetBookmarkModel(), |
| 451 parent_, index); | 428 parent_, index); |
| 452 break; | 429 break; |
| 453 } | 430 } |
| 454 | 431 |
| 455 default: | 432 default: |
| 456 NOTREACHED(); | 433 NOTREACHED(); |
| 457 } | 434 } |
| 458 } | 435 } |
| 459 | 436 |
| 460 bool BookmarkContextMenu::IsItemChecked(int id) const { | 437 bool BookmarkContextMenuGtk::IsItemChecked(int id) const { |
| 461 DCHECK(id == IDS_BOOMARK_BAR_ALWAYS_SHOW); | 438 DCHECK(id == IDS_BOOMARK_BAR_ALWAYS_SHOW); |
| 462 return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | 439 return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
| 463 } | 440 } |
| 464 | 441 |
| 465 bool BookmarkContextMenu::IsCommandEnabled(int id) const { | 442 bool BookmarkContextMenuGtk::IsCommandEnabled(int id) const { |
| 466 bool is_root_node = | 443 bool is_root_node = |
| 467 (selection_.size() == 1 && | 444 (selection_.size() == 1 && |
| 468 selection_[0]->GetParent() == model_->root_node()); | 445 selection_[0]->GetParent() == model_->root_node()); |
| 469 switch (id) { | 446 switch (id) { |
| 470 case IDS_BOOMARK_BAR_OPEN_INCOGNITO: | 447 case IDS_BOOMARK_BAR_OPEN_INCOGNITO: |
| 471 return !profile_->IsOffTheRecord(); | 448 return !profile_->IsOffTheRecord(); |
| 472 | 449 |
| 473 case IDS_BOOMARK_BAR_OPEN_ALL_INCOGNITO: | 450 case IDS_BOOMARK_BAR_OPEN_ALL_INCOGNITO: |
| 474 return HasURLs() && !profile_->IsOffTheRecord(); | 451 return HasURLs() && !profile_->IsOffTheRecord(); |
| 475 | 452 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 500 case IDS_CUT: | 477 case IDS_CUT: |
| 501 return selection_.size() > 0 && !is_root_node; | 478 return selection_.size() > 0 && !is_root_node; |
| 502 | 479 |
| 503 case IDS_PASTE: | 480 case IDS_PASTE: |
| 504 // Always paste to parent. | 481 // Always paste to parent. |
| 505 return bookmark_utils::CanPasteFromClipboard(parent_); | 482 return bookmark_utils::CanPasteFromClipboard(parent_); |
| 506 } | 483 } |
| 507 return true; | 484 return true; |
| 508 } | 485 } |
| 509 | 486 |
| 510 void BookmarkContextMenu::BookmarkModelBeingDeleted(BookmarkModel* model) { | 487 void BookmarkContextMenuGtk::BookmarkModelBeingDeleted(BookmarkModel* model) { |
| 511 ModelChanged(); | 488 ModelChanged(); |
| 512 } | 489 } |
| 513 | 490 |
| 514 void BookmarkContextMenu::BookmarkNodeMoved(BookmarkModel* model, | 491 void BookmarkContextMenuGtk::BookmarkNodeMoved(BookmarkModel* model, |
| 515 const BookmarkNode* old_parent, | 492 const BookmarkNode* old_parent, |
| 516 int old_index, | 493 int old_index, |
| 517 const BookmarkNode* new_parent, | 494 const BookmarkNode* new_parent, |
| 518 int new_index) { | 495 int new_index) { |
| 519 ModelChanged(); | 496 ModelChanged(); |
| 520 } | 497 } |
| 521 | 498 |
| 522 void BookmarkContextMenu::BookmarkNodeAdded(BookmarkModel* model, | 499 void BookmarkContextMenuGtk::BookmarkNodeAdded(BookmarkModel* model, |
| 523 const BookmarkNode* parent, | 500 const BookmarkNode* parent, |
| 524 int index) { | 501 int index) { |
| 525 ModelChanged(); | 502 ModelChanged(); |
| 526 } | 503 } |
| 527 | 504 |
| 528 void BookmarkContextMenu::BookmarkNodeRemoved(BookmarkModel* model, | 505 void BookmarkContextMenuGtk::BookmarkNodeRemoved(BookmarkModel* model, |
| 529 const BookmarkNode* parent, | 506 const BookmarkNode* parent, |
| 530 int index, | 507 int index, |
| 531 const BookmarkNode* node) { | 508 const BookmarkNode* node) { |
| 532 ModelChanged(); | 509 ModelChanged(); |
| 533 } | 510 } |
| 534 | 511 |
| 535 void BookmarkContextMenu::BookmarkNodeChanged(BookmarkModel* model, | 512 void BookmarkContextMenuGtk::BookmarkNodeChanged(BookmarkModel* model, |
| 536 const BookmarkNode* node) { | 513 const BookmarkNode* node) { |
| 537 ModelChanged(); | 514 ModelChanged(); |
| 538 } | 515 } |
| 539 | 516 |
| 540 void BookmarkContextMenu::BookmarkNodeChildrenReordered( | 517 void BookmarkContextMenuGtk::BookmarkNodeChildrenReordered( |
| 541 BookmarkModel* model, const BookmarkNode* node) { | 518 BookmarkModel* model, const BookmarkNode* node) { |
| 542 ModelChanged(); | 519 ModelChanged(); |
| 543 } | 520 } |
| 544 | 521 |
| 545 void BookmarkContextMenu::ModelChanged() { | 522 void BookmarkContextMenuGtk::ModelChanged() { |
| 546 menu_->Cancel(); | 523 menu_->Cancel(); |
| 547 } | 524 } |
| 548 | 525 |
| 549 BookmarkModel* BookmarkContextMenu::RemoveModelObserver() { | 526 void BookmarkContextMenuGtk::CreateMenuObject() { |
| 527 menu_.reset(new MenuGtk(this, false)); |
| 528 } |
| 529 |
| 530 void BookmarkContextMenuGtk::AppendItem(int id) { |
| 531 menu_->AppendMenuItemWithLabel(id, l10n_util::GetStringUTF8(id)); |
| 532 } |
| 533 |
| 534 void BookmarkContextMenuGtk::AppendItem(int id, int localization_id) { |
| 535 menu_->AppendMenuItemWithLabel(id, l10n_util::GetStringUTF8(localization_id)); |
| 536 } |
| 537 |
| 538 void BookmarkContextMenuGtk::AppendSeparator() { |
| 539 menu_->AppendSeparator(); |
| 540 } |
| 541 |
| 542 void BookmarkContextMenuGtk::AppendCheckboxItem(int id) { |
| 543 menu_->AppendCheckMenuItemWithLabel(id, l10n_util::GetStringUTF8(id)); |
| 544 } |
| 545 |
| 546 BookmarkModel* BookmarkContextMenuGtk::RemoveModelObserver() { |
| 550 BookmarkModel* model = model_; | 547 BookmarkModel* model = model_; |
| 551 model_->RemoveObserver(this); | 548 model_->RemoveObserver(this); |
| 552 model_ = NULL; | 549 model_ = NULL; |
| 553 return model; | 550 return model; |
| 554 } | 551 } |
| 555 | 552 |
| 556 bool BookmarkContextMenu::HasURLs() const { | 553 bool BookmarkContextMenuGtk::HasURLs() const { |
| 557 for (size_t i = 0; i < selection_.size(); ++i) { | 554 for (size_t i = 0; i < selection_.size(); ++i) { |
| 558 if (NodeHasURLs(selection_[i])) | 555 if (NodeHasURLs(selection_[i])) |
| 559 return true; | 556 return true; |
| 560 } | 557 } |
| 561 return false; | 558 return false; |
| 562 } | 559 } |
| 563 | 560 |
| 564 const BookmarkNode* BookmarkContextMenu::GetParentForNewNodes() const { | 561 const BookmarkNode* BookmarkContextMenuGtk::GetParentForNewNodes() const { |
| 565 return (selection_.size() == 1 && selection_[0]->is_folder()) ? | 562 return (selection_.size() == 1 && selection_[0]->is_folder()) ? |
| 566 selection_[0] : parent_; | 563 selection_[0] : parent_; |
| 567 } | 564 } |
| OLD | NEW |