OLD | NEW |
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_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "chrome/browser/download/hyperbolic_download_item_notifier.h" | 13 #include "chrome/browser/download/all_download_item_notifier.h" |
14 #include "content/public/browser/download_item.h" | 14 #include "content/public/browser/download_item.h" |
15 #include "content/public/browser/download_manager.h" | 15 #include "content/public/browser/download_manager.h" |
16 #include "content/public/browser/web_ui_message_handler.h" | 16 #include "content/public/browser/web_ui_message_handler.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class ListValue; | 19 class ListValue; |
20 } | 20 } |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 class WebContents; | 23 class WebContents; |
24 } | 24 } |
25 | 25 |
26 // The handler for Javascript messages related to the "downloads" view, | 26 // The handler for Javascript messages related to the "downloads" view, |
27 // also observes changes to the download manager. | 27 // also observes changes to the download manager. |
28 class DownloadsDOMHandler : public content::WebUIMessageHandler, | 28 class DownloadsDOMHandler : public content::WebUIMessageHandler, |
29 public HyperbolicDownloadItemNotifier::Observer { | 29 public AllDownloadItemNotifier::Observer { |
30 public: | 30 public: |
31 explicit DownloadsDOMHandler(content::DownloadManager* dlm); | 31 explicit DownloadsDOMHandler(content::DownloadManager* dlm); |
32 virtual ~DownloadsDOMHandler(); | 32 virtual ~DownloadsDOMHandler(); |
33 | 33 |
34 void Init(); | 34 void Init(); |
35 | 35 |
36 // WebUIMessageHandler implementation. | 36 // WebUIMessageHandler implementation. |
37 virtual void RegisterMessages() OVERRIDE; | 37 virtual void RegisterMessages() OVERRIDE; |
38 | 38 |
39 // HyperbolicDownloadItemNotifier::Observer interface | 39 // AllDownloadItemNotifier::Observer interface |
40 virtual void OnDownloadCreated( | 40 virtual void OnDownloadCreated( |
41 content::DownloadManager* manager, | 41 content::DownloadManager* manager, |
42 content::DownloadItem* download_item) OVERRIDE; | 42 content::DownloadItem* download_item) OVERRIDE; |
43 virtual void OnDownloadUpdated( | 43 virtual void OnDownloadUpdated( |
44 content::DownloadManager* manager, | 44 content::DownloadManager* manager, |
45 content::DownloadItem* download_item) OVERRIDE; | 45 content::DownloadItem* download_item) OVERRIDE; |
46 virtual void OnDownloadRemoved( | 46 virtual void OnDownloadRemoved( |
47 content::DownloadManager* manager, | 47 content::DownloadManager* manager, |
48 content::DownloadItem* download_item) OVERRIDE; | 48 content::DownloadItem* download_item) OVERRIDE; |
49 | 49 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // DownloadItem. | 119 // DownloadItem. |
120 void DangerPromptAccepted(int download_id); | 120 void DangerPromptAccepted(int download_id); |
121 | 121 |
122 // Returns the download that is referred to in a given value. | 122 // Returns the download that is referred to in a given value. |
123 content::DownloadItem* GetDownloadByValue(const base::ListValue* args); | 123 content::DownloadItem* GetDownloadByValue(const base::ListValue* args); |
124 | 124 |
125 // Current search text. | 125 // Current search text. |
126 string16 search_text_; | 126 string16 search_text_; |
127 | 127 |
128 // Notifies OnDownload*() and provides safe access to the DownloadManager. | 128 // Notifies OnDownload*() and provides safe access to the DownloadManager. |
129 HyperbolicDownloadItemNotifier main_notifier_; | 129 AllDownloadItemNotifier main_notifier_; |
130 | 130 |
131 // If |main_notifier_| observes an incognito profile, then this observes the | 131 // If |main_notifier_| observes an incognito profile, then this observes the |
132 // DownloadManager for the original profile; otherwise, this is NULL. | 132 // DownloadManager for the original profile; otherwise, this is NULL. |
133 scoped_ptr<HyperbolicDownloadItemNotifier> original_notifier_; | 133 scoped_ptr<AllDownloadItemNotifier> original_notifier_; |
134 | 134 |
135 // Whether a call to SendCurrentDownloads() is currently scheduled. | 135 // Whether a call to SendCurrentDownloads() is currently scheduled. |
136 bool update_scheduled_; | 136 bool update_scheduled_; |
137 | 137 |
138 base::WeakPtrFactory<DownloadsDOMHandler> weak_ptr_factory_; | 138 base::WeakPtrFactory<DownloadsDOMHandler> weak_ptr_factory_; |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(DownloadsDOMHandler); | 140 DISALLOW_COPY_AND_ASSIGN(DownloadsDOMHandler); |
141 }; | 141 }; |
142 | 142 |
143 #endif // CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ | 143 #endif // CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_ |
OLD | NEW |