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

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

Issue 900613003: Mac: Make it easier for views to correctly draw with a theme. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gyp
Patch Set: Created 5 years, 10 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <numeric> 8 #include <numeric>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 612
613 // the tab strip is empty, it's ok to close the window 613 // the tab strip is empty, it's ok to close the window
614 return YES; 614 return YES;
615 } 615 }
616 616
617 // Called right after our window became the main window. 617 // Called right after our window became the main window.
618 - (void)windowDidBecomeMain:(NSNotification*)notification { 618 - (void)windowDidBecomeMain:(NSNotification*)notification {
619 BrowserList::SetLastActive(browser_.get()); 619 BrowserList::SetLastActive(browser_.get());
620 [self saveWindowPositionIfNeeded]; 620 [self saveWindowPositionIfNeeded];
621 621
622 // TODO(dmaclach): Instead of redrawing the whole window, views that care 622 [[[self window] contentView] cr_recursivelyInvokeBlock:^(id view) {
623 // about the active window state should be registering for notifications. 623 if ([view conformsToProtocol:@protocol(ThemedWindowDrawing)])
624 [[self window] setViewsNeedDisplay:YES]; 624 [view windowDidChangeActive];
Andre 2015/02/03 19:00:20 I think there's a misunderstanding here. setViewsN
625 625 }];
626 // TODO(viettrungluu): For some reason, the above doesn't suffice.
627 if ([self isInAnyFullscreenMode])
628 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil.
Andre 2015/02/03 19:00:20 FloatingBarBackingView now adopts ThemedWindowDraw
629 626
630 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile()) 627 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile())
631 ->set_registry_for_active_window(extension_keybinding_registry_.get()); 628 ->set_registry_for_active_window(extension_keybinding_registry_.get());
632 } 629 }
633 630
634 - (void)windowDidResignMain:(NSNotification*)notification { 631 - (void)windowDidResignMain:(NSNotification*)notification {
635 // TODO(dmaclach): Instead of redrawing the whole window, views that care 632 [[[self window] contentView] cr_recursivelyInvokeBlock:^(id view) {
636 // about the active window state should be registering for notifications. 633 if ([view conformsToProtocol:@protocol(ThemedWindowDrawing)])
637 [[self window] setViewsNeedDisplay:YES]; 634 [view windowDidChangeActive];
638 635 }];
639 // TODO(viettrungluu): For some reason, the above doesn't suffice.
640 if ([self isInAnyFullscreenMode])
641 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil.
642 636
643 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile()) 637 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile())
644 ->set_registry_for_active_window(nullptr); 638 ->set_registry_for_active_window(nullptr);
645 } 639 }
646 640
647 // Called when we are activated (when we gain focus). 641 // Called when we are activated (when we gain focus).
648 - (void)windowDidBecomeKey:(NSNotification*)notification { 642 - (void)windowDidBecomeKey:(NSNotification*)notification {
649 // We need to activate the controls (in the "WebView"). To do this, get the 643 // We need to activate the controls (in the "WebView"). To do this, get the
650 // selected WebContents's RenderWidgetHostView and tell it to activate. 644 // selected WebContents's RenderWidgetHostView and tell it to activate.
651 if (WebContents* contents = 645 if (WebContents* contents =
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 windowShim_->BookmarkBarStateChanged( 1689 windowShim_->BookmarkBarStateChanged(
1696 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 1690 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
1697 } 1691 }
1698 } 1692 }
1699 1693
1700 - (void)onTabDetachedWithContents:(WebContents*)contents { 1694 - (void)onTabDetachedWithContents:(WebContents*)contents {
1701 [infoBarContainerController_ tabDetachedWithContents:contents]; 1695 [infoBarContainerController_ tabDetachedWithContents:contents];
1702 } 1696 }
1703 1697
1704 - (void)userChangedTheme { 1698 - (void)userChangedTheme {
1705 [[[[self window] contentView] superview] cr_recursivelySetNeedsDisplay:YES]; 1699 NSView* rootView = [[[self window] contentView] superview];
1700 [rootView cr_recursivelyInvokeBlock:^(id view) {
1701 if ([view conformsToProtocol:@protocol(ThemedWindowDrawing)])
1702 [view windowDidChangeTheme];
1703
1704 // TODO(andresantoso): Remove this once all themed views respond to
1705 // windowDidChangeTheme above.
1706 [view setNeedsDisplay:YES];
1707 }];
1706 } 1708 }
1707 1709
1708 - (ui::ThemeProvider*)themeProvider { 1710 - (ui::ThemeProvider*)themeProvider {
1709 return ThemeServiceFactory::GetForProfile(browser_->profile()); 1711 return ThemeServiceFactory::GetForProfile(browser_->profile());
1710 } 1712 }
1711 1713
1712 - (ThemedWindowStyle)themedWindowStyle { 1714 - (ThemedWindowStyle)themedWindowStyle {
1713 ThemedWindowStyle style = 0; 1715 ThemedWindowStyle style = 0;
1714 if (browser_->profile()->IsOffTheRecord()) 1716 if (browser_->profile()->IsOffTheRecord())
1715 style |= THEMED_INCOGNITO; 1717 style |= THEMED_INCOGNITO;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 2234
2233 - (BOOL)supportsBookmarkBar { 2235 - (BOOL)supportsBookmarkBar {
2234 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2236 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2235 } 2237 }
2236 2238
2237 - (BOOL)isTabbedWindow { 2239 - (BOOL)isTabbedWindow {
2238 return browser_->is_type_tabbed(); 2240 return browser_->is_type_tabbed();
2239 } 2241 }
2240 2242
2241 @end // @implementation BrowserWindowController(WindowType) 2243 @end // @implementation BrowserWindowController(WindowType)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698