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

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

Issue 11820041: Remove profile-keyed factory boilerplates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 7 years, 11 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
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/bookmark_model_observer.h" 14 #include "chrome/browser/bookmarks/bookmark_model_observer.h"
15 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
15 #include "chrome/browser/extensions/event_router.h" 16 #include "chrome/browser/extensions/event_router.h"
16 #include "chrome/browser/extensions/extension_function.h" 17 #include "chrome/browser/extensions/extension_function.h"
17 #include "chrome/browser/profiles/profile_keyed_service.h"
18 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
20 #include "ui/base/dialogs/select_file_dialog.h" 20 #include "ui/base/dialogs/select_file_dialog.h"
21 21
22 class FilePath; 22 class FilePath;
23 23
24 namespace base { 24 namespace base {
25 class ListValue; 25 class ListValue;
26 } 26 }
27 27
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // Helper to actually dispatch an event to extension listeners. 62 // Helper to actually dispatch an event to extension listeners.
63 void DispatchEvent(Profile* profile, 63 void DispatchEvent(Profile* profile,
64 const char* event_name, 64 const char* event_name,
65 scoped_ptr<base::ListValue> event_args); 65 scoped_ptr<base::ListValue> event_args);
66 66
67 BookmarkModel* model_; 67 BookmarkModel* model_;
68 68
69 DISALLOW_COPY_AND_ASSIGN(BookmarkEventRouter); 69 DISALLOW_COPY_AND_ASSIGN(BookmarkEventRouter);
70 }; 70 };
71 71
72 class BookmarkAPI : public ProfileKeyedService, 72 class BookmarksAPI : public ProfileKeyedAPI,
73 public EventRouter::Observer { 73 public EventRouter::Observer {
74 public: 74 public:
75 explicit BookmarkAPI(Profile* profile); 75 explicit BookmarksAPI(Profile* profile);
76 virtual ~BookmarkAPI(); 76 virtual ~BookmarksAPI();
77 77
78 // ProfileKeyedService implementation. 78 // ProfileKeyedService implementation.
79 virtual void Shutdown() OVERRIDE; 79 virtual void Shutdown() OVERRIDE;
80 80
81 // ProfileKeyedAPI implementation.
82 static ProfileKeyedAPIFactory<BookmarksAPI>* GetFactoryInstance();
83
81 // EventRouter::Observer implementation. 84 // EventRouter::Observer implementation.
82 virtual void OnListenerAdded(const EventListenerInfo& details) 85 virtual void OnListenerAdded(const EventListenerInfo& details)
83 OVERRIDE; 86 OVERRIDE;
84 87
85 private: 88 private:
89 friend class ProfileKeyedAPIFactory<BookmarksAPI>;
90
86 Profile* profile_; 91 Profile* profile_;
87 92
93 // ProfileKeyedAPI implementation.
94 static const char* service_name() {
95 return "BookmarksAPI";
96 }
97 static const bool kServiceIsNULLWhileTesting = true;
98
88 // Created lazily upon OnListenerAdded. 99 // Created lazily upon OnListenerAdded.
89 scoped_ptr<BookmarkEventRouter> bookmark_event_router_; 100 scoped_ptr<BookmarkEventRouter> bookmark_event_router_;
90 }; 101 };
91 102
92 class BookmarksFunction : public AsyncExtensionFunction, 103 class BookmarksFunction : public AsyncExtensionFunction,
93 public content::NotificationObserver { 104 public content::NotificationObserver {
94 public: 105 public:
95 // AsyncExtensionFunction: 106 // AsyncExtensionFunction:
96 virtual void Run() OVERRIDE; 107 virtual void Run() OVERRIDE;
97 108
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 private: 323 private:
313 virtual ~BookmarksExportFunction() {} 324 virtual ~BookmarksExportFunction() {}
314 325
315 // ExtensionFunction: 326 // ExtensionFunction:
316 virtual bool RunImpl() OVERRIDE; 327 virtual bool RunImpl() OVERRIDE;
317 }; 328 };
318 329
319 } // namespace extensions 330 } // namespace extensions
320 331
321 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_ 332 #endif // CHROME_BROWSER_EXTENSIONS_API_BOOKMARKS_BOOKMARKS_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698