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

Side by Side Diff: chrome/browser/ui/views/toolbar_view.cc

Issue 6693032: Remove WebUI menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 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
« no previous file with comments | « chrome/browser/chromeos/webui/wrench_menu_ui.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/views/toolbar_view.h" 5 #include "chrome/browser/ui/views/toolbar_view.h"
6 6
7 #include "base/i18n/number_formatting.h" 7 #include "base/i18n/number_formatting.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/accessibility/browser_accessibility_state.h" 10 #include "chrome/browser/accessibility/browser_accessibility_state.h"
(...skipping 22 matching lines...) Expand all
33 #include "ui/gfx/skbitmap_operations.h" 33 #include "ui/gfx/skbitmap_operations.h"
34 #include "views/controls/button/button_dropdown.h" 34 #include "views/controls/button/button_dropdown.h"
35 #include "views/focus/view_storage.h" 35 #include "views/focus/view_storage.h"
36 #include "views/widget/tooltip_manager.h" 36 #include "views/widget/tooltip_manager.h"
37 #include "views/window/non_client_view.h" 37 #include "views/window/non_client_view.h"
38 #include "views/window/window.h" 38 #include "views/window/window.h"
39 39
40 #if defined(OS_CHROMEOS) 40 #if defined(OS_CHROMEOS)
41 #include "chrome/browser/chromeos/cros/cros_library.h" 41 #include "chrome/browser/chromeos/cros/cros_library.h"
42 #include "chrome/browser/chromeos/cros/update_library.h" 42 #include "chrome/browser/chromeos/cros/update_library.h"
43 #include "chrome/browser/chromeos/webui/wrench_menu_ui.h"
44 #include "views/controls/menu/menu_2.h" 43 #include "views/controls/menu/menu_2.h"
45 #endif 44 #endif
46 #include "chrome/browser/ui/views/wrench_menu.h" 45 #include "chrome/browser/ui/views/wrench_menu.h"
47 46
48 #if defined(OS_WIN) 47 #if defined(OS_WIN)
49 #include "chrome/browser/enumerate_modules_model_win.h" 48 #include "chrome/browser/enumerate_modules_model_win.h"
50 #endif 49 #endif
51 50
52 // The space between items is 4 px in general. 51 // The space between items is 4 px in general.
53 const int ToolbarView::kStandardSpacing = 4; 52 const int ToolbarView::kStandardSpacing = 4;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // after the Browser (which owns the CommandUpdater), so the CommandUpdater is 128 // after the Browser (which owns the CommandUpdater), so the CommandUpdater is
130 // already gone. 129 // already gone.
131 } 130 }
132 131
133 void ToolbarView::Init(Profile* profile) { 132 void ToolbarView::Init(Profile* profile) {
134 back_menu_model_.reset(new BackForwardMenuModel( 133 back_menu_model_.reset(new BackForwardMenuModel(
135 browser_, BackForwardMenuModel::BACKWARD_MENU)); 134 browser_, BackForwardMenuModel::BACKWARD_MENU));
136 forward_menu_model_.reset(new BackForwardMenuModel( 135 forward_menu_model_.reset(new BackForwardMenuModel(
137 browser_, BackForwardMenuModel::FORWARD_MENU)); 136 browser_, BackForwardMenuModel::FORWARD_MENU));
138 wrench_menu_model_.reset(new WrenchMenuModel(this, browser_)); 137 wrench_menu_model_.reset(new WrenchMenuModel(this, browser_));
139 #if defined(OS_CHROMEOS)
140 if (chromeos::MenuUI::IsEnabled()) {
141 wrench_menu_2_.reset(
142 chromeos::WrenchMenuUI::CreateMenu2(wrench_menu_model_.get()));
143 }
144 #endif
145 back_ = new views::ButtonDropDown(this, back_menu_model_.get()); 138 back_ = new views::ButtonDropDown(this, back_menu_model_.get());
146 back_->set_triggerable_event_flags(ui::EF_LEFT_BUTTON_DOWN | 139 back_->set_triggerable_event_flags(ui::EF_LEFT_BUTTON_DOWN |
147 ui::EF_MIDDLE_BUTTON_DOWN); 140 ui::EF_MIDDLE_BUTTON_DOWN);
148 back_->set_tag(IDC_BACK); 141 back_->set_tag(IDC_BACK);
149 back_->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, 142 back_->SetImageAlignment(views::ImageButton::ALIGN_RIGHT,
150 views::ImageButton::ALIGN_TOP); 143 views::ImageButton::ALIGN_TOP);
151 back_->SetTooltipText( 144 back_->SetTooltipText(
152 UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_BACK))); 145 UTF16ToWide(l10n_util::GetStringUTF16(IDS_TOOLTIP_BACK)));
153 back_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK)); 146 back_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_BACK));
154 back_->SetID(VIEW_ID_BACK_BUTTON); 147 back_->SetID(VIEW_ID_BACK_BUTTON);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 254
262 void ToolbarView::SetPaneFocusAndFocusAppMenu(int view_storage_id) { 255 void ToolbarView::SetPaneFocusAndFocusAppMenu(int view_storage_id) {
263 SetPaneFocus(view_storage_id, app_menu_); 256 SetPaneFocus(view_storage_id, app_menu_);
264 } 257 }
265 258
266 bool ToolbarView::IsAppMenuFocused() { 259 bool ToolbarView::IsAppMenuFocused() {
267 return app_menu_->HasFocus(); 260 return app_menu_->HasFocus();
268 } 261 }
269 262
270 void ToolbarView::AddMenuListener(views::MenuListener* listener) { 263 void ToolbarView::AddMenuListener(views::MenuListener* listener) {
271 #if defined(OS_CHROMEOS)
272 if (chromeos::MenuUI::IsEnabled()) {
273 DCHECK(wrench_menu_2_.get());
274 wrench_menu_2_->AddMenuListener(listener);
275 return;
276 }
277 #endif
278 menu_listeners_.push_back(listener); 264 menu_listeners_.push_back(listener);
279 } 265 }
280 266
281 void ToolbarView::RemoveMenuListener(views::MenuListener* listener) { 267 void ToolbarView::RemoveMenuListener(views::MenuListener* listener) {
282 #if defined(OS_CHROMEOS)
283 if (chromeos::MenuUI::IsEnabled()) {
284 DCHECK(wrench_menu_2_.get());
285 wrench_menu_2_->RemoveMenuListener(listener);
286 return;
287 }
288 #endif
289 for (std::vector<views::MenuListener*>::iterator i(menu_listeners_.begin()); 268 for (std::vector<views::MenuListener*>::iterator i(menu_listeners_.begin());
290 i != menu_listeners_.end(); ++i) { 269 i != menu_listeners_.end(); ++i) {
291 if (*i == listener) { 270 if (*i == listener) {
292 menu_listeners_.erase(i); 271 menu_listeners_.erase(i);
293 return; 272 return;
294 } 273 }
295 } 274 }
296 } 275 }
297 276
298 //////////////////////////////////////////////////////////////////////////////// 277 ////////////////////////////////////////////////////////////////////////////////
(...skipping 21 matching lines...) Expand all
320 } 299 }
321 300
322 //////////////////////////////////////////////////////////////////////////////// 301 ////////////////////////////////////////////////////////////////////////////////
323 // ToolbarView, views::MenuDelegate implementation: 302 // ToolbarView, views::MenuDelegate implementation:
324 303
325 void ToolbarView::RunMenu(views::View* source, const gfx::Point& /* pt */) { 304 void ToolbarView::RunMenu(views::View* source, const gfx::Point& /* pt */) {
326 DCHECK_EQ(VIEW_ID_APP_MENU, source->GetID()); 305 DCHECK_EQ(VIEW_ID_APP_MENU, source->GetID());
327 306
328 bool destroyed_flag = false; 307 bool destroyed_flag = false;
329 destroyed_flag_ = &destroyed_flag; 308 destroyed_flag_ = &destroyed_flag;
330 #if defined(OS_CHROMEOS)
331 if (chromeos::MenuUI::IsEnabled()) {
332 gfx::Point screen_loc;
333 views::View::ConvertPointToScreen(app_menu_, &screen_loc);
334 gfx::Rect bounds(screen_loc, app_menu_->size());
335 if (base::i18n::IsRTL())
336 bounds.set_x(bounds.x() - app_menu_->size().width());
337 wrench_menu_2_->RunMenuAt(gfx::Point(bounds.right(), bounds.bottom()),
338 views::Menu2::ALIGN_TOPRIGHT);
339 // TODO(oshima): nuke this once we made decision about go or no go
340 // for WebUI menu.
341 goto cleanup;
342 }
343 #endif
344 wrench_menu_ = new WrenchMenu(browser_); 309 wrench_menu_ = new WrenchMenu(browser_);
345 wrench_menu_->Init(wrench_menu_model_.get()); 310 wrench_menu_->Init(wrench_menu_model_.get());
346 311
347 for (size_t i = 0; i < menu_listeners_.size(); ++i) 312 for (size_t i = 0; i < menu_listeners_.size(); ++i)
348 menu_listeners_[i]->OnMenuOpened(); 313 menu_listeners_[i]->OnMenuOpened();
349 314
350 wrench_menu_->RunMenu(app_menu_); 315 wrench_menu_->RunMenu(app_menu_);
351 316
352 #if defined(OS_CHROMEOS)
353 cleanup:
354 #endif
355 if (destroyed_flag) 317 if (destroyed_flag)
356 return; 318 return;
357 destroyed_flag_ = NULL; 319 destroyed_flag_ = NULL;
358 } 320 }
359 321
360 //////////////////////////////////////////////////////////////////////////////// 322 ////////////////////////////////////////////////////////////////////////////////
361 // ToolbarView, LocationBarView::Delegate implementation: 323 // ToolbarView, LocationBarView::Delegate implementation:
362 324
363 TabContentsWrapper* ToolbarView::GetTabContentsWrapper() { 325 TabContentsWrapper* ToolbarView::GetTabContentsWrapper() {
364 return browser_->GetSelectedTabContentsWrapper(); 326 return browser_->GetSelectedTabContentsWrapper();
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 NOTREACHED(); 741 NOTREACHED();
780 #endif 742 #endif
781 } else { 743 } else {
782 NOTREACHED(); 744 NOTREACHED();
783 } 745 }
784 746
785 canvas->DrawBitmapInt(badge, icon.width() - badge.width(), kBadgeTopMargin); 747 canvas->DrawBitmapInt(badge, icon.width() - badge.width(), kBadgeTopMargin);
786 748
787 return canvas->ExtractBitmap(); 749 return canvas->ExtractBitmap();
788 } 750 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/webui/wrench_menu_ui.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698