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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_cocoa.mm

Issue 8135001: Fixed behavior of the bookmark bar visibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DCHECK_EQ instead of DCHECK Created 9 years, 2 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/ui/cocoa/browser_window_cocoa.h" 5 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 25 matching lines...) Expand all
36 #include "chrome/browser/ui/cocoa/task_manager_mac.h" 36 #include "chrome/browser/ui/cocoa/task_manager_mac.h"
37 #import "chrome/browser/ui/cocoa/theme_install_bubble_view.h" 37 #import "chrome/browser/ui/cocoa/theme_install_bubble_view.h"
38 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 38 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
39 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 39 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
40 #include "chrome/browser/ui/webui/task_manager_dialog.h" 40 #include "chrome/browser/ui/webui/task_manager_dialog.h"
41 #include "chrome/common/chrome_notification_types.h" 41 #include "chrome/common/chrome_notification_types.h"
42 #include "chrome/common/chrome_switches.h" 42 #include "chrome/common/chrome_switches.h"
43 #include "chrome/common/pref_names.h" 43 #include "chrome/common/pref_names.h"
44 #include "content/browser/tab_contents/tab_contents.h" 44 #include "content/browser/tab_contents/tab_contents.h"
45 #include "content/common/native_web_keyboard_event.h" 45 #include "content/common/native_web_keyboard_event.h"
46 #include "content/common/notification_details.h"
46 #include "content/common/notification_service.h" 47 #include "content/common/notification_service.h"
47 #include "grit/chromium_strings.h" 48 #include "grit/chromium_strings.h"
48 #include "grit/generated_resources.h" 49 #include "grit/generated_resources.h"
49 #include "ui/base/l10n/l10n_util_mac.h" 50 #include "ui/base/l10n/l10n_util_mac.h"
50 #include "ui/gfx/rect.h" 51 #include "ui/gfx/rect.h"
51 52
52 // Replicate specific 10.7 SDK declarations for building with prior SDKs. 53 // Replicate specific 10.7 SDK declarations for building with prior SDKs.
53 #if !defined(MAC_OS_X_VERSION_10_7) || \ 54 #if !defined(MAC_OS_X_VERSION_10_7) || \
54 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 55 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
55 56
(...skipping 11 matching lines...) Expand all
67 - (void)setAnimationBehavior:(NSWindowAnimationBehavior)newAnimationBehavior; 68 - (void)setAnimationBehavior:(NSWindowAnimationBehavior)newAnimationBehavior;
68 @end 69 @end
69 70
70 #endif // MAC_OS_X_VERSION_10_7 71 #endif // MAC_OS_X_VERSION_10_7
71 72
72 BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser, 73 BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser,
73 BrowserWindowController* controller) 74 BrowserWindowController* controller)
74 : browser_(browser), 75 : browser_(browser),
75 controller_(controller), 76 controller_(controller),
76 confirm_close_factory_(browser) { 77 confirm_close_factory_(browser) {
77 // Listen for bookmark bar visibility changes and set the initial state; we
78 // need to listen to all profiles because of normal profile/incognito issues.
79 registrar_.Add(this,
80 chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
81 NotificationService::AllBrowserContextsAndSources());
82 registrar_.Add(this, chrome::NOTIFICATION_SIDEBAR_CHANGED, 78 registrar_.Add(this, chrome::NOTIFICATION_SIDEBAR_CHANGED,
83 Source<SidebarManager>(SidebarManager::GetInstance())); 79 Source<SidebarManager>(SidebarManager::GetInstance()));
84 80
81 pref_change_registrar_.Init(browser_->profile()->GetPrefs());
82 pref_change_registrar_.Add(prefs::kShowBookmarkBar, this);
83
85 initial_show_state_ = browser_->GetSavedWindowShowState(); 84 initial_show_state_ = browser_->GetSavedWindowShowState();
86 } 85 }
87 86
88 BrowserWindowCocoa::~BrowserWindowCocoa() { 87 BrowserWindowCocoa::~BrowserWindowCocoa() {
89 } 88 }
90 89
91 void BrowserWindowCocoa::Show() { 90 void BrowserWindowCocoa::Show() {
92 // The Browser associated with this browser window must become the active 91 // The Browser associated with this browser window must become the active
93 // browser at the time |Show()| is called. This is the natural behaviour under 92 // browser at the time |Show()| is called. This is the natural behaviour under
94 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| 93 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:|
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // BrowserWindow object. 546 // BrowserWindow object.
548 FindBarBridge* bridge = new FindBarBridge(); 547 FindBarBridge* bridge = new FindBarBridge();
549 AddFindBar(bridge->find_bar_cocoa_controller()); 548 AddFindBar(bridge->find_bar_cocoa_controller());
550 return bridge; 549 return bridge;
551 } 550 }
552 551
553 void BrowserWindowCocoa::Observe(int type, 552 void BrowserWindowCocoa::Observe(int type,
554 const NotificationSource& source, 553 const NotificationSource& source,
555 const NotificationDetails& details) { 554 const NotificationDetails& details) {
556 switch (type) { 555 switch (type) {
557 // Only the key window gets a direct toggle from the menu. 556 case chrome::NOTIFICATION_PREF_CHANGED: {
558 // Other windows hear about it from the notification. 557 const std::string& pref_name = *Details<std::string>(details).ptr();
559 case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: 558 DCHECK(pref_name == prefs::kShowBookmarkBar);
560 if (browser_->profile()->IsSameProfile(Source<Profile>(source).ptr())) 559 [controller_ updateBookmarkBarVisibilityWithAnimation:YES];
561 [controller_ updateBookmarkBarVisibilityWithAnimation:YES];
562 break; 560 break;
561 }
563 case chrome::NOTIFICATION_SIDEBAR_CHANGED: 562 case chrome::NOTIFICATION_SIDEBAR_CHANGED:
564 UpdateSidebarForContents( 563 UpdateSidebarForContents(
565 Details<SidebarContainer>(details)->tab_contents()); 564 Details<SidebarContainer>(details)->tab_contents());
566 break; 565 break;
567 default: 566 default:
568 NOTREACHED(); // we don't ask for anything else! 567 NOTREACHED(); // we don't ask for anything else!
569 break; 568 break;
570 } 569 }
571 } 570 }
572 571
(...skipping 20 matching lines...) Expand all
593 NSPoint point = NSMakePoint(rect.right(), rect.bottom()); 592 NSPoint point = NSMakePoint(rect.right(), rect.bottom());
594 point = [view convertPoint:point toView:nil]; 593 point = [view convertPoint:point toView:nil];
595 point = [[view window] convertBaseToScreen:point]; 594 point = [[view window] convertBaseToScreen:point];
596 595
597 // |menu| will automatically release itself on close. 596 // |menu| will automatically release itself on close.
598 AvatarMenuBubbleController* menu = 597 AvatarMenuBubbleController* menu =
599 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ 598 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_
600 anchoredAt:point]; 599 anchoredAt:point];
601 [menu showWindow:nil]; 600 [menu showWindow:nil];
602 } 601 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_cocoa.h ('k') | chrome/browser/ui/cocoa/browser_window_cocoa_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698