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

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

Issue 171813010: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 1). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: browser_context_ Created 6 years, 10 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" 14 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
15 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" 15 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
16 #include "chrome/browser/extensions/chrome_extension_function.h" 16 #include "chrome/browser/extensions/chrome_extension_function.h"
17 #include "extensions/browser/event_router.h" 17 #include "extensions/browser/event_router.h"
18 #include "ui/shell_dialogs/select_file_dialog.h" 18 #include "ui/shell_dialogs/select_file_dialog.h"
19 19
20 class Profile;
21
22 namespace base { 20 namespace base {
23 class FilePath; 21 class FilePath;
24 class ListValue; 22 class ListValue;
25 } 23 }
26 24
25 namespace content {
26 class BrowserContext;
27 }
28
27 namespace extensions { 29 namespace extensions {
28 30
29 // Observes BookmarkModel and then routes the notifications as events to 31 // Observes BookmarkModel and then routes the notifications as events to
30 // the extension system. 32 // the extension system.
31 class BookmarkEventRouter : public BookmarkModelObserver { 33 class BookmarkEventRouter : public BookmarkModelObserver {
32 public: 34 public:
33 BookmarkEventRouter(Profile* profile, BookmarkModel* model); 35 BookmarkEventRouter(content::BrowserContext* context, BookmarkModel* model);
34 virtual ~BookmarkEventRouter(); 36 virtual ~BookmarkEventRouter();
35 37
36 // BookmarkModelObserver: 38 // BookmarkModelObserver:
37 virtual void BookmarkModelLoaded(BookmarkModel* model, 39 virtual void BookmarkModelLoaded(BookmarkModel* model,
38 bool ids_reassigned) OVERRIDE; 40 bool ids_reassigned) OVERRIDE;
39 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE; 41 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE;
40 virtual void BookmarkNodeMoved(BookmarkModel* model, 42 virtual void BookmarkNodeMoved(BookmarkModel* model,
41 const BookmarkNode* old_parent, 43 const BookmarkNode* old_parent,
42 int old_index, 44 int old_index,
43 const BookmarkNode* new_parent, 45 const BookmarkNode* new_parent,
(...skipping 13 matching lines...) Expand all
57 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, 59 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
58 const BookmarkNode* node) OVERRIDE; 60 const BookmarkNode* node) OVERRIDE;
59 virtual void ExtensiveBookmarkChangesBeginning(BookmarkModel* model) OVERRIDE; 61 virtual void ExtensiveBookmarkChangesBeginning(BookmarkModel* model) OVERRIDE;
60 virtual void ExtensiveBookmarkChangesEnded(BookmarkModel* model) OVERRIDE; 62 virtual void ExtensiveBookmarkChangesEnded(BookmarkModel* model) OVERRIDE;
61 63
62 private: 64 private:
63 // Helper to actually dispatch an event to extension listeners. 65 // Helper to actually dispatch an event to extension listeners.
64 void DispatchEvent(const std::string& event_name, 66 void DispatchEvent(const std::string& event_name,
65 scoped_ptr<base::ListValue> event_args); 67 scoped_ptr<base::ListValue> event_args);
66 68
67 Profile* profile_; 69 content::BrowserContext* browser_context_;
68 BookmarkModel* model_; 70 BookmarkModel* model_;
69 71
70 DISALLOW_COPY_AND_ASSIGN(BookmarkEventRouter); 72 DISALLOW_COPY_AND_ASSIGN(BookmarkEventRouter);
71 }; 73 };
72 74
73 class BookmarksAPI : public ProfileKeyedAPI, 75 class BookmarksAPI : public ProfileKeyedAPI,
74 public EventRouter::Observer { 76 public EventRouter::Observer {
75 public: 77 public:
76 explicit BookmarksAPI(Profile* profile); 78 explicit BookmarksAPI(content::BrowserContext* context);
77 virtual ~BookmarksAPI(); 79 virtual ~BookmarksAPI();
78 80
79 // BrowserContextKeyedService implementation. 81 // BrowserContextKeyedService implementation.
80 virtual void Shutdown() OVERRIDE; 82 virtual void Shutdown() OVERRIDE;
81 83
82 // ProfileKeyedAPI implementation. 84 // ProfileKeyedAPI implementation.
83 static ProfileKeyedAPIFactory<BookmarksAPI>* GetFactoryInstance(); 85 static ProfileKeyedAPIFactory<BookmarksAPI>* GetFactoryInstance();
84 86
85 // EventRouter::Observer implementation. 87 // EventRouter::Observer implementation.
86 virtual void OnListenerAdded( 88 virtual void OnListenerAdded(
87 const EventListenerInfo& details) OVERRIDE; 89 const EventListenerInfo& details) OVERRIDE;
88 90
89 private: 91 private:
90 friend class ProfileKeyedAPIFactory<BookmarksAPI>; 92 friend class ProfileKeyedAPIFactory<BookmarksAPI>;
91 93
92 Profile* profile_; 94 content::BrowserContext* browser_context_;
93 95
94 // ProfileKeyedAPI implementation. 96 // ProfileKeyedAPI implementation.
95 static const char* service_name() { 97 static const char* service_name() {
96 return "BookmarksAPI"; 98 return "BookmarksAPI";
97 } 99 }
98 static const bool kServiceIsNULLWhileTesting = true; 100 static const bool kServiceIsNULLWhileTesting = true;
99 101
100 // Created lazily upon OnListenerAdded. 102 // Created lazily upon OnListenerAdded.
101 scoped_ptr<BookmarkEventRouter> bookmark_event_router_; 103 scoped_ptr<BookmarkEventRouter> bookmark_event_router_;
102 }; 104 };
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 private: 334 private:
333 virtual ~BookmarksExportFunction() {} 335 virtual ~BookmarksExportFunction() {}
334 336
335 // ExtensionFunction: 337 // ExtensionFunction:
336 virtual bool RunImpl() OVERRIDE; 338 virtual bool RunImpl() OVERRIDE;
337 }; 339 };
338 340
339 } // namespace extensions 341 } // namespace extensions
340 342
341 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ 343 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/audio/audio_api.cc ('k') | chrome/browser/extensions/api/bookmarks/bookmarks_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698