Index: chrome/browser/extensions/api/developer_private/developer_private_api.h |
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.h b/chrome/browser/extensions/api/developer_private/developer_private_api.h |
index ee1b45551887f55fa7e3e82fbad4fbe7a711c172..2d4d2b4f4f724b19250eaaf638e823d59f1325ce 100644 |
--- a/chrome/browser/extensions/api/developer_private/developer_private_api.h |
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api.h |
@@ -5,10 +5,13 @@ |
#ifndef CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ |
#define CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ |
+#include <set> |
+ |
#include "base/files/file.h" |
#include "chrome/browser/extensions/api/developer_private/entry_picker.h" |
#include "chrome/browser/extensions/api/file_system/file_system_api.h" |
#include "chrome/browser/extensions/chrome_extension_function.h" |
+#include "chrome/browser/extensions/error_console/error_console.h" |
#include "chrome/browser/extensions/extension_install_prompt.h" |
#include "chrome/browser/extensions/extension_uninstall_dialog.h" |
#include "chrome/browser/extensions/pack_extension_job.h" |
@@ -26,6 +29,7 @@ class ExtensionService; |
namespace extensions { |
+class ExtensionError; |
class ExtensionSystem; |
class ManagementPolicy; |
@@ -44,38 +48,46 @@ struct ProjectInfo; |
} // namespace api |
-} // namespace extensions |
- |
-namespace developer = extensions::api::developer_private; |
+namespace developer = api::developer_private; |
typedef std::vector<linked_ptr<developer::ItemInfo> > ItemInfoList; |
typedef std::vector<linked_ptr<developer::ProjectInfo> > ProjectInfoList; |
typedef std::vector<linked_ptr<developer::ItemInspectView> > |
ItemInspectViewList; |
-namespace extensions { |
- |
-class DeveloperPrivateEventRouter : public content::NotificationObserver { |
+class DeveloperPrivateEventRouter : public content::NotificationObserver, |
+ public ErrorConsole::Observer { |
public: |
explicit DeveloperPrivateEventRouter(Profile* profile); |
virtual ~DeveloperPrivateEventRouter(); |
+ // Add or remove an ID to the list of extensions subscribed to events. |
+ void AddExtensionId(const std::string& extension_id); |
+ void RemoveExtensionId(const std::string& extension_id); |
+ |
private: |
// content::NotificationObserver implementation |
virtual void Observe(int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details) OVERRIDE; |
+ // ErrorConsole::Observer implementation |
+ virtual void OnErrorAdded(const ExtensionError* error) OVERRIDE; |
+ |
content::NotificationRegistrar registrar_; |
Profile* profile_; |
+ // The set of IDs of the Extensions which have subscribed to the events, |
+ // since we may treat events with these extensions differently. |
+ std::set<std::string> extension_ids_; |
+ |
DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateEventRouter); |
}; |
// The profile-keyed service that manages the DeveloperPrivate API. |
class DeveloperPrivateAPI : public BrowserContextKeyedService, |
- public extensions::EventRouter::Observer { |
+ public EventRouter::Observer { |
public: |
// Convenience method to get the DeveloperPrivateAPI for a profile. |
static DeveloperPrivateAPI* Get(Profile* profile); |
@@ -93,9 +105,9 @@ class DeveloperPrivateAPI : public BrowserContextKeyedService, |
virtual void Shutdown() OVERRIDE; |
// EventRouter::Observer implementation. |
- virtual void OnListenerAdded(const extensions::EventListenerInfo& details) |
+ virtual void OnListenerAdded(const EventListenerInfo& details) |
OVERRIDE; |
- virtual void OnListenerRemoved(const extensions::EventListenerInfo& details) |
+ virtual void OnListenerRemoved(const EventListenerInfo& details) |
OVERRIDE; |
private: |
@@ -143,8 +155,7 @@ class DeveloperPrivateGetItemsInfoFunction |
private: |
scoped_ptr<developer::ItemInfo> CreateItemInfo( |
- const extensions::Extension& item, |
- bool item_is_enabled); |
+ const Extension& item, bool item_is_enabled); |
void GetIconsOnFileThread( |
ItemInfoList item_list, |
@@ -157,12 +168,10 @@ class DeveloperPrivateGetItemsInfoFunction |
ItemInspectViewList* result); |
ItemInspectViewList GetInspectablePagesForExtension( |
- const extensions::Extension* extension, |
- bool extension_is_enabled); |
+ const Extension* extension, bool extension_is_enabled); |
void GetShellWindowPagesForExtensionProfile( |
- const extensions::Extension* extension, |
- ItemInspectViewList* result); |
+ const Extension* extension, ItemInspectViewList* result); |
linked_ptr<developer::ItemInspectView> constructInspectView( |
const GURL& url, |
@@ -264,7 +273,7 @@ class DeveloperPrivateEnableFunction |
virtual bool RunImpl() OVERRIDE; |
private: |
- scoped_ptr<extensions::RequirementsChecker> requirements_checker_; |
+ scoped_ptr<RequirementsChecker> requirements_checker_; |
}; |
class DeveloperPrivateChooseEntryFunction : public ChromeAsyncExtensionFunction, |
@@ -316,7 +325,7 @@ class DeveloperPrivateChoosePathFunction |
class DeveloperPrivatePackDirectoryFunction |
: public ChromeAsyncExtensionFunction, |
- public extensions::PackExtensionJob::Client { |
+ public PackExtensionJob::Client { |
public: |
DECLARE_EXTENSION_FUNCTION("developerPrivate.packDirectory", |
@@ -329,99 +338,131 @@ class DeveloperPrivatePackDirectoryFunction |
const base::FilePath& key_file) OVERRIDE; |
virtual void OnPackFailure( |
const std::string& error, |
- extensions::ExtensionCreator::ErrorType error_type) OVERRIDE; |
+ ExtensionCreator::ErrorType error_type) OVERRIDE; |
protected: |
virtual ~DeveloperPrivatePackDirectoryFunction(); |
virtual bool RunImpl() OVERRIDE; |
private: |
- scoped_refptr<extensions::PackExtensionJob> pack_job_; |
+ scoped_refptr<PackExtensionJob> pack_job_; |
std::string item_path_str_; |
std::string key_path_str_; |
}; |
class DeveloperPrivateGetStringsFunction : public ChromeSyncExtensionFunction { |
- public: |
- DECLARE_EXTENSION_FUNCTION("developerPrivate.getStrings", |
- DEVELOPERPRIVATE_GETSTRINGS); |
+ public: |
+ DECLARE_EXTENSION_FUNCTION("developerPrivate.getStrings", |
+ DEVELOPERPRIVATE_GETSTRINGS); |
- protected: |
- virtual ~DeveloperPrivateGetStringsFunction(); |
+ protected: |
+ virtual ~DeveloperPrivateGetStringsFunction(); |
- // ExtensionFunction |
- virtual bool RunImpl() OVERRIDE; |
+ // ExtensionFunction |
+ virtual bool RunImpl() OVERRIDE; |
}; |
class DeveloperPrivateIsProfileManagedFunction |
: public ChromeSyncExtensionFunction { |
- public: |
- DECLARE_EXTENSION_FUNCTION("developerPrivate.isProfileManaged", |
- DEVELOPERPRIVATE_ISPROFILEMANAGED); |
+ public: |
+ DECLARE_EXTENSION_FUNCTION("developerPrivate.isProfileManaged", |
+ DEVELOPERPRIVATE_ISPROFILEMANAGED); |
- protected: |
- virtual ~DeveloperPrivateIsProfileManagedFunction(); |
+ protected: |
+ virtual ~DeveloperPrivateIsProfileManagedFunction(); |
- // ExtensionFunction |
- virtual bool RunImpl() OVERRIDE; |
+ // ExtensionFunction |
+ virtual bool RunImpl() OVERRIDE; |
}; |
class DeveloperPrivateLoadDirectoryFunction |
: public ChromeAsyncExtensionFunction { |
- public: |
- DECLARE_EXTENSION_FUNCTION("developerPrivate.loadDirectory", |
- DEVELOPERPRIVATE_LOADUNPACKEDCROS); |
+ public: |
+ DECLARE_EXTENSION_FUNCTION("developerPrivate.loadDirectory", |
+ DEVELOPERPRIVATE_LOADUNPACKEDCROS); |
+ |
+ DeveloperPrivateLoadDirectoryFunction(); |
+ |
+ protected: |
+ virtual ~DeveloperPrivateLoadDirectoryFunction(); |
- DeveloperPrivateLoadDirectoryFunction(); |
+ // ExtensionFunction |
+ virtual bool RunImpl() OVERRIDE; |
+ |
+ void ClearExistingDirectoryContent(const base::FilePath& project_path); |
- protected: |
- virtual ~DeveloperPrivateLoadDirectoryFunction(); |
+ void ReadSyncFileSystemDirectory(const base::FilePath& project_path, |
+ const base::FilePath& destination_path); |
- // ExtensionFunction |
- virtual bool RunImpl() OVERRIDE; |
+ void ReadSyncFileSystemDirectoryCb( |
+ const base::FilePath& project_path, |
+ const base::FilePath& destination_path, |
+ base::File::Error result, |
+ const fileapi::FileSystemOperation::FileEntryList& file_list, |
+ bool has_more); |
- void ClearExistingDirectoryContent(const base::FilePath& project_path); |
+ void SnapshotFileCallback( |
+ const base::FilePath& target_path, |
+ base::File::Error result, |
+ const base::File::Info& file_info, |
+ const base::FilePath& platform_path, |
+ const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); |
- void ReadSyncFileSystemDirectory(const base::FilePath& project_path, |
- const base::FilePath& destination_path); |
+ void CopyFile(const base::FilePath& src_path, |
+ const base::FilePath& dest_path); |
- void ReadSyncFileSystemDirectoryCb( |
- const base::FilePath& project_path, |
- const base::FilePath& destination_path, |
- base::File::Error result, |
- const fileapi::FileSystemOperation::FileEntryList& file_list, |
- bool has_more); |
+ void Load(); |
- void SnapshotFileCallback( |
- const base::FilePath& target_path, |
- base::File::Error result, |
- const base::File::Info& file_info, |
- const base::FilePath& platform_path, |
- const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); |
+ scoped_refptr<fileapi::FileSystemContext> context_; |
- void CopyFile(const base::FilePath& src_path, |
- const base::FilePath& dest_path); |
+ // syncfs url representing the root of the folder to be copied. |
+ std::string project_base_url_; |
- void Load(); |
+ // physical path on disc of the folder to be copied. |
+ base::FilePath project_base_path_; |
- scoped_refptr<fileapi::FileSystemContext> context_; |
+ // Path of the current folder to be copied. |
+ base::FilePath current_path_; |
- // syncfs url representing the root of the folder to be copied. |
- std::string project_base_url_; |
+ private: |
+ int pending_copy_operations_count_; |
+ |
+ // This is set to false if any of the copyFile operations fail on |
+ // call of the API. It is returned as a response of the API call. |
+ bool success_; |
+}; |
- // physical path on disc of the folder to be copied. |
- base::FilePath project_base_path_; |
+class DeveloperPrivateRequestFileSourceFunction |
+ : public ChromeAsyncExtensionFunction { |
+ public: |
+ DECLARE_EXTENSION_FUNCTION("developerPrivate.requestFileSource", |
+ DEVELOPERPRIVATE_REQUESTFILESOURCE); |
- // Path of the current folder to be copied. |
- base::FilePath current_path_; |
+ DeveloperPrivateRequestFileSourceFunction(); |
- private: |
- int pending_copy_operations_count_; |
+ protected: |
+ virtual ~DeveloperPrivateRequestFileSourceFunction(); |
- // This is set to false if any of the copyFile operations fail on |
- // call of the API. It is returned as a response of the API call. |
- bool success_; |
+ // ExtensionFunction |
+ virtual bool RunImpl() OVERRIDE; |
+ private: |
+ void LaunchCallback(const base::DictionaryValue& results); |
+}; |
+ |
+class DeveloperPrivateOpenDevToolsFunction |
+ : public ChromeAsyncExtensionFunction { |
+ public: |
+ DECLARE_EXTENSION_FUNCTION("developerPrivate.openDevTools", |
+ DEVELOPERPRIVATE_OPENDEVTOOLS); |
+ |
+ DeveloperPrivateOpenDevToolsFunction(); |
+ |
+ protected: |
+ virtual ~DeveloperPrivateOpenDevToolsFunction(); |
+ |
+ // ExtensionFunction |
+ virtual bool RunImpl() OVERRIDE; |
}; |
} // namespace api |