summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/views/download/download_item_view.cc41
-rw-r--r--chrome/browser/ui/views/download/download_item_view.h4
-rw-r--r--chrome/browser/ui/views/download/download_shelf_context_menu_view.cc39
-rw-r--r--chrome/browser/ui/views/download/download_shelf_context_menu_view.h40
-rw-r--r--chrome/chrome_browser.gypi4
5 files changed, 87 insertions, 41 deletions
diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc
index a4b85c0..0be0d11 100644
--- a/chrome/browser/ui/views/download/download_item_view.cc
+++ b/chrome/browser/ui/views/download/download_item_view.cc
@@ -16,9 +16,9 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_item_model.h"
-#include "chrome/browser/download/download_shelf_context_menu.h"
#include "chrome/browser/download/download_util.h"
#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h"
#include "chrome/browser/ui/views/download/download_shelf_view.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -33,7 +33,6 @@
#include "unicode/uchar.h"
#include "views/controls/button/native_button.h"
#include "views/controls/label.h"
-#include "views/controls/menu/menu_2.h"
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
@@ -79,42 +78,6 @@ static const int kDisabledOnOpenDuration = 3000;
// light-on-dark themes.
static const double kDownloadItemLuminanceMod = 0.8;
-// DownloadShelfContextMenuWin -------------------------------------------------
-
-class DownloadShelfContextMenuWin : public DownloadShelfContextMenu {
- public:
- explicit DownloadShelfContextMenuWin(BaseDownloadItemModel* model)
- : DownloadShelfContextMenu(model) {
- DCHECK(model);
- }
-
- void Run(const gfx::Point& point) {
- if (download_item()->IsComplete())
- menu_.reset(new views::Menu2(GetFinishedMenuModel()));
- else
- menu_.reset(new views::Menu2(GetInProgressMenuModel()));
-
- // The menu's alignment is determined based on the UI layout.
- views::Menu2::Alignment alignment;
- if (base::i18n::IsRTL())
- alignment = views::Menu2::ALIGN_TOPRIGHT;
- else
- alignment = views::Menu2::ALIGN_TOPLEFT;
- menu_->RunMenuAt(point, alignment);
- }
-
- // This method runs when the caller has been deleted and we should not attempt
- // to access |download_|.
- void Stop() {
- set_download_item(NULL);
- }
-
- private:
- scoped_ptr<views::Menu2> menu_;
-};
-
-// DownloadItemView ------------------------------------------------------------
-
DownloadItemView::DownloadItemView(DownloadItem* download,
DownloadShelfView* parent,
BaseDownloadItemModel* model)
@@ -661,7 +624,7 @@ void DownloadItemView::ShowContextMenu(const gfx::Point& p,
views::View::ConvertPointToScreen(this, &point);
if (!context_menu_.get())
- context_menu_.reset(new DownloadShelfContextMenuWin(model_.get()));
+ context_menu_.reset(new DownloadShelfContextMenuView(model_.get()));
// When we call the Run method on the menu, it runs an inner message loop
// that might causes us to be deleted.
bool deleted = false;
diff --git a/chrome/browser/ui/views/download/download_item_view.h b/chrome/browser/ui/views/download/download_item_view.h
index 295d52d..4fe8f46 100644
--- a/chrome/browser/ui/views/download/download_item_view.h
+++ b/chrome/browser/ui/views/download/download_item_view.h
@@ -36,7 +36,7 @@
class BaseDownloadItemModel;
class DownloadShelfView;
class SkBitmap;
-class DownloadShelfContextMenuWin;
+class DownloadShelfContextMenuView;
namespace gfx {
class Image;
@@ -276,7 +276,7 @@ class DownloadItemView : public views::ButtonListener,
ScopedRunnableMethodFactory<DownloadItemView> reenable_method_factory_;
// The currently running download context menu.
- scoped_ptr<DownloadShelfContextMenuWin> context_menu_;
+ scoped_ptr<DownloadShelfContextMenuView> context_menu_;
// If non-NULL, set to true when this object is deleted.
// (Used when showing the context menu as it runs an inner message loop that
diff --git a/chrome/browser/ui/views/download/download_shelf_context_menu_view.cc b/chrome/browser/ui/views/download/download_shelf_context_menu_view.cc
new file mode 100644
index 0000000..fb2736d
--- /dev/null
+++ b/chrome/browser/ui/views/download/download_shelf_context_menu_view.cc
@@ -0,0 +1,39 @@
+// Copyright (c) 2011 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/views/download/download_shelf_context_menu_view.h"
+
+#include "base/i18n/rtl.h"
+#include "base/logging.h"
+#include "chrome/browser/download/download_item.h"
+#include "chrome/browser/download/download_item_model.h"
+#include "ui/gfx/point.h"
+#include "views/controls/menu/menu_2.h"
+
+DownloadShelfContextMenuView::DownloadShelfContextMenuView(
+ BaseDownloadItemModel* model)
+ : DownloadShelfContextMenu(model) {
+ DCHECK(model);
+}
+
+DownloadShelfContextMenuView::~DownloadShelfContextMenuView() {}
+
+void DownloadShelfContextMenuView::Run(const gfx::Point& point) {
+ if (download_item()->IsComplete())
+ menu_.reset(new views::Menu2(GetFinishedMenuModel()));
+ else
+ menu_.reset(new views::Menu2(GetInProgressMenuModel()));
+
+ // The menu's alignment is determined based on the UI layout.
+ views::Menu2::Alignment alignment;
+ if (base::i18n::IsRTL())
+ alignment = views::Menu2::ALIGN_TOPRIGHT;
+ else
+ alignment = views::Menu2::ALIGN_TOPLEFT;
+ menu_->RunMenuAt(point, alignment);
+}
+
+void DownloadShelfContextMenuView::Stop() {
+ set_download_item(NULL);
+}
diff --git a/chrome/browser/ui/views/download/download_shelf_context_menu_view.h b/chrome/browser/ui/views/download/download_shelf_context_menu_view.h
new file mode 100644
index 0000000..1266005
--- /dev/null
+++ b/chrome/browser/ui/views/download/download_shelf_context_menu_view.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2011 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_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_CONTEXT_MENU_VIEW_H_
+#define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_CONTEXT_MENU_VIEW_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/download/download_shelf_context_menu.h"
+
+class BaseDownloadItemModel;
+
+namespace gfx {
+class Point;
+}
+
+namespace views {
+class Menu2;
+}
+
+class DownloadShelfContextMenuView : public DownloadShelfContextMenu {
+ public:
+ explicit DownloadShelfContextMenuView(BaseDownloadItemModel* model);
+ virtual ~DownloadShelfContextMenuView();
+
+ void Run(const gfx::Point& point);
+
+ // This method runs when the caller has been deleted and we should not attempt
+ // to access download_item().
+ void Stop();
+
+ private:
+ scoped_ptr<views::Menu2> menu_;
+
+ DISALLOW_COPY_AND_ASSIGN(DownloadShelfContextMenuView);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_CONTEXT_MENU_VIEW_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 5a8cbeb..6432159 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2972,6 +2972,8 @@
'browser/ui/views/download/download_in_progress_dialog_view.h',
'browser/ui/views/download/download_item_view.cc',
'browser/ui/views/download/download_item_view.h',
+ 'browser/ui/views/download/download_shelf_context_menu_view.cc',
+ 'browser/ui/views/download/download_shelf_context_menu_view.h',
'browser/ui/views/download/download_shelf_view.cc',
'browser/ui/views/download/download_shelf_view.h',
'browser/ui/views/download/download_started_animation_win.cc',
@@ -4044,6 +4046,8 @@
['include', '^browser/ui/views/download/download_in_progress_dialog_view.h'],
['include', '^browser/ui/views/download/download_item_view.cc'],
['include', '^browser/ui/views/download/download_item_view.h'],
+ ['include', '^browser/ui/views/download/download_shelf_context_menu_view.cc'],
+ ['include', '^browser/ui/views/download/download_shelf_context_menu_view.h'],
['include', '^browser/ui/views/download/download_shelf_view.cc'],
['include', '^browser/ui/views/download/download_shelf_view.h'],
['include', '^browser/ui/views/dragged_tab_controller.cc'],