summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 20:12:50 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 20:12:50 +0000
commit58db2f88917448f794deeee45868137d9098339a (patch)
tree0aa9feba219c093223542830c3e9951aa8f63ec1 /chrome/browser/cocoa
parent66814bb0eb9fd82cb6acd58ddc9292555bd98322 (diff)
downloadchromium_src-58db2f88917448f794deeee45868137d9098339a.zip
chromium_src-58db2f88917448f794deeee45868137d9098339a.tar.gz
chromium_src-58db2f88917448f794deeee45868137d9098339a.tar.bz2
Make the multiple download request dialog an infobar.
The icon is a placeholder until Glen makes a pretty one. BUG=24047 TEST=go to skypher.com/SkyLined/Repro/Chrome/carpet bombing/repro.html allow, deny, closing infobar, and closing tab all work as expected Review URL: http://codereview.chromium.org/275011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29006 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/download_request_dialog_delegate_mac.h43
-rw-r--r--chrome/browser/cocoa/download_request_dialog_delegate_mac.mm104
2 files changed, 0 insertions, 147 deletions
diff --git a/chrome/browser/cocoa/download_request_dialog_delegate_mac.h b/chrome/browser/cocoa/download_request_dialog_delegate_mac.h
deleted file mode 100644
index f12ae19..0000000
--- a/chrome/browser/cocoa/download_request_dialog_delegate_mac.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_DIALOG_DELEGATE_MAC_H_
-#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_DIALOG_DELEGATE_MAC_H_
-
-#include "base/scoped_nsobject.h"
-#include "base/scoped_ptr.h"
-#include "chrome/browser/cocoa/constrained_window_mac.h"
-#include "chrome/browser/download/download_request_dialog_delegate.h"
-#include "chrome/browser/download/download_request_manager.h"
-
-@class SheetCallback;
-class TabContents;
-
-class DownloadRequestDialogDelegateMac : public DownloadRequestDialogDelegate,
- public ConstrainedWindowMacDelegateSystemSheet {
- public:
- DownloadRequestDialogDelegateMac(TabContents* tab,
- DownloadRequestManager::TabDownloadState* host);
-
- // Implement ConstrainedWindowMacDelegateSystemSheet.
- virtual void DeleteDelegate();
-
- // Called when the sheet is done.
- void SheetDidEnd(int returnCode);
-
- private:
- // DownloadRequestDialogDelegate methods.
- virtual void CloseWindow();
-
- // The ConstrainedWindow that is hosting our DownloadRequestDialog.
- ConstrainedWindow* window_;
-
- // Has a button on the sheet been clicked?
- bool responded_;
-
- DISALLOW_COPY_AND_ASSIGN(DownloadRequestDialogDelegateMac);
-};
-
-#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_DIALOG_DELEGATE_MAC_H_
-
diff --git a/chrome/browser/cocoa/download_request_dialog_delegate_mac.mm b/chrome/browser/cocoa/download_request_dialog_delegate_mac.mm
deleted file mode 100644
index 4f5e29a..0000000
--- a/chrome/browser/cocoa/download_request_dialog_delegate_mac.mm
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/cocoa/download_request_dialog_delegate_mac.h"
-
-#import <Cocoa/Cocoa.h>
-
-#include "app/l10n_util_mac.h"
-#include "app/message_box_flags.h"
-#include "base/sys_string_conversions.h"
-#include "chrome/browser/tab_contents/constrained_window.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-#include "grit/generated_resources.h"
-
-@interface SheetCallback : NSObject {
- DownloadRequestDialogDelegateMac* target_; // weak
-}
-- (id)initWithTarget:(DownloadRequestDialogDelegateMac*)target;
-- (void) alertDidEnd:(NSAlert *)alert
- returnCode:(int)returnCode
- contextInfo:(void *)contextInfo;
-@end
-
-@implementation SheetCallback
-- (id)initWithTarget:(DownloadRequestDialogDelegateMac*)target {
- if ((self = [super init]) != nil) {
- target_ = target;
- }
- return self;
-}
-- (void)alertDidEnd:(NSAlert *)alert
- returnCode:(int)returnCode
- contextInfo:(void *)contextInfo {
- target_->SheetDidEnd(returnCode);
-}
-@end
-
-
-// static
-DownloadRequestDialogDelegate* DownloadRequestDialogDelegate::Create(
- TabContents* tab,
- DownloadRequestManager::TabDownloadState* host) {
- return new DownloadRequestDialogDelegateMac(tab, host);
-}
-
-DownloadRequestDialogDelegateMac::DownloadRequestDialogDelegateMac(
- TabContents* tab,
- DownloadRequestManager::TabDownloadState* host)
- : DownloadRequestDialogDelegate(host),
- ConstrainedWindowMacDelegateSystemSheet(
- [[[SheetCallback alloc] initWithTarget:this] autorelease],
- @selector(alertDidEnd:returnCode:contextInfo:)),
- responded_(false) {
-
- // Set up alert.
- NSAlert* alert = [[[NSAlert alloc] init] autorelease];
- [alert addButtonWithTitle:
- l10n_util::GetNSStringWithFixup(IDS_MULTI_DOWNLOAD_WARNING_ALLOW)];
- NSButton* denyButton = [alert addButtonWithTitle:
- l10n_util::GetNSStringWithFixup(IDS_MULTI_DOWNLOAD_WARNING_DENY)];
- [alert setMessageText:
- l10n_util::GetNSStringWithFixup(IDS_MULTI_DOWNLOAD_WARNING)];
- [alert setAlertStyle:NSInformationalAlertStyle];
-
- // Cocoa automatically gives ESC as a key equivalent to buttons with the text
- // "Cancel". Since we use a different text, we have to set this ourselves.
- NSString* escapeKey = @"\e";
- [denyButton setKeyEquivalent:escapeKey];
-
- set_sheet(alert);
-
- // Display alert in a per-tab sheet.
- window_ = tab->CreateConstrainedDialog(this);
-}
-
-void DownloadRequestDialogDelegateMac::CloseWindow() {
- window_->CloseConstrainedWindow();
-}
-
-void DownloadRequestDialogDelegateMac::DeleteDelegate() {
- if (is_sheet_open()) {
- // Close sheet if it's still open.
- [NSApp endSheet:[(NSAlert*)sheet() window]]; // calls SheetDidEnd().
- DCHECK(responded_);
- }
- if (!responded_) {
- // Happens if the sheet was never visible.
- responded_ = true;
- DoCancel();
- }
- DCHECK(!host_);
- delete this;
-}
-
-void DownloadRequestDialogDelegateMac::SheetDidEnd(int returnCode) {
- DCHECK(!responded_);
- if (returnCode == NSAlertFirstButtonReturn) {
- DoAccept();
- } else {
- DoCancel();
- }
- responded_ = true;
-}