summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/browser_window_controller.mm
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/cocoa/browser_window_controller.mm')
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm28
1 files changed, 28 insertions, 0 deletions
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<NSImage> 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<NSImageView> 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(