OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/download/download_ui_controller.h" | 5 #include "chrome/browser/download/download_ui_controller.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "chrome/browser/download/download_item_model.h" | 9 #include "chrome/browser/download/download_item_model.h" |
10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #if defined(OS_ANDROID) | 26 #if defined(OS_ANDROID) |
27 | 27 |
28 class DefaultUIControllerDelegateAndroid | 28 class DefaultUIControllerDelegateAndroid |
29 : public DownloadUIController::Delegate { | 29 : public DownloadUIController::Delegate { |
30 public: | 30 public: |
31 DefaultUIControllerDelegateAndroid() {} | 31 DefaultUIControllerDelegateAndroid() {} |
32 virtual ~DefaultUIControllerDelegateAndroid() {} | 32 virtual ~DefaultUIControllerDelegateAndroid() {} |
33 | 33 |
34 private: | 34 private: |
35 // DownloadUIController::Delegate | 35 // DownloadUIController::Delegate |
36 virtual void OnNewDownloadReady(content::DownloadItem* item) OVERRIDE; | 36 virtual void OnNewDownloadReady(content::DownloadItem* item) override; |
37 }; | 37 }; |
38 | 38 |
39 void DefaultUIControllerDelegateAndroid::OnNewDownloadReady( | 39 void DefaultUIControllerDelegateAndroid::OnNewDownloadReady( |
40 content::DownloadItem* item) { | 40 content::DownloadItem* item) { |
41 // The Android DownloadController is only interested in IN_PROGRESS downloads. | 41 // The Android DownloadController is only interested in IN_PROGRESS downloads. |
42 // Ones which are INTERRUPTED etc. can't be handed over to the Android | 42 // Ones which are INTERRUPTED etc. can't be handed over to the Android |
43 // DownloadManager. | 43 // DownloadManager. |
44 if (item->GetState() != content::DownloadItem::IN_PROGRESS) | 44 if (item->GetState() != content::DownloadItem::IN_PROGRESS) |
45 return; | 45 return; |
46 | 46 |
47 // GET downloads without authentication are delegated to the Android | 47 // GET downloads without authentication are delegated to the Android |
48 // DownloadManager. Chrome is responsible for the rest. See | 48 // DownloadManager. Chrome is responsible for the rest. See |
49 // InterceptDownloadResourceThrottle::ProcessDownloadRequest(). | 49 // InterceptDownloadResourceThrottle::ProcessDownloadRequest(). |
50 content::DownloadControllerAndroid::Get()->OnDownloadStarted(item); | 50 content::DownloadControllerAndroid::Get()->OnDownloadStarted(item); |
51 } | 51 } |
52 | 52 |
53 #else // OS_ANDROID | 53 #else // OS_ANDROID |
54 | 54 |
55 class DefaultUIControllerDelegate : public DownloadUIController::Delegate { | 55 class DefaultUIControllerDelegate : public DownloadUIController::Delegate { |
56 public: | 56 public: |
57 // |profile| is required to outlive DefaultUIControllerDelegate. | 57 // |profile| is required to outlive DefaultUIControllerDelegate. |
58 explicit DefaultUIControllerDelegate(Profile* profile) | 58 explicit DefaultUIControllerDelegate(Profile* profile) |
59 : profile_(profile) {} | 59 : profile_(profile) {} |
60 virtual ~DefaultUIControllerDelegate() {} | 60 virtual ~DefaultUIControllerDelegate() {} |
61 | 61 |
62 private: | 62 private: |
63 // DownloadUIController::Delegate | 63 // DownloadUIController::Delegate |
64 virtual void OnNewDownloadReady(content::DownloadItem* item) OVERRIDE; | 64 virtual void OnNewDownloadReady(content::DownloadItem* item) override; |
65 | 65 |
66 Profile* profile_; | 66 Profile* profile_; |
67 }; | 67 }; |
68 | 68 |
69 void DefaultUIControllerDelegate::OnNewDownloadReady( | 69 void DefaultUIControllerDelegate::OnNewDownloadReady( |
70 content::DownloadItem* item) { | 70 content::DownloadItem* item) { |
71 content::WebContents* web_contents = item->GetWebContents(); | 71 content::WebContents* web_contents = item->GetWebContents(); |
72 Browser* browser = | 72 Browser* browser = |
73 web_contents ? chrome::FindBrowserWithWebContents(web_contents) : NULL; | 73 web_contents ? chrome::FindBrowserWithWebContents(web_contents) : NULL; |
74 | 74 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 if (item_model.WasUINotified() || !item_model.ShouldNotifyUI()) | 126 if (item_model.WasUINotified() || !item_model.ShouldNotifyUI()) |
127 return; | 127 return; |
128 | 128 |
129 // Wait until the target path is determined. | 129 // Wait until the target path is determined. |
130 if (item->GetTargetFilePath().empty()) | 130 if (item->GetTargetFilePath().empty()) |
131 return; | 131 return; |
132 | 132 |
133 DownloadItemModel(item).SetWasUINotified(true); | 133 DownloadItemModel(item).SetWasUINotified(true); |
134 delegate_->OnNewDownloadReady(item); | 134 delegate_->OnNewDownloadReady(item); |
135 } | 135 } |
OLD | NEW |