| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #import "chrome/browser/cocoa/toolbar_controller.h" | 5 #import "chrome/browser/cocoa/toolbar_controller.h" |
| 6 | 6 |
| 7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
| 8 #include "base/mac_util.h" | 8 #include "base/mac_util.h" |
| 9 #include "base/nsimage_cache_mac.h" | 9 #include "base/nsimage_cache_mac.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| 11 #include "base/gfx/rect.h" | 11 #include "base/gfx/rect.h" |
| 12 #include "chrome/app/chrome_dll_resource.h" | 12 #include "chrome/app/chrome_dll_resource.h" |
| 13 #include "chrome/browser/app_menu_model.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 14 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
| 14 #include "chrome/browser/browser.h" | 15 #include "chrome/browser/browser.h" |
| 15 #include "chrome/browser/bubble_positioner.h" | 16 #include "chrome/browser/bubble_positioner.h" |
| 16 #import "chrome/browser/cocoa/autocomplete_text_field.h" | 17 #import "chrome/browser/cocoa/autocomplete_text_field.h" |
| 17 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" | 18 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" |
| 18 #import "chrome/browser/cocoa/back_forward_menu_controller.h" | 19 #import "chrome/browser/cocoa/back_forward_menu_controller.h" |
| 19 #import "chrome/browser/cocoa/background_gradient_view.h" | 20 #import "chrome/browser/cocoa/background_gradient_view.h" |
| 20 #import "chrome/browser/cocoa/encoding_menu_controller_delegate_mac.h" | 21 #import "chrome/browser/cocoa/encoding_menu_controller_delegate_mac.h" |
| 21 #import "chrome/browser/cocoa/extensions/browser_actions_controller.h" | 22 #import "chrome/browser/cocoa/extensions/browser_actions_controller.h" |
| 22 #import "chrome/browser/cocoa/gradient_button_cell.h" | 23 #import "chrome/browser/cocoa/gradient_button_cell.h" |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 [locationBar_ setFrame:[self adjustRect:[locationBar_ frame] | 466 [locationBar_ setFrame:[self adjustRect:[locationBar_ frame] |
| 466 byAmount:moveX]]; | 467 byAmount:moveX]]; |
| 467 [homeButton_ setHidden:hide]; | 468 [homeButton_ setHidden:hide]; |
| 468 } | 469 } |
| 469 | 470 |
| 470 // Lazily install the menus on the page and wrench buttons. Calling this | 471 // Lazily install the menus on the page and wrench buttons. Calling this |
| 471 // repeatedly is inexpensive so it can be done every time the buttons are shown. | 472 // repeatedly is inexpensive so it can be done every time the buttons are shown. |
| 472 - (void)installPageWrenchMenus { | 473 - (void)installPageWrenchMenus { |
| 473 if (pageMenuModel_.get()) | 474 if (pageMenuModel_.get()) |
| 474 return; | 475 return; |
| 475 pageMenuDelegate_.reset( | 476 menuDelegate_.reset(new ToolbarControllerInternal::MenuDelegate(browser_)); |
| 476 new ToolbarControllerInternal::MenuDelegate(browser_)); | 477 pageMenuModel_.reset(new PageMenuModel(menuDelegate_.get(), browser_)); |
| 477 pageMenuModel_.reset(new PageMenuModel(pageMenuDelegate_.get(), browser_)); | |
| 478 pageMenuController_.reset( | 478 pageMenuController_.reset( |
| 479 [[MenuController alloc] initWithModel:pageMenuModel_.get() | 479 [[MenuController alloc] initWithModel:pageMenuModel_.get() |
| 480 useWithPopUpButtonCell:YES]); | 480 useWithPopUpButtonCell:YES]); |
| 481 [pageButton_ setAttachedMenu:[pageMenuController_ menu]]; | 481 [pageButton_ setAttachedMenu:[pageMenuController_ menu]]; |
| 482 |
| 483 appMenuModel_.reset(new AppMenuModel(menuDelegate_.get(), browser_)); |
| 484 appMenuController_.reset( |
| 485 [[MenuController alloc] initWithModel:appMenuModel_.get() |
| 486 useWithPopUpButtonCell:YES]); |
| 487 [wrenchButton_ setAttachedMenu:[appMenuController_ menu]]; |
| 482 } | 488 } |
| 483 | 489 |
| 484 // Show or hide the page and wrench buttons based on the pref. | 490 // Show or hide the page and wrench buttons based on the pref. |
| 485 - (void)showOptionalPageWrenchButtons { | 491 - (void)showOptionalPageWrenchButtons { |
| 486 // Ignore this message if only showing the URL bar. | 492 // Ignore this message if only showing the URL bar. |
| 487 if (!hasToolbar_) | 493 if (!hasToolbar_) |
| 488 return; | 494 return; |
| 489 DCHECK([pageButton_ isHidden] == [wrenchButton_ isHidden]); | 495 DCHECK([pageButton_ isHidden] == [wrenchButton_ isHidden]); |
| 490 BOOL hide = showPageOptionButtons_.GetValue() ? NO : YES; | 496 BOOL hide = showPageOptionButtons_.GetValue() ? NO : YES; |
| 491 if (!hide) | 497 if (!hide) |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 | 665 |
| 660 NSRect r = NSMakeRect(minX, NSMinY(locationFrame), maxX - minX, | 666 NSRect r = NSMakeRect(minX, NSMinY(locationFrame), maxX - minX, |
| 661 NSHeight(locationFrame)); | 667 NSHeight(locationFrame)); |
| 662 gfx::Rect stack_bounds( | 668 gfx::Rect stack_bounds( |
| 663 NSRectToCGRect([[self view] convertRect:r toView:nil])); | 669 NSRectToCGRect([[self view] convertRect:r toView:nil])); |
| 664 // Inset the bounds to just inside the visible edges (see comment above). | 670 // Inset the bounds to just inside the visible edges (see comment above). |
| 665 stack_bounds.Inset(kLocationStackEdgeWidth, 0); | 671 stack_bounds.Inset(kLocationStackEdgeWidth, 0); |
| 666 return stack_bounds; | 672 return stack_bounds; |
| 667 } | 673 } |
| 668 @end | 674 @end |
| OLD | NEW |