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

Side by Side Diff: chrome/browser/download/download_ui_controller.cc

Issue 852043002: Initial Implementation of Download Notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments & added tests. Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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/command_line.h"
8 #include "base/stl_util.h" 9 #include "base/stl_util.h"
9 #include "chrome/browser/download/download_item_model.h" 10 #include "chrome/browser/download/download_item_model.h"
11 #include "chrome/browser/download/notification/download_notification_manager.h"
10 #include "chrome/browser/ui/browser_finder.h" 12 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/browser_tabstrip.h" 13 #include "chrome/browser/ui/browser_tabstrip.h"
14 #include "chrome/common/chrome_switches.h"
12 #include "content/public/browser/download_item.h" 15 #include "content/public/browser/download_item.h"
13 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
14 #include "content/public/browser/web_contents_delegate.h" 17 #include "content/public/browser/web_contents_delegate.h"
15 18
16 #if defined(OS_ANDROID) 19 #if defined(OS_ANDROID)
17 #include "content/public/browser/android/download_controller_android.h" 20 #include "content/public/browser/android/download_controller_android.h"
18 #else 21 #else
19 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
20 #endif 23 #endif
21 24
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 scoped_ptr<Delegate> delegate) 97 scoped_ptr<Delegate> delegate)
95 : download_notifier_(manager, this), 98 : download_notifier_(manager, this),
96 delegate_(delegate.Pass()) { 99 delegate_(delegate.Pass()) {
97 if (!delegate_) { 100 if (!delegate_) {
98 #if defined(OS_ANDROID) 101 #if defined(OS_ANDROID)
99 delegate_.reset(new DefaultUIControllerDelegateAndroid()); 102 delegate_.reset(new DefaultUIControllerDelegateAndroid());
100 #else 103 #else
101 // The delegate should not be invoked after the profile has gone away. This 104 // The delegate should not be invoked after the profile has gone away. This
102 // should be the case since DownloadUIController is owned by 105 // should be the case since DownloadUIController is owned by
103 // DownloadService, which in turn is a profile keyed service. 106 // DownloadService, which in turn is a profile keyed service.
104 delegate_.reset(new DefaultUIControllerDelegate( 107 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
105 Profile::FromBrowserContext(manager->GetBrowserContext()))); 108 switches::kEnableDownloadNotification)) {
109 delegate_.reset(new DownloadNotificationManager(
110 Profile::FromBrowserContext(manager->GetBrowserContext())));
111 } else {
112 delegate_.reset(new DefaultUIControllerDelegate(
asanka 2015/02/20 23:34:39 Shall we rename the UIControllerDelegates? Defaul
yoshiki 2015/02/24 21:30:57 Done.
113 Profile::FromBrowserContext(manager->GetBrowserContext())));
114 }
106 #endif 115 #endif
107 } 116 }
108 } 117 }
109 118
110 DownloadUIController::~DownloadUIController() { 119 DownloadUIController::~DownloadUIController() {
111 } 120 }
112 121
113 void DownloadUIController::OnDownloadCreated(content::DownloadManager* manager, 122 void DownloadUIController::OnDownloadCreated(content::DownloadManager* manager,
114 content::DownloadItem* item) { 123 content::DownloadItem* item) {
115 // SavePackage downloads are created in a state where they can be shown in the 124 // SavePackage downloads are created in a state where they can be shown in the
(...skipping 10 matching lines...) Expand all
126 if (item_model.WasUINotified() || !item_model.ShouldNotifyUI()) 135 if (item_model.WasUINotified() || !item_model.ShouldNotifyUI())
127 return; 136 return;
128 137
129 // Wait until the target path is determined. 138 // Wait until the target path is determined.
130 if (item->GetTargetFilePath().empty()) 139 if (item->GetTargetFilePath().empty())
131 return; 140 return;
132 141
133 DownloadItemModel(item).SetWasUINotified(true); 142 DownloadItemModel(item).SetWasUINotified(true);
134 delegate_->OnNewDownloadReady(item); 143 delegate_->OnNewDownloadReady(item);
135 } 144 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698