OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/api/bookmarks/bookmarks_api.h" | 5 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 if (details.url.get()) | 173 if (details.url.get()) |
174 url_string = *details.url.get(); | 174 url_string = *details.url.get(); |
175 | 175 |
176 GURL url(url_string); | 176 GURL url(url_string); |
177 if (!url_string.empty() && !url.is_valid()) { | 177 if (!url_string.empty() && !url.is_valid()) { |
178 error_ = keys::kInvalidUrlError; | 178 error_ = keys::kInvalidUrlError; |
179 return NULL; | 179 return NULL; |
180 } | 180 } |
181 | 181 |
182 const BookmarkNode* node; | 182 const BookmarkNode* node; |
183 if (url_string.length()) | 183 if (url_string.length()) { |
184 node = model->AddURLWithCreationTimeAndMetaInfo( | 184 node = model->AddURLWithCreationTimeAndMetaInfo( |
185 parent, index, title, url, base::Time::Now(), meta_info); | 185 parent, index, title, url, base::Time::Now(), meta_info); |
186 else | 186 } else { |
187 node = model->AddFolderWithMetaInfo(parent, index, title, meta_info); | 187 node = model->AddFolderWithMetaInfo(parent, index, title, meta_info); |
| 188 model->SetDateFolderModified(parent, base::Time::Now()); |
| 189 } |
| 190 |
188 DCHECK(node); | 191 DCHECK(node); |
189 if (!node) { | |
190 error_ = keys::kNoNodeError; | |
191 return NULL; | |
192 } | |
193 | 192 |
194 return node; | 193 return node; |
195 } | 194 } |
196 | 195 |
197 bool BookmarksFunction::EditBookmarksEnabled() { | 196 bool BookmarksFunction::EditBookmarksEnabled() { |
198 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); | 197 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); |
199 if (prefs->GetBoolean(::bookmarks::prefs::kEditBookmarksEnabled)) | 198 if (prefs->GetBoolean(::bookmarks::prefs::kEditBookmarksEnabled)) |
200 return true; | 199 return true; |
201 error_ = keys::kEditBookmarksDisabled; | 200 error_ = keys::kEditBookmarksDisabled; |
202 return false; | 201 return false; |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 } | 844 } |
846 | 845 |
847 void BookmarksExportFunction::FileSelected(const base::FilePath& path, | 846 void BookmarksExportFunction::FileSelected(const base::FilePath& path, |
848 int index, | 847 int index, |
849 void* params) { | 848 void* params) { |
850 bookmark_html_writer::WriteBookmarks(GetProfile(), path, NULL); | 849 bookmark_html_writer::WriteBookmarks(GetProfile(), path, NULL); |
851 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 850 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
852 } | 851 } |
853 | 852 |
854 } // namespace extensions | 853 } // namespace extensions |
OLD | NEW |