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

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

Issue 164547: Mac: make save/open dialogs operate as tab-modal sheets.... Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Painfully (but hopefully correctly) merged ToT. Created 11 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_request_manager.h" 5 #include "chrome/browser/download/download_request_manager.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/thread.h" 8 #include "base/thread.h"
9 #include "chrome/browser/download/download_request_dialog_delegate.h" 9 #include "chrome/browser/download/download_request_dialog_delegate.h"
10 #include "chrome/browser/tab_contents/navigation_controller.h" 10 #include "chrome/browser/tab_contents/navigation_controller.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 if (status_ != DownloadRequestManager::ALLOW_ALL_DOWNLOADS && 52 if (status_ != DownloadRequestManager::ALLOW_ALL_DOWNLOADS &&
53 status_ != DownloadRequestManager::DOWNLOADS_NOT_ALLOWED) { 53 status_ != DownloadRequestManager::DOWNLOADS_NOT_ALLOWED) {
54 // Revert to default status. 54 // Revert to default status.
55 host_->Remove(this); 55 host_->Remove(this);
56 // WARNING: We've been deleted. 56 // WARNING: We've been deleted.
57 return; 57 return;
58 } 58 }
59 } 59 }
60 60
61 void DownloadRequestManager::TabDownloadState::PromptUserForDownload( 61 bool DownloadRequestManager::TabDownloadState::PromptUserForDownload(
62 TabContents* tab, 62 TabContents* tab,
63 DownloadRequestManager::Callback* callback) { 63 DownloadRequestManager::Callback* callback) {
64 callbacks_.push_back(callback); 64 callbacks_.push_back(callback);
65 65
66 if (is_showing_prompt()) 66 if (is_showing_prompt())
67 return; // Already showing prompt. 67 return true; // Already showing prompt.
68 68
69 if (DownloadRequestManager::delegate_) { 69 if (DownloadRequestManager::delegate_) {
70 NotifyCallbacks(DownloadRequestManager::delegate_->ShouldAllowDownload()); 70 NotifyCallbacks(DownloadRequestManager::delegate_->ShouldAllowDownload());
71 } else { 71 } else {
72 dialog_delegate_ = DownloadRequestDialogDelegate::Create(tab, this); 72 dialog_delegate_ = DownloadRequestDialogDelegate::Create(tab, this);
73 if (!dialog_delegate_)
74 return false;
73 } 75 }
76 return true;
74 } 77 }
75 78
76 void DownloadRequestManager::TabDownloadState::Cancel() { 79 void DownloadRequestManager::TabDownloadState::Cancel() {
77 NotifyCallbacks(false); 80 NotifyCallbacks(false);
78 } 81 }
79 82
80 void DownloadRequestManager::TabDownloadState::Accept() { 83 void DownloadRequestManager::TabDownloadState::Accept() {
81 NotifyCallbacks(true); 84 NotifyCallbacks(true);
82 } 85 }
83 86
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 case ALLOW_ONE_DOWNLOAD: 257 case ALLOW_ONE_DOWNLOAD:
255 state->set_download_status(PROMPT_BEFORE_DOWNLOAD); 258 state->set_download_status(PROMPT_BEFORE_DOWNLOAD);
256 ScheduleNotification(callback, true); 259 ScheduleNotification(callback, true);
257 break; 260 break;
258 261
259 case DOWNLOADS_NOT_ALLOWED: 262 case DOWNLOADS_NOT_ALLOWED:
260 ScheduleNotification(callback, false); 263 ScheduleNotification(callback, false);
261 break; 264 break;
262 265
263 case PROMPT_BEFORE_DOWNLOAD: 266 case PROMPT_BEFORE_DOWNLOAD:
264 state->PromptUserForDownload(effective_tab, callback); 267 // Conceivably, for some reason (e.g., already have another tab-modal
268 // dialog up), we may not be able display a prompt. In that case, default
269 // to denial.
270 if (!state->PromptUserForDownload(effective_tab, callback))
271 ScheduleNotification(callback, false);
265 break; 272 break;
266 273
267 default: 274 default:
268 NOTREACHED(); 275 NOTREACHED();
269 } 276 }
270 } 277 }
271 278
272 void DownloadRequestManager::ScheduleNotification(Callback* callback, 279 void DownloadRequestManager::ScheduleNotification(Callback* callback,
273 bool allow) { 280 bool allow) {
274 if (io_loop_) { 281 if (io_loop_) {
(...skipping 16 matching lines...) Expand all
291 298
292 void DownloadRequestManager::Remove(TabDownloadState* state) { 299 void DownloadRequestManager::Remove(TabDownloadState* state) {
293 DCHECK(state_map_.find(state->controller()) != state_map_.end()); 300 DCHECK(state_map_.find(state->controller()) != state_map_.end());
294 state_map_.erase(state->controller()); 301 state_map_.erase(state->controller());
295 delete state; 302 delete state;
296 } 303 }
297 304
298 // static 305 // static
299 DownloadRequestManager::TestingDelegate* DownloadRequestManager::delegate_ = 306 DownloadRequestManager::TestingDelegate* DownloadRequestManager::delegate_ =
300 NULL; 307 NULL;
OLDNEW
« no previous file with comments | « chrome/browser/download/download_request_manager.h ('k') | chrome/browser/download/save_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698