| 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_bookmark_manager_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" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 13 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_utils.h" | 14 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 15 #include "chrome/browser/extensions/extension_bookmark_helpers.h" | 15 #include "chrome/browser/bookmarks/bookmark_extension_api_constants.h" |
| 16 #include "chrome/browser/extensions/extension_bookmarks_module_constants.h" | 16 #include "chrome/browser/bookmarks/bookmark_extension_helpers.h" |
| 17 #include "chrome/browser/extensions/extension_event_router.h" | 17 #include "chrome/browser/extensions/extension_event_router.h" |
| 18 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 18 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 19 #include "chrome/browser/extensions/extension_web_ui.h" | 19 #include "chrome/browser/extensions/extension_web_ui.h" |
| 20 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 23 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 23 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/common/chrome_view_types.h" | 25 #include "chrome/common/chrome_view_types.h" |
| 26 #include "content/browser/renderer_host/render_view_host.h" | 26 #include "content/browser/renderer_host/render_view_host.h" |
| 27 #include "content/browser/tab_contents/tab_contents.h" | 27 #include "content/browser/tab_contents/tab_contents.h" |
| 28 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 | 30 |
| 31 namespace keys = extension_bookmarks_module_constants; | 31 namespace keys = bookmark_extension_api_constants; |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 // Returns a single bookmark node from the argument ID. | 35 // Returns a single bookmark node from the argument ID. |
| 36 // This returns NULL in case of failure. | 36 // This returns NULL in case of failure. |
| 37 const BookmarkNode* GetNodeFromArguments(BookmarkModel* model, | 37 const BookmarkNode* GetNodeFromArguments(BookmarkModel* model, |
| 38 const ListValue* args) { | 38 const ListValue* args) { |
| 39 std::string id_string; | 39 std::string id_string; |
| 40 if (!args->GetString(0, &id_string)) | 40 if (!args->GetString(0, &id_string)) |
| 41 return NULL; | 41 return NULL; |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 return false; | 458 return false; |
| 459 } | 459 } |
| 460 node = model->GetNodeByID(id); | 460 node = model->GetNodeByID(id); |
| 461 } | 461 } |
| 462 if (!node) { | 462 if (!node) { |
| 463 error_ = keys::kNoNodeError; | 463 error_ = keys::kNoNodeError; |
| 464 return false; | 464 return false; |
| 465 } | 465 } |
| 466 scoped_ptr<ListValue> json(new ListValue()); | 466 scoped_ptr<ListValue> json(new ListValue()); |
| 467 if (folders_only) { | 467 if (folders_only) { |
| 468 extension_bookmark_helpers::AddNodeFoldersOnly(node, | 468 bookmark_extension_helpers::AddNodeFoldersOnly(node, |
| 469 json.get(), | 469 json.get(), |
| 470 true); | 470 true); |
| 471 } else { | 471 } else { |
| 472 extension_bookmark_helpers::AddNode(node, json.get(), true); | 472 bookmark_extension_helpers::AddNode(node, json.get(), true); |
| 473 } | 473 } |
| 474 result_.reset(json.release()); | 474 result_.reset(json.release()); |
| 475 return true; | 475 return true; |
| 476 } | 476 } |
| 477 | 477 |
| 478 bool CanEditBookmarkManagerFunction::RunImpl() { | 478 bool CanEditBookmarkManagerFunction::RunImpl() { |
| 479 result_.reset(Value::CreateBooleanValue( | 479 result_.reset(Value::CreateBooleanValue( |
| 480 profile_->GetPrefs()->GetBoolean(prefs::kEditBookmarksEnabled))); | 480 profile_->GetPrefs()->GetBoolean(prefs::kEditBookmarksEnabled))); |
| 481 return true; | 481 return true; |
| 482 } | 482 } |
| 483 | 483 |
| 484 bool RecordLaunchBookmarkFunction::RunImpl() { | 484 bool RecordLaunchBookmarkFunction::RunImpl() { |
| 485 bookmark_utils::RecordBookmarkLaunch(bookmark_utils::LAUNCH_MANAGER); | 485 bookmark_utils::RecordBookmarkLaunch(bookmark_utils::LAUNCH_MANAGER); |
| 486 return true; | 486 return true; |
| 487 } | 487 } |
| OLD | NEW |