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

Side by Side Diff: chrome/browser/extensions/api/developer_private/developer_private_api.h

Issue 168253002: Cleanup many APIs to use ProfileKeyedAPI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/files/file.h" 10 #include "base/files/file.h"
11 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" 11 #include "chrome/browser/extensions/api/developer_private/entry_picker.h"
12 #include "chrome/browser/extensions/api/file_system/file_system_api.h" 12 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
13 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
13 #include "chrome/browser/extensions/chrome_extension_function.h" 14 #include "chrome/browser/extensions/chrome_extension_function.h"
14 #include "chrome/browser/extensions/error_console/error_console.h" 15 #include "chrome/browser/extensions/error_console/error_console.h"
15 #include "chrome/browser/extensions/extension_install_prompt.h" 16 #include "chrome/browser/extensions/extension_install_prompt.h"
16 #include "chrome/browser/extensions/extension_uninstall_dialog.h" 17 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
17 #include "chrome/browser/extensions/pack_extension_job.h" 18 #include "chrome/browser/extensions/pack_extension_job.h"
18 #include "chrome/browser/extensions/requirements_checker.h" 19 #include "chrome/browser/extensions/requirements_checker.h"
19 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
20 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
22 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
23 #include "extensions/browser/event_router.h" 23 #include "extensions/browser/event_router.h"
24 #include "ui/shell_dialogs/select_file_dialog.h" 24 #include "ui/shell_dialogs/select_file_dialog.h"
25 #include "webkit/browser/fileapi/file_system_context.h" 25 #include "webkit/browser/fileapi/file_system_context.h"
26 #include "webkit/browser/fileapi/file_system_operation.h" 26 #include "webkit/browser/fileapi/file_system_operation.h"
27 27
28 class ExtensionService; 28 class ExtensionService;
29 class Profile;
29 30
30 namespace extensions { 31 namespace extensions {
31 32
32 class ExtensionError; 33 class ExtensionError;
33 class ExtensionSystem; 34 class ExtensionSystem;
34 class ManagementPolicy; 35 class ManagementPolicy;
35 36
36 namespace api { 37 namespace api {
37 38
38 class EntryPicker; 39 class EntryPicker;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // the Apps Developer Tool (which replaces the chrome://extensions page), we 84 // the Apps Developer Tool (which replaces the chrome://extensions page), we
84 // don't want to send information about the subscribing extension in an 85 // don't want to send information about the subscribing extension in an
85 // update. In particular, we want to avoid entering a loop, which could happen 86 // update. In particular, we want to avoid entering a loop, which could happen
86 // when, e.g., the Apps Developer Tool throws an error. 87 // when, e.g., the Apps Developer Tool throws an error.
87 std::set<std::string> extension_ids_; 88 std::set<std::string> extension_ids_;
88 89
89 DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateEventRouter); 90 DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateEventRouter);
90 }; 91 };
91 92
92 // The profile-keyed service that manages the DeveloperPrivate API. 93 // The profile-keyed service that manages the DeveloperPrivate API.
93 class DeveloperPrivateAPI : public BrowserContextKeyedService, 94 class DeveloperPrivateAPI : public ProfileKeyedAPI,
94 public EventRouter::Observer { 95 public EventRouter::Observer {
95 public: 96 public:
97 static ProfileKeyedAPIFactory<DeveloperPrivateAPI>* GetFactoryInstance();
98
96 // Convenience method to get the DeveloperPrivateAPI for a profile. 99 // Convenience method to get the DeveloperPrivateAPI for a profile.
97 static DeveloperPrivateAPI* Get(Profile* profile); 100 static DeveloperPrivateAPI* Get(content::BrowserContext* context);
98 101
99 explicit DeveloperPrivateAPI(Profile* profile); 102 explicit DeveloperPrivateAPI(content::BrowserContext* context);
100 virtual ~DeveloperPrivateAPI(); 103 virtual ~DeveloperPrivateAPI();
101 104
102 void SetLastUnpackedDirectory(const base::FilePath& path); 105 void SetLastUnpackedDirectory(const base::FilePath& path);
103 106
104 base::FilePath& GetLastUnpackedDirectory() { 107 base::FilePath& GetLastUnpackedDirectory() {
105 return last_unpacked_directory_; 108 return last_unpacked_directory_;
106 } 109 }
107 110
108 // BrowserContextKeyedService implementation 111 // BrowserContextKeyedService implementation
109 virtual void Shutdown() OVERRIDE; 112 virtual void Shutdown() OVERRIDE;
110 113
111 // EventRouter::Observer implementation. 114 // EventRouter::Observer implementation.
112 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; 115 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE;
113 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; 116 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE;
114 117
115 private: 118 private:
119 friend class ProfileKeyedAPIFactory<DeveloperPrivateAPI>;
120
121 // ProfileKeyedAPI implementation.
122 static const char* service_name() { return "DeveloperPrivateAPI"; }
123 static const bool kServiceRedirectedInIncognito = true;
124 static const bool kServiceIsNULLWhileTesting = true;
125
116 void RegisterNotifications(); 126 void RegisterNotifications();
117 127
118 Profile* profile_; 128 Profile* profile_;
119 129
120 // Used to start the load |load_extension_dialog_| in the last directory that 130 // Used to start the load |load_extension_dialog_| in the last directory that
121 // was loaded. 131 // was loaded.
122 base::FilePath last_unpacked_directory_; 132 base::FilePath last_unpacked_directory_;
123 133
124 // Created lazily upon OnListenerAdded. 134 // Created lazily upon OnListenerAdded.
125 scoped_ptr<DeveloperPrivateEventRouter> developer_private_event_router_; 135 scoped_ptr<DeveloperPrivateEventRouter> developer_private_event_router_;
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 462
453 // ExtensionFunction: 463 // ExtensionFunction:
454 virtual bool RunImpl() OVERRIDE; 464 virtual bool RunImpl() OVERRIDE;
455 }; 465 };
456 466
457 } // namespace api 467 } // namespace api
458 468
459 } // namespace extensions 469 } // namespace extensions
460 470
461 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API _H_ 471 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698