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/extensions/extension_bookmarks_module.h" | 5 #include "chrome/browser/extensions/extension_bookmarks_module.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/i18n/file_util_icu.h" | 8 #include "base/i18n/file_util_icu.h" |
9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 | 514 |
515 DictionaryValue* destination; | 515 DictionaryValue* destination; |
516 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &destination)); | 516 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &destination)); |
517 | 517 |
518 BookmarkModel* model = profile()->GetBookmarkModel(); | 518 BookmarkModel* model = profile()->GetBookmarkModel(); |
519 const BookmarkNode* node = model->GetNodeByID(ids.front()); | 519 const BookmarkNode* node = model->GetNodeByID(ids.front()); |
520 if (!node) { | 520 if (!node) { |
521 error_ = keys::kNoNodeError; | 521 error_ = keys::kNoNodeError; |
522 return false; | 522 return false; |
523 } | 523 } |
524 if (node == model->root_node() || | 524 if (model->is_permanent_node(node)) { |
525 node == model->other_node() || | |
526 node == model->GetBookmarkBarNode()) { | |
527 error_ = keys::kModifySpecialError; | 525 error_ = keys::kModifySpecialError; |
528 return false; | 526 return false; |
529 } | 527 } |
530 | 528 |
531 const BookmarkNode* parent = NULL; | 529 const BookmarkNode* parent = NULL; |
532 if (!destination->HasKey(keys::kParentIdKey)) { | 530 if (!destination->HasKey(keys::kParentIdKey)) { |
533 // Optional, defaults to current parent. | 531 // Optional, defaults to current parent. |
534 parent = node->parent(); | 532 parent = node->parent(); |
535 } else { | 533 } else { |
536 std::string parentId_string; | 534 std::string parentId_string; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 error_ = keys::kInvalidUrlError; | 606 error_ = keys::kInvalidUrlError; |
609 return false; | 607 return false; |
610 } | 608 } |
611 | 609 |
612 BookmarkModel* model = profile()->GetBookmarkModel(); | 610 BookmarkModel* model = profile()->GetBookmarkModel(); |
613 const BookmarkNode* node = model->GetNodeByID(ids.front()); | 611 const BookmarkNode* node = model->GetNodeByID(ids.front()); |
614 if (!node) { | 612 if (!node) { |
615 error_ = keys::kNoNodeError; | 613 error_ = keys::kNoNodeError; |
616 return false; | 614 return false; |
617 } | 615 } |
618 if (node == model->root_node() || | 616 if (model->is_permanent_node(node)) { |
619 node == model->other_node() || | |
620 node == model->GetBookmarkBarNode()) { | |
621 error_ = keys::kModifySpecialError; | 617 error_ = keys::kModifySpecialError; |
622 return false; | 618 return false; |
623 } | 619 } |
624 if (has_title) | 620 if (has_title) |
625 model->SetTitle(node, title); | 621 model->SetTitle(node, title); |
626 if (!url.is_empty()) | 622 if (!url.is_empty()) |
627 model->SetURL(node, url); | 623 model->SetURL(node, url); |
628 | 624 |
629 DictionaryValue* ret = | 625 DictionaryValue* ret = |
630 extension_bookmark_helpers::GetNodeDictionary(node, false, false); | 626 extension_bookmark_helpers::GetNodeDictionary(node, false, false); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); | 904 SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE); |
909 return true; | 905 return true; |
910 } | 906 } |
911 | 907 |
912 void ExportBookmarksFunction::FileSelected(const FilePath& path, | 908 void ExportBookmarksFunction::FileSelected(const FilePath& path, |
913 int index, | 909 int index, |
914 void* params) { | 910 void* params) { |
915 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); | 911 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); |
916 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 912 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
917 } | 913 } |
OLD | NEW |