summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa/download/download_shelf_mac.mm
blob: cf14be75ecc54bfa5be085e97b5d463db7ef8b0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2012 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/ui/cocoa/download/download_shelf_mac.h"

#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/cocoa/download/download_item_mac.h"
#import "chrome/browser/ui/cocoa/download/download_shelf_controller.h"

DownloadShelfMac::DownloadShelfMac(Browser* browser,
                                   DownloadShelfController* controller)
    : browser_(browser),
      shelf_controller_(controller) {
}

void DownloadShelfMac::DoAddDownload(content::DownloadItem* download) {
  [shelf_controller_ addDownloadItem:download];
}

bool DownloadShelfMac::IsShowing() const {
  return [shelf_controller_ isVisible] == YES;
}

bool DownloadShelfMac::IsClosing() const {
  // TODO(estade): This is never called. For now just return false.
  return false;
}

void DownloadShelfMac::DoShow() {
  [shelf_controller_ showDownloadShelf:YES
                          isUserAction:NO];
  browser_->UpdateDownloadShelfVisibility(true);
}

void DownloadShelfMac::DoClose(CloseReason reason) {
  [shelf_controller_ showDownloadShelf:NO
                          isUserAction:reason == USER_ACTION];
  browser_->UpdateDownloadShelfVisibility(false);
}

Browser* DownloadShelfMac::browser() const {
  return browser_;
}