| 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_MD_DOWNLOADS_MD_DOWNLOADS_DOM_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_MD_DOWNLOADS_MD_DOWNLOADS_DOM_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_MD_DOWNLOADS_MD_DOWNLOADS_DOM_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_MD_DOWNLOADS_MD_DOWNLOADS_DOM_HANDLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "chrome/browser/download/download_danger_prompt.h" | 15 #include "chrome/browser/download/download_danger_prompt.h" |
| 16 #include "chrome/browser/ui/webui/md_downloads/downloads_list_tracker.h" | 16 #include "chrome/browser/ui/webui/md_downloads/downloads_list_tracker.h" |
| 17 #include "content/public/browser/web_contents_observer.h" |
| 17 #include "content/public/browser/web_ui_message_handler.h" | 18 #include "content/public/browser/web_ui_message_handler.h" |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 class ListValue; | 21 class ListValue; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 class DownloadItem; | 25 class DownloadItem; |
| 25 class DownloadManager; | 26 class DownloadManager; |
| 26 class RenderViewHost; | |
| 27 class WebContents; | 27 class WebContents; |
| 28 class WebUI; | 28 class WebUI; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // The handler for Javascript messages related to the "downloads" view, | 31 // The handler for Javascript messages related to the "downloads" view, |
| 32 // also observes changes to the download manager. | 32 // also observes changes to the download manager. |
| 33 class MdDownloadsDOMHandler : public content::WebUIMessageHandler { | 33 class MdDownloadsDOMHandler : public content::WebContentsObserver, |
| 34 public content::WebUIMessageHandler { |
| 34 public: | 35 public: |
| 35 MdDownloadsDOMHandler(content::DownloadManager* download_manager, | 36 MdDownloadsDOMHandler(content::DownloadManager* download_manager, |
| 36 content::WebUI* web_ui); | 37 content::WebUI* web_ui); |
| 37 ~MdDownloadsDOMHandler() override; | 38 ~MdDownloadsDOMHandler() override; |
| 38 | 39 |
| 39 // WebUIMessageHandler implementation. | 40 // WebUIMessageHandler implementation. |
| 40 void RegisterMessages() override; | 41 void RegisterMessages() override; |
| 41 void OnJavascriptDisallowed() override; | 42 void OnJavascriptDisallowed() override; |
| 42 | 43 |
| 44 // WebContentsObserver implementation. |
| 45 void RenderProcessGone(base::TerminationStatus status) override; |
| 46 |
| 43 // Callback for the "getDownloads" message. | 47 // Callback for the "getDownloads" message. |
| 44 void HandleGetDownloads(const base::ListValue* args); | 48 void HandleGetDownloads(const base::ListValue* args); |
| 45 | 49 |
| 46 // Callback for the "openFile" message - opens the file in the shell. | 50 // Callback for the "openFile" message - opens the file in the shell. |
| 47 void HandleOpenFile(const base::ListValue* args); | 51 void HandleOpenFile(const base::ListValue* args); |
| 48 | 52 |
| 49 // Callback for the "drag" message - initiates a file object drag. | 53 // Callback for the "drag" message - initiates a file object drag. |
| 50 void HandleDrag(const base::ListValue* args); | 54 void HandleDrag(const base::ListValue* args); |
| 51 | 55 |
| 52 // Callback for the "saveDangerous" message - specifies that the user | 56 // Callback for the "saveDangerous" message - specifies that the user |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 140 |
| 137 // IDs of downloads to remove when this handler gets deleted. | 141 // IDs of downloads to remove when this handler gets deleted. |
| 138 std::vector<IdSet> removals_; | 142 std::vector<IdSet> removals_; |
| 139 | 143 |
| 140 base::WeakPtrFactory<MdDownloadsDOMHandler> weak_ptr_factory_; | 144 base::WeakPtrFactory<MdDownloadsDOMHandler> weak_ptr_factory_; |
| 141 | 145 |
| 142 DISALLOW_COPY_AND_ASSIGN(MdDownloadsDOMHandler); | 146 DISALLOW_COPY_AND_ASSIGN(MdDownloadsDOMHandler); |
| 143 }; | 147 }; |
| 144 | 148 |
| 145 #endif // CHROME_BROWSER_UI_WEBUI_MD_DOWNLOADS_MD_DOWNLOADS_DOM_HANDLER_H_ | 149 #endif // CHROME_BROWSER_UI_WEBUI_MD_DOWNLOADS_MD_DOWNLOADS_DOM_HANDLER_H_ |
| OLD | NEW |