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

Side by Side Diff: chrome/browser/chromeos/notifications/balloon_view.cc

Issue 9693022: views: Rename MenuButtonDelegate::RunMenu to something more obvious. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: menu_button_listener.h Created 8 years, 9 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/notifications/balloon_view.h" 5 #include "chrome/browser/chromeos/notifications/balloon_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 16 matching lines...) Expand all
27 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
28 #include "grit/theme_resources.h" 28 #include "grit/theme_resources.h"
29 #include "grit/theme_resources_standard.h" 29 #include "grit/theme_resources_standard.h"
30 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
31 #include "ui/base/models/simple_menu_model.h" 31 #include "ui/base/models/simple_menu_model.h"
32 #include "ui/base/resource/resource_bundle.h" 32 #include "ui/base/resource/resource_bundle.h"
33 #include "ui/views/background.h" 33 #include "ui/views/background.h"
34 #include "ui/views/controls/button/button.h" 34 #include "ui/views/controls/button/button.h"
35 #include "ui/views/controls/button/image_button.h" 35 #include "ui/views/controls/button/image_button.h"
36 #include "ui/views/controls/button/menu_button.h" 36 #include "ui/views/controls/button/menu_button.h"
37 #include "ui/views/controls/button/menu_button_delegate.h" 37 #include "ui/views/controls/button/menu_button_listener.h"
38 #include "ui/views/controls/label.h" 38 #include "ui/views/controls/label.h"
39 #include "ui/views/controls/menu/menu_item_view.h" 39 #include "ui/views/controls/menu/menu_item_view.h"
40 #include "ui/views/controls/menu/menu_model_adapter.h" 40 #include "ui/views/controls/menu/menu_model_adapter.h"
41 #include "ui/views/controls/menu/menu_runner.h" 41 #include "ui/views/controls/menu/menu_runner.h"
42 #include "ui/views/widget/widget.h" 42 #include "ui/views/widget/widget.h"
43 43
44 using content::RenderWidgetHostView; 44 using content::RenderWidgetHostView;
45 45
46 namespace { 46 namespace {
47 // Menu commands 47 // Menu commands
48 const int kNoopCommand = 0; 48 const int kNoopCommand = 0;
49 const int kRevokePermissionCommand = 1; 49 const int kRevokePermissionCommand = 1;
50 50
51 // Vertical margin between close button and menu button. 51 // Vertical margin between close button and menu button.
52 const int kControlButtonsMargin = 6; 52 const int kControlButtonsMargin = 6;
53 53
54 // Top, Right margin for notification control view. 54 // Top, Right margin for notification control view.
55 const int kControlViewTopMargin = 4; 55 const int kControlViewTopMargin = 4;
56 const int kControlViewRightMargin = 6; 56 const int kControlViewRightMargin = 6;
57 } // namespace 57 } // namespace
58 58
59 namespace chromeos { 59 namespace chromeos {
60 60
61 // NotificationControlView has close and menu buttons and 61 // NotificationControlView has close and menu buttons and
62 // overlays on top of renderer view. 62 // overlays on top of renderer view.
63 class NotificationControlView : public views::View, 63 class NotificationControlView : public views::View,
64 public views::MenuButtonDelegate, 64 public views::MenuButtonListener,
65 public ui::SimpleMenuModel::Delegate, 65 public ui::SimpleMenuModel::Delegate,
66 public views::ButtonListener { 66 public views::ButtonListener {
67 public: 67 public:
68 explicit NotificationControlView(BalloonViewImpl* view) 68 explicit NotificationControlView(BalloonViewImpl* view)
69 : balloon_view_(view), 69 : balloon_view_(view),
70 close_button_(NULL), 70 close_button_(NULL),
71 options_menu_contents_(NULL), 71 options_menu_contents_(NULL),
72 options_menu_button_(NULL) { 72 options_menu_button_(NULL) {
73 // TODO(oshima): make background transparent. 73 // TODO(oshima): make background transparent.
74 set_background(views::Background::CreateSolidBackground(SK_ColorWHITE)); 74 set_background(views::Background::CreateSolidBackground(SK_ColorWHITE));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 SizeToPreferredSize(); 115 SizeToPreferredSize();
116 } 116 }
117 117
118 virtual gfx::Size GetPreferredSize() { 118 virtual gfx::Size GetPreferredSize() {
119 gfx::Rect total_bounds = 119 gfx::Rect total_bounds =
120 close_button_->bounds().Union(options_menu_button_->bounds()); 120 close_button_->bounds().Union(options_menu_button_->bounds());
121 return total_bounds.size(); 121 return total_bounds.size();
122 } 122 }
123 123
124 // views::MenuButtonDelegate implements. 124 // Overridden from views::MenuButtonListener:
125 virtual void RunMenu(views::View* source, const gfx::Point& pt) { 125 virtual void OnMenuButtonClicked(views::View* source,
126 const gfx::Point& point) OVERRIDE {
126 CreateOptionsMenu(); 127 CreateOptionsMenu();
127 128
128 views::MenuModelAdapter menu_model_adapter(options_menu_contents_.get()); 129 views::MenuModelAdapter menu_model_adapter(options_menu_contents_.get());
129 menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu())); 130 menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu()));
130 131
131 gfx::Point screen_location; 132 gfx::Point screen_location;
132 views::View::ConvertPointToScreen(options_menu_button_, &screen_location); 133 views::View::ConvertPointToScreen(options_menu_button_, &screen_location);
133 if (menu_runner_->RunMenuAt( 134 if (menu_runner_->RunMenuAt(
134 source->GetWidget()->GetTopLevelWidget(), options_menu_button_, 135 source->GetWidget()->GetTopLevelWidget(), options_menu_button_,
135 gfx::Rect(screen_location, options_menu_button_->size()), 136 gfx::Rect(screen_location, options_menu_button_->size()),
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 } 366 }
366 367
367 gfx::NativeView BalloonViewImpl::GetParentNativeView() { 368 gfx::NativeView BalloonViewImpl::GetParentNativeView() {
368 RenderWidgetHostView* view = 369 RenderWidgetHostView* view =
369 html_contents_->web_contents()->GetRenderViewHost()->GetView(); 370 html_contents_->web_contents()->GetRenderViewHost()->GetView();
370 DCHECK(view); 371 DCHECK(view);
371 return view->GetNativeView(); 372 return view->GetNativeView();
372 } 373 }
373 374
374 } // namespace chromeos 375 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/language_switch_menu.cc ('k') | chrome/browser/chromeos/status/accessibility_menu_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698