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

Unified Diff: chrome/browser/extensions/extension_downloads.h

Issue 7192016: chrome.experimental.downloads (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merged db_handle, id; onCreated, onErased Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_downloads.h
diff --git a/chrome/browser/extensions/extension_downloads.h b/chrome/browser/extensions/extension_downloads.h
new file mode 100644
index 0000000000000000000000000000000000000000..a53d59a62861c538d95696a84e9e7f11e9d6a7e9
--- /dev/null
+++ b/chrome/browser/extensions/extension_downloads.h
@@ -0,0 +1,232 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_H_
+#pragma once
+
+#include <map>
+#include <set>
+#include <string>
+
+#include "base/memory/singleton.h"
+#include "base/stl_util-inl.h"
+#include "chrome/browser/download/download_item.h"
+#include "chrome/browser/download/download_manager.h"
+#include "chrome/browser/extensions/extension_function.h"
+
+class DictionaryValue;
+class ResourceDispatcherHost;
+class TabContents;
+namespace content {
+class ResourceContext;
+}
+
+// http://goo.gl/6hO1n
+
+class DownloadsDownloadFunction : public AsyncExtensionFunction {
+ public:
+ DownloadsDownloadFunction()
+ : options_(NULL),
+ save_as_(false),
+ extra_headers_(NULL),
+ dl_man_(NULL),
+ rdh_(NULL),
+ tab_contents_(NULL),
+ resource_context_(NULL),
+ render_process_host_id_(0),
+ render_view_host_routing_id_(0),
+ products_(NULL),
+ dl_id_(-1),
+ dl_error_(0) {
+ }
+ virtual ~DownloadsDownloadFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.download");
+
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ void BeginDownloadOnIOThread();
+ void OnStarted(int dl_id, int error);
+ void RespondOnUIThread();
+
+ DictionaryValue* options_;
+ std::string url_;
+ std::string filename_;
+ bool save_as_;
+ DictionaryValue* extra_headers_;
+ std::string method_;
+ std::string post_body_;
+
+ DownloadManager* dl_man_;
+ ResourceDispatcherHost* rdh_;
+ TabContents* tab_contents_;
+ const content::ResourceContext* resource_context_;
+ int render_process_host_id_;
+ int render_view_host_routing_id_;
+
+ DictionaryValue* products_;
+ int dl_id_;
+ int dl_error_;
+
+ DISALLOW_COPY_AND_ASSIGN(DownloadsDownloadFunction);
+};
+
+class DownloadsSearchFunction : public SyncExtensionFunction {
+ public:
+ DownloadsSearchFunction() {}
+ virtual ~DownloadsSearchFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.search");
+
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DownloadsSearchFunction);
+};
+
+class DownloadsPauseFunction : public SyncExtensionFunction {
+ public:
+ DownloadsPauseFunction() {}
+ virtual ~DownloadsPauseFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.pause");
+
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DownloadsPauseFunction);
+};
+
+class DownloadsResumeFunction : public AsyncExtensionFunction {
+ public:
+ DownloadsResumeFunction() {}
+ virtual ~DownloadsResumeFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.resume");
+
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DownloadsResumeFunction);
+};
+
+class DownloadsCancelFunction : public AsyncExtensionFunction {
+ public:
+ DownloadsCancelFunction() {}
+ virtual ~DownloadsCancelFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.cancel");
+
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DownloadsCancelFunction);
+};
+
+class DownloadsEraseFunction : public AsyncExtensionFunction {
+ public:
+ DownloadsEraseFunction() {}
+ virtual ~DownloadsEraseFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.erase");
+
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DownloadsEraseFunction);
+};
+
+class DownloadsSetDestinationFunction : public AsyncExtensionFunction {
+ public:
+ DownloadsSetDestinationFunction() {}
+ virtual ~DownloadsSetDestinationFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.setDestination");
+
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DownloadsSetDestinationFunction);
+};
+
+class DownloadsAcceptDangerFunction : public AsyncExtensionFunction {
+ public:
+ DownloadsAcceptDangerFunction() {}
+ virtual ~DownloadsAcceptDangerFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.acceptDanger");
+
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DownloadsAcceptDangerFunction);
+};
+
+class DownloadsShowFunction : public AsyncExtensionFunction {
+ public:
+ DownloadsShowFunction() {}
+ virtual ~DownloadsShowFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.show");
+
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DownloadsShowFunction);
+};
+
+class DownloadsDragFunction : public AsyncExtensionFunction {
+ public:
+ DownloadsDragFunction() {}
+ virtual ~DownloadsDragFunction() {}
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.drag");
+
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DownloadsDragFunction);
+};
+
+class DownloadsEventRouter {
+ public:
+ enum EventType {
+ CREATED,
+ CHANGED,
+ ERASED,
+ };
+
+ static DownloadsEventRouter* GetInstance();
+
+ void AddEventListener(
+ EventType event_type,
+ ProfileId profile_id,
+ const std::string& extension_id,
+ base::WeakPtr<IPC::Message::Sender> ipc_sender);
+
+ void DispatchEvent(
+ EventType event_type,
+ ProfileId profile_id,
+ int download_id);
+
+ // But I'm a frickin singleton...
+ void AddRef() {}
+ void Release() {}
+ static bool ImplementsThreadSafeReferenceCounting() { return true; }
+
+ private:
+ DownloadsEventRouter();
+ ~DownloadsEventRouter();
+
+ friend struct DefaultSingletonTraits<DownloadsEventRouter>;
+ struct EventListener;
+ class ManagerObserver;
+ class ItemObserver;
+ typedef std::set<EventListener> ListenerSet;
+ typedef std::map<EventType, ListenerSet> ListenerMapForProfile;
+ typedef std::map<ProfileId, ListenerMapForProfile> ListenerMap;
+ typedef std::map<ProfileId, ManagerObserver*> ManagerObservers;
+ typedef std::map<int/*download_id*/, ItemObserver> ItemObserversForProfile;
+ typedef std::map<ProfileId, ItemObserversForProfile> ItemObservers;
+
+ ListenerMap listeners_;
+ ManagerObservers manager_observers_;
+ ItemObservers item_observers_;
+ //STLValueDeleter<ManagerObservers> delete_manager_observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(DownloadsEventRouter);
+};
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_H_
« no previous file with comments | « chrome/browser/extensions/extension_browser_event_router.cc ('k') | chrome/browser/extensions/extension_downloads.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698