From e4cfddb3796bacb968607d17024d77540b665ca2 Mon Sep 17 00:00:00 2001 From: "pinkerton@chromium.org" Date: Mon, 15 Jun 2009 16:01:47 +0000 Subject: Badge browser window with incognito icon when in incognito mode BUG=12536 TEST=incognito icon on window opened in incognito mode git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18390 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/cocoa/browser_window_controller.mm | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'chrome/browser/cocoa/browser_window_controller.mm') diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 99a0737..f363008 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -10,6 +10,7 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/encoding_menu_controller.h" +#include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/tabs/tab_strip_model.h" @@ -37,6 +38,7 @@ const int kWindowGradientHeight = 24; @interface BrowserWindowController(Private) - (void)positionToolbar; +- (void)installIncognitoBadge; // Leopard's gradient heuristic gets confused by our tabs and makes the title // gradient jump when creating a tab that is less than a tab width from the @@ -133,6 +135,9 @@ willPositionSheet:(NSWindow *)sheet switchView:[self tabContentArea] model:browser_->tabstrip_model()]); + // Puts the incognito badge on the window frame, if necessary. + [self installIncognitoBadge]; + // Create a controller for the toolbar, giving it the toolbar model object // and the toolbar view from the nib. The controller will handle // registering for the appropriate command state changes from the back-end. @@ -641,6 +646,29 @@ willPositionSheet:(NSWindow *)sheet [[[self window] contentView] addSubview:toolbarView]; } +// If the browser is in incognito mode, install the image view to decordate +// the window at the upper right. Use the same base y coordinate as the +// tab strip. +- (void)installIncognitoBadge { + if (!browser_->profile()->IsOffTheRecord()) + return; + + NSString *incognitoPath = [mac_util::MainAppBundle() + pathForResource:@"otr_icon" + ofType:@"png"]; + scoped_nsobject incognitoImage( + [[NSImage alloc] initWithContentsOfFile:incognitoPath]); + const NSSize imageSize = [incognitoImage size]; + const NSRect tabFrame = [[self tabStripView] frame]; + NSRect incognitoFrame = tabFrame; + incognitoFrame.origin.x = NSMaxX(incognitoFrame) - imageSize.width; + incognitoFrame.size = imageSize; + scoped_nsobject incognitoView( + [[NSImageView alloc] initWithFrame:incognitoFrame]); + [incognitoView setImage:incognitoImage]; + [[[[self window] contentView] superview] addSubview:incognitoView.get()]; +} + - (void)fixWindowGradient { NSWindow* win = [self window]; if ([win respondsToSelector:@selector( -- cgit v1.1