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

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

Issue 7720012: Moves ownership of MenuItemView to MenuRunner as well as responbility (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 7 #include <vector>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 16 matching lines...) Expand all
27 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/models/simple_menu_model.h" 28 #include "ui/base/models/simple_menu_model.h"
29 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
30 #include "views/background.h" 30 #include "views/background.h"
31 #include "views/controls/button/button.h" 31 #include "views/controls/button/button.h"
32 #include "views/controls/button/image_button.h" 32 #include "views/controls/button/image_button.h"
33 #include "views/controls/button/menu_button.h" 33 #include "views/controls/button/menu_button.h"
34 #include "views/controls/label.h" 34 #include "views/controls/label.h"
35 #include "views/controls/menu/menu_item_view.h" 35 #include "views/controls/menu/menu_item_view.h"
36 #include "views/controls/menu/menu_model_adapter.h" 36 #include "views/controls/menu/menu_model_adapter.h"
37 #include "views/controls/menu/menu_runner.h"
37 #include "views/controls/menu/view_menu_delegate.h" 38 #include "views/controls/menu/view_menu_delegate.h"
38 #include "views/widget/widget.h" 39 #include "views/widget/widget.h"
39 40
40 namespace { 41 namespace {
41 // Menu commands 42 // Menu commands
42 const int kNoopCommand = 0; 43 const int kNoopCommand = 0;
43 const int kRevokePermissionCommand = 1; 44 const int kRevokePermissionCommand = 1;
44 45
45 // Vertical margin between close button and menu button. 46 // Vertical margin between close button and menu button.
46 const int kControlButtonsMargin = 6; 47 const int kControlButtonsMargin = 6;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 gfx::Rect total_bounds = 114 gfx::Rect total_bounds =
114 close_button_->bounds().Union(options_menu_button_->bounds()); 115 close_button_->bounds().Union(options_menu_button_->bounds());
115 return total_bounds.size(); 116 return total_bounds.size();
116 } 117 }
117 118
118 // views::ViewMenuDelegate implements. 119 // views::ViewMenuDelegate implements.
119 virtual void RunMenu(views::View* source, const gfx::Point& pt) { 120 virtual void RunMenu(views::View* source, const gfx::Point& pt) {
120 CreateOptionsMenu(); 121 CreateOptionsMenu();
121 122
122 views::MenuModelAdapter menu_model_adapter(options_menu_contents_.get()); 123 views::MenuModelAdapter menu_model_adapter(options_menu_contents_.get());
123 views::MenuItemView menu(&menu_model_adapter); 124 views::MenuRunner menu_runner(menu_model_adapter.CreateMenu());
124 menu_model_adapter.BuildMenu(&menu);
125 125
126 gfx::Point screen_location; 126 gfx::Point screen_location;
127 views::View::ConvertPointToScreen(options_menu_button_, 127 views::View::ConvertPointToScreen(options_menu_button_,
128 &screen_location); 128 &screen_location);
129 menu.RunMenuAt(source->GetWidget()->GetTopLevelWidget(), 129 if (menu_runner.RunMenuAt(
130 options_menu_button_, 130 source->GetWidget()->GetTopLevelWidget(), options_menu_button_,
131 gfx::Rect(screen_location, options_menu_button_->size()), 131 gfx::Rect(screen_location, options_menu_button_->size()),
132 views::MenuItemView::TOPRIGHT, 132 views::MenuItemView::TOPRIGHT, views::MenuRunner::HAS_MNEMONICS) ==
133 true); 133 views::MenuRunner::MENU_DELETED)
134 return;
134 } 135 }
135 136
136 // views::ButtonListener implements. 137 // views::ButtonListener implements.
137 virtual void ButtonPressed(views::Button* sender, const views::Event&) { 138 virtual void ButtonPressed(views::Button* sender, const views::Event&) {
138 balloon_view_->Close(true); 139 balloon_view_->Close(true);
139 } 140 }
140 141
141 // ui::SimpleMenuModel::Delegate impglements. 142 // ui::SimpleMenuModel::Delegate impglements.
142 virtual bool IsCommandIdChecked(int /* command_id */) const { 143 virtual bool IsCommandIdChecked(int /* command_id */) const {
143 // Nothing in the menu is checked. 144 // Nothing in the menu is checked.
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 service->DenyPermission(balloon_->notification().origin_url()); 358 service->DenyPermission(balloon_->notification().origin_url());
358 } 359 }
359 360
360 gfx::NativeView BalloonViewImpl::GetParentNativeView() { 361 gfx::NativeView BalloonViewImpl::GetParentNativeView() {
361 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); 362 RenderWidgetHostView* view = html_contents_->render_view_host()->view();
362 DCHECK(view); 363 DCHECK(view);
363 return view->GetNativeView(); 364 return view->GetNativeView();
364 } 365 }
365 366
366 } // namespace chromeos 367 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698