Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Side by Side Diff: chrome/browser/extensions/api/bookmarks/bookmarks_api.cc

Issue 12340111: Introduce //components/user_prefs, use to eliminate c/b/prefs dependency in Autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge of LKGR Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 21 matching lines...) Expand all
32 #include "chrome/browser/extensions/extension_system.h" 32 #include "chrome/browser/extensions/extension_system.h"
33 #include "chrome/browser/extensions/extensions_quota_service.h" 33 #include "chrome/browser/extensions/extensions_quota_service.h"
34 #include "chrome/browser/importer/importer_data_types.h" 34 #include "chrome/browser/importer/importer_data_types.h"
35 #include "chrome/browser/importer/importer_host.h" 35 #include "chrome/browser/importer/importer_host.h"
36 #include "chrome/browser/profiles/profile.h" 36 #include "chrome/browser/profiles/profile.h"
37 #include "chrome/browser/ui/chrome_select_file_policy.h" 37 #include "chrome/browser/ui/chrome_select_file_policy.h"
38 #include "chrome/common/chrome_notification_types.h" 38 #include "chrome/common/chrome_notification_types.h"
39 #include "chrome/common/chrome_paths.h" 39 #include "chrome/common/chrome_paths.h"
40 #include "chrome/common/extensions/api/bookmarks.h" 40 #include "chrome/common/extensions/api/bookmarks.h"
41 #include "chrome/common/pref_names.h" 41 #include "chrome/common/pref_names.h"
42 #include "components/user_prefs/user_prefs.h"
42 #include "content/public/browser/notification_service.h" 43 #include "content/public/browser/notification_service.h"
43 #include "grit/generated_resources.h" 44 #include "grit/generated_resources.h"
44 #include "ui/base/l10n/l10n_util.h" 45 #include "ui/base/l10n/l10n_util.h"
45 46
46 namespace extensions { 47 namespace extensions {
47 48
48 namespace keys = bookmark_api_constants; 49 namespace keys = bookmark_api_constants;
49 namespace bookmarks = api::bookmarks; 50 namespace bookmarks = api::bookmarks;
50 51
51 using base::TimeDelta; 52 using base::TimeDelta;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 bool BookmarksFunction::GetBookmarkIdAsInt64(const std::string& id_string, 110 bool BookmarksFunction::GetBookmarkIdAsInt64(const std::string& id_string,
110 int64* id) { 111 int64* id) {
111 if (base::StringToInt64(id_string, id)) 112 if (base::StringToInt64(id_string, id))
112 return true; 113 return true;
113 114
114 error_ = keys::kInvalidIdError; 115 error_ = keys::kInvalidIdError;
115 return false; 116 return false;
116 } 117 }
117 118
118 bool BookmarksFunction::EditBookmarksEnabled() { 119 bool BookmarksFunction::EditBookmarksEnabled() {
119 PrefService* prefs = PrefServiceFromBrowserContext(profile_); 120 PrefService* prefs = components::UserPrefs::Get(profile_);
120 if (prefs->GetBoolean(prefs::kEditBookmarksEnabled)) 121 if (prefs->GetBoolean(prefs::kEditBookmarksEnabled))
121 return true; 122 return true;
122 error_ = keys::kEditBookmarksDisabled; 123 error_ = keys::kEditBookmarksDisabled;
123 return false; 124 return false;
124 } 125 }
125 126
126 void BookmarksFunction::BookmarkModelChanged() { 127 void BookmarksFunction::BookmarkModelChanged() {
127 } 128 }
128 129
129 void BookmarksFunction::Loaded(BookmarkModel* model, bool ids_reassigned) { 130 void BookmarksFunction::Loaded(BookmarkModel* model, bool ids_reassigned) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 bookmark_api_helpers::AddNode(node, &nodes, true); 425 bookmark_api_helpers::AddNode(node, &nodes, true);
425 results_ = bookmarks::GetSubTree::Results::Create(nodes); 426 results_ = bookmarks::GetSubTree::Results::Create(nodes);
426 return true; 427 return true;
427 } 428 }
428 429
429 bool BookmarksSearchFunction::RunImpl() { 430 bool BookmarksSearchFunction::RunImpl() {
430 scoped_ptr<bookmarks::Search::Params> params( 431 scoped_ptr<bookmarks::Search::Params> params(
431 bookmarks::Search::Params::Create(*args_)); 432 bookmarks::Search::Params::Create(*args_));
432 EXTENSION_FUNCTION_VALIDATE(params.get()); 433 EXTENSION_FUNCTION_VALIDATE(params.get());
433 434
434 PrefService* prefs = PrefServiceFromBrowserContext(profile_); 435 PrefService* prefs = components::UserPrefs::Get(profile_);
435 std::string lang = prefs->GetString(prefs::kAcceptLanguages); 436 std::string lang = prefs->GetString(prefs::kAcceptLanguages);
436 std::vector<const BookmarkNode*> nodes; 437 std::vector<const BookmarkNode*> nodes;
437 bookmark_utils::GetBookmarksContainingText( 438 bookmark_utils::GetBookmarksContainingText(
438 BookmarkModelFactory::GetForProfile(profile()), 439 BookmarkModelFactory::GetForProfile(profile()),
439 UTF8ToUTF16(params->query), 440 UTF8ToUTF16(params->query),
440 std::numeric_limits<int>::max(), 441 std::numeric_limits<int>::max(),
441 lang, 442 lang,
442 &nodes); 443 &nodes);
443 444
444 std::vector<linked_ptr<BookmarkTreeNode> > tree_nodes; 445 std::vector<linked_ptr<BookmarkTreeNode> > tree_nodes;
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 #if !defined(OS_ANDROID) 996 #if !defined(OS_ANDROID)
996 // Android does not have support for the standard exporter. 997 // Android does not have support for the standard exporter.
997 // TODO(jgreenwald): remove ifdef once extensions are no longer built on 998 // TODO(jgreenwald): remove ifdef once extensions are no longer built on
998 // Android. 999 // Android.
999 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); 1000 bookmark_html_writer::WriteBookmarks(profile(), path, NULL);
1000 #endif 1001 #endif
1001 Release(); // Balanced in BookmarksIOFunction::SelectFile() 1002 Release(); // Balanced in BookmarksIOFunction::SelectFile()
1002 } 1003 }
1003 1004
1004 } // namespace extensions 1005 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698