| 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/bookmarks/bookmark_manager_extension_api.h" | 5 #include "chrome/browser/bookmarks/bookmark_manager_extension_api.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 bool CanPasteBookmarkManagerFunction::RunImpl() { | 273 bool CanPasteBookmarkManagerFunction::RunImpl() { |
| 274 if (!EditBookmarksEnabled()) | 274 if (!EditBookmarksEnabled()) |
| 275 return false; | 275 return false; |
| 276 BookmarkModel* model = profile()->GetBookmarkModel(); | 276 BookmarkModel* model = profile()->GetBookmarkModel(); |
| 277 const BookmarkNode* parent_node = GetNodeFromArguments(model, args_.get()); | 277 const BookmarkNode* parent_node = GetNodeFromArguments(model, args_.get()); |
| 278 if (!parent_node) { | 278 if (!parent_node) { |
| 279 error_ = keys::kNoParentError; | 279 error_ = keys::kNoParentError; |
| 280 return false; | 280 return false; |
| 281 } | 281 } |
| 282 bool can_paste = bookmark_utils::CanPasteFromClipboard(parent_node); | 282 bool can_paste = bookmark_utils::CanPasteFromClipboard(parent_node); |
| 283 result_.reset(Value::CreateBooleanValue(can_paste)); | 283 SetResult(Value::CreateBooleanValue(can_paste)); |
| 284 return true; | 284 return true; |
| 285 } | 285 } |
| 286 | 286 |
| 287 bool SortChildrenBookmarkManagerFunction::RunImpl() { | 287 bool SortChildrenBookmarkManagerFunction::RunImpl() { |
| 288 if (!EditBookmarksEnabled()) | 288 if (!EditBookmarksEnabled()) |
| 289 return false; | 289 return false; |
| 290 BookmarkModel* model = profile()->GetBookmarkModel(); | 290 BookmarkModel* model = profile()->GetBookmarkModel(); |
| 291 const BookmarkNode* parent_node = GetNodeFromArguments(model, args_.get()); | 291 const BookmarkNode* parent_node = GetNodeFromArguments(model, args_.get()); |
| 292 if (!parent_node) { | 292 if (!parent_node) { |
| 293 error_ = keys::kNoParentError; | 293 error_ = keys::kNoParentError; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_SEARCH)); | 364 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_SEARCH)); |
| 365 localized_strings->SetString("bookmark_all_tabs", | 365 localized_strings->SetString("bookmark_all_tabs", |
| 366 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_BOOKMARK_ALL_TABS)); | 366 l10n_util::GetStringUTF16(IDS_BOOKMARK_MANAGER_BOOKMARK_ALL_TABS)); |
| 367 localized_strings->SetString("save", | 367 localized_strings->SetString("save", |
| 368 l10n_util::GetStringUTF16(IDS_SAVE)); | 368 l10n_util::GetStringUTF16(IDS_SAVE)); |
| 369 localized_strings->SetString("cancel", | 369 localized_strings->SetString("cancel", |
| 370 l10n_util::GetStringUTF16(IDS_CANCEL)); | 370 l10n_util::GetStringUTF16(IDS_CANCEL)); |
| 371 | 371 |
| 372 ChromeURLDataManager::DataSource::SetFontAndTextDirection(localized_strings); | 372 ChromeURLDataManager::DataSource::SetFontAndTextDirection(localized_strings); |
| 373 | 373 |
| 374 result_.reset(localized_strings); | 374 SetResult(localized_strings); |
| 375 | 375 |
| 376 // This is needed because unlike the rest of these functions, this class | 376 // This is needed because unlike the rest of these functions, this class |
| 377 // inherits from AsyncFunction directly, rather than BookmarkFunction. | 377 // inherits from AsyncFunction directly, rather than BookmarkFunction. |
| 378 SendResponse(true); | 378 SendResponse(true); |
| 379 | 379 |
| 380 return true; | 380 return true; |
| 381 } | 381 } |
| 382 | 382 |
| 383 bool StartDragBookmarkManagerFunction::RunImpl() { | 383 bool StartDragBookmarkManagerFunction::RunImpl() { |
| 384 if (!EditBookmarksEnabled()) | 384 if (!EditBookmarksEnabled()) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 return false; | 483 return false; |
| 484 } | 484 } |
| 485 scoped_ptr<ListValue> json(new ListValue()); | 485 scoped_ptr<ListValue> json(new ListValue()); |
| 486 if (folders_only) { | 486 if (folders_only) { |
| 487 bookmark_extension_helpers::AddNodeFoldersOnly(node, | 487 bookmark_extension_helpers::AddNodeFoldersOnly(node, |
| 488 json.get(), | 488 json.get(), |
| 489 true); | 489 true); |
| 490 } else { | 490 } else { |
| 491 bookmark_extension_helpers::AddNode(node, json.get(), true); | 491 bookmark_extension_helpers::AddNode(node, json.get(), true); |
| 492 } | 492 } |
| 493 result_.reset(json.release()); | 493 SetResult(json.release()); |
| 494 return true; | 494 return true; |
| 495 } | 495 } |
| 496 | 496 |
| 497 bool CanEditBookmarkManagerFunction::RunImpl() { | 497 bool CanEditBookmarkManagerFunction::RunImpl() { |
| 498 result_.reset(Value::CreateBooleanValue( | 498 SetResult(Value::CreateBooleanValue( |
| 499 profile_->GetPrefs()->GetBoolean(prefs::kEditBookmarksEnabled))); | 499 profile_->GetPrefs()->GetBoolean(prefs::kEditBookmarksEnabled))); |
| 500 return true; | 500 return true; |
| 501 } | 501 } |
| 502 | 502 |
| 503 bool RecordLaunchBookmarkFunction::RunImpl() { | 503 bool RecordLaunchBookmarkFunction::RunImpl() { |
| 504 bookmark_utils::RecordBookmarkLaunch(bookmark_utils::LAUNCH_MANAGER); | 504 bookmark_utils::RecordBookmarkLaunch(bookmark_utils::LAUNCH_MANAGER); |
| 505 return true; | 505 return true; |
| 506 } | 506 } |
| 507 | 507 |
| 508 bool CanOpenNewWindowsBookmarkFunction::RunImpl() { | 508 bool CanOpenNewWindowsBookmarkFunction::RunImpl() { |
| 509 bool can_open_new_windows = true; | 509 bool can_open_new_windows = true; |
| 510 | 510 |
| 511 #if defined(OS_WIN) | 511 #if defined(OS_WIN) |
| 512 if (base::win::IsMetroProcess()) | 512 if (base::win::IsMetroProcess()) |
| 513 can_open_new_windows = false; | 513 can_open_new_windows = false; |
| 514 #endif // OS_WIN | 514 #endif // OS_WIN |
| 515 | 515 |
| 516 result_.reset(Value::CreateBooleanValue(can_open_new_windows)); | 516 SetResult(Value::CreateBooleanValue(can_open_new_windows)); |
| 517 return true; | 517 return true; |
| 518 } | 518 } |
| OLD | NEW |