summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/nibs/Panel.xib10
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.mm22
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller.mm35
-rw-r--r--chrome/browser/ui/cocoa/browser_window_utils.h14
-rw-r--r--chrome/browser/ui/cocoa/browser_window_utils.mm54
-rw-r--r--chrome/browser/ui/cocoa/chrome_browser_window.h9
-rw-r--r--chrome/browser/ui/cocoa/chrome_browser_window.mm23
-rw-r--r--chrome/browser/ui/cocoa/themed_browser_window.h19
-rw-r--r--chrome/browser/ui/cocoa/themed_browser_window.mm34
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_cocoa.h2
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_cocoa.mm4
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_cocoa_unittest.mm29
-rw-r--r--chrome/browser/ui/panels/panel_titlebar_view_cocoa.h5
-rw-r--r--chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm18
-rw-r--r--chrome/browser/ui/panels/panel_window_controller_cocoa.h9
-rw-r--r--chrome/browser/ui/panels/panel_window_controller_cocoa.mm31
-rw-r--r--chrome/chrome_browser.gypi2
17 files changed, 232 insertions, 88 deletions
diff --git a/chrome/app/nibs/Panel.xib b/chrome/app/nibs/Panel.xib
index f2a2561..b6fceaa 100644
--- a/chrome/app/nibs/Panel.xib
+++ b/chrome/app/nibs/Panel.xib
@@ -45,7 +45,7 @@
<string key="NSWindowRect">{{196, 240}, {480, 270}}</string>
<int key="NSWTFlags">544736256</int>
<string key="NSWindowTitle">Window</string>
- <string key="NSWindowClass">ChromeEventProcessingWindow</string>
+ <string key="NSWindowClass">ThemedBrowserWindow</string>
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<object class="NSView" key="NSWindowView" id="1006">
@@ -351,6 +351,14 @@
<string key="minorKey"/>
</object>
</object>
+ <object class="IBPartialClassDescription">
+ <string key="className">ThemedBrowserWindow</string>
+ <string key="superclassName">ChromeEventProcessingWindow</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBUserSource</string>
+ <string key="minorKey"/>
+ </object>
+ </object>
</object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<bool key="EncodedWithXMLCoder">YES</bool>
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index 784965f..19f1d3a 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -203,24 +203,10 @@ void BrowserWindowCocoa::UpdateTitleBar() {
NSString* newTitle =
base::SysUTF16ToNSString(browser_->GetWindowTitleForCurrentTab());
- // Work around Cocoa bug: if a window changes title during the tracking of the
- // Window menu it doesn't display well and the constant re-sorting of the list
- // makes it difficult for the user to pick the desired window. Delay window
- // title updates until the default run-loop mode.
-
- if (pending_window_title_.get())
- [[NSRunLoop currentRunLoop]
- cancelPerformSelector:@selector(setTitle:)
- target:window()
- argument:pending_window_title_.get()];
-
- pending_window_title_.reset([newTitle copy]);
- [[NSRunLoop currentRunLoop]
- performSelector:@selector(setTitle:)
- target:window()
- argument:newTitle
- order:0
- modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
+ pending_window_title_.reset(
+ [BrowserWindowUtils scheduleReplaceOldTitle:pending_window_title_.get()
+ withNewTitle:newTitle
+ forWindow:window()]);
}
void BrowserWindowCocoa::BookmarkBarStateChanged(
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index 5a7cdc2..6444bbc 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -35,6 +35,7 @@
#import "chrome/browser/ui/cocoa/browser/avatar_button.h"
#import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
#import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
+#import "chrome/browser/ui/cocoa/browser_window_utils.h"
#import "chrome/browser/ui/cocoa/dev_tools_controller.h"
#import "chrome/browser/ui/cocoa/download/download_shelf_controller.h"
#import "chrome/browser/ui/cocoa/event_utils.h"
@@ -1587,39 +1588,9 @@ enum {
}
- (NSPoint)themePatternPhase {
- // Our patterns want to be drawn from the upper left hand corner of the view.
- // Cocoa wants to do it from the lower left of the window.
- //
- // Rephase our pattern to fit this view. Some other views (Tabs, Toolbar etc.)
- // will phase their patterns relative to this so all the views look right.
- //
- // To line up the background pattern with the pattern in the browser window
- // the background pattern for the tabs needs to be moved left by 5 pixels.
- const CGFloat kPatternHorizontalOffset = -5;
- // To match Windows and CrOS, have to offset vertically by 2 pixels.
- // Without tab strip, offset an extra pixel (determined by experimentation).
- const CGFloat kPatternVerticalOffset = 2;
- const CGFloat kPatternVerticalOffsetNoTabStrip = 3;
-
- // When we have a tab strip, line up with the top of the tab, otherwise,
- // line up with the top of the window.
NSView* windowChromeView = [[[self window] contentView] superview];
- if ([self hasTabStrip]) {
- NSView* tabStripView = [self tabStripView];
- NSRect tabStripViewWindowBounds = [tabStripView bounds];
- tabStripViewWindowBounds =
- [tabStripView convertRect:tabStripViewWindowBounds
- toView:windowChromeView];
- return NSMakePoint(NSMinX(tabStripViewWindowBounds)
- + kPatternHorizontalOffset,
- NSMinY(tabStripViewWindowBounds)
- + [TabStripController defaultTabHeight]
- + kPatternVerticalOffset);
- } else {
- return NSMakePoint(kPatternHorizontalOffset,
- NSHeight([windowChromeView bounds])
- + kPatternVerticalOffsetNoTabStrip);
- }
+ return [BrowserWindowUtils themePatternPhaseFor:windowChromeView
+ withTabStrip:[self tabStripView]];
}
- (NSPoint)bookmarkBubblePoint {
diff --git a/chrome/browser/ui/cocoa/browser_window_utils.h b/chrome/browser/ui/cocoa/browser_window_utils.h
index 97d454f..6c6edcc 100644
--- a/chrome/browser/ui/cocoa/browser_window_utils.h
+++ b/chrome/browser/ui/cocoa/browser_window_utils.h
@@ -23,6 +23,20 @@ struct NativeWebKeyboardEvent;
// NSWindow must be a ChromeEventProcessingWindow.
+ (BOOL)handleKeyboardEvent:(NSEvent*)event
inWindow:(NSWindow*)window;
+
+// Schedule a window title change in the next run loop iteration. This works
+// around a Cocoa bug: if a window changes title during the tracking of the
+// Window menu it doesn't display well and the constant re-sorting of the list
+// makes it difficult for the user to pick the desired window.
+// Passing in a non-nil oldTitle will also cancel any pending title changes with
+// a matching window and title. This function returns a NSString* that can be
+// passed in future calls as oldTitle.
++ (NSString*)scheduleReplaceOldTitle:(NSString*)oldTitle
+ withNewTitle:(NSString*)newTitle
+ forWindow:(NSWindow*)window;
+
++ (NSPoint)themePatternPhaseFor:(NSView*)windowView
+ withTabStrip:(NSView*)tabStripView;
@end
#endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_UTILS_H_
diff --git a/chrome/browser/ui/cocoa/browser_window_utils.mm b/chrome/browser/ui/cocoa/browser_window_utils.mm
index c028615..aea2e9b 100644
--- a/chrome/browser/ui/cocoa/browser_window_utils.mm
+++ b/chrome/browser/ui/cocoa/browser_window_utils.mm
@@ -10,6 +10,7 @@
#include "chrome/browser/ui/browser.h"
#import "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
#import "chrome/browser/ui/cocoa/nsmenuitem_additions.h"
+#import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
#include "content/common/native_web_keyboard_event.h"
@interface MenuWalker : NSObject
@@ -121,4 +122,57 @@
return [event_window redispatchKeyEvent:event];
}
++ (NSString*)scheduleReplaceOldTitle:(NSString*)oldTitle
+ withNewTitle:(NSString*)newTitle
+ forWindow:(NSWindow*)window {
+ if (oldTitle)
+ [[NSRunLoop currentRunLoop]
+ cancelPerformSelector:@selector(setTitle:)
+ target:window
+ argument:oldTitle];
+
+ [[NSRunLoop currentRunLoop]
+ performSelector:@selector(setTitle:)
+ target:window
+ argument:newTitle
+ order:0
+ modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
+ return [newTitle copy];
+}
+
+// Our patterns want to be drawn from the upper left hand corner of the view.
+// Cocoa wants to do it from the lower left of the window.
+//
+// Rephase our pattern to fit this view. Some other views (Tabs, Toolbar etc.)
+// will phase their patterns relative to this so all the views look right.
+//
+// To line up the background pattern with the pattern in the browser window
+// the background pattern for the tabs needs to be moved left by 5 pixels.
+const CGFloat kPatternHorizontalOffset = -5;
+// To match Windows and CrOS, have to offset vertically by 2 pixels.
+// Without tab strip, offset an extra pixel (determined by experimentation).
+const CGFloat kPatternVerticalOffset = 2;
+const CGFloat kPatternVerticalOffsetNoTabStrip = 3;
+
+
++ (NSPoint)themePatternPhaseFor:(NSView*)windowView
+ withTabStrip:(NSView*)tabStripView {
+ // When we have a tab strip, line up with the top of the tab, otherwise,
+ // line up with the top of the window.
+ if (!tabStripView)
+ return NSMakePoint(kPatternHorizontalOffset,
+ NSHeight([windowView bounds])
+ + kPatternVerticalOffsetNoTabStrip);
+
+ NSRect tabStripViewWindowBounds = [tabStripView bounds];
+ tabStripViewWindowBounds =
+ [tabStripView convertRect:tabStripViewWindowBounds
+ toView:windowView];
+ return NSMakePoint(NSMinX(tabStripViewWindowBounds)
+ + kPatternHorizontalOffset,
+ NSMinY(tabStripViewWindowBounds)
+ + [TabStripController defaultTabHeight]
+ + kPatternVerticalOffset);
+}
+
@end
diff --git a/chrome/browser/ui/cocoa/chrome_browser_window.h b/chrome/browser/ui/cocoa/chrome_browser_window.h
index 64c0123..1d247e6 100644
--- a/chrome/browser/ui/cocoa/chrome_browser_window.h
+++ b/chrome/browser/ui/cocoa/chrome_browser_window.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,12 +8,11 @@
#import <Cocoa/Cocoa.h>
-#include "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
+#include "chrome/browser/ui/cocoa/themed_browser_window.h"
// Common base class for chrome browser windows. Contains methods relating to
-// theming and hole punching that are shared between framed and fullscreen
-// windows.
-@interface ChromeBrowserWindow : ChromeEventProcessingWindow {
+// hole punching that are shared between framed and fullscreen windows.
+@interface ChromeBrowserWindow : ThemedBrowserWindow {
@private
int underlaySurfaceCount_;
}
diff --git a/chrome/browser/ui/cocoa/chrome_browser_window.mm b/chrome/browser/ui/cocoa/chrome_browser_window.mm
index e21507b..a6ef49c 100644
--- a/chrome/browser/ui/cocoa/chrome_browser_window.mm
+++ b/chrome/browser/ui/cocoa/chrome_browser_window.mm
@@ -5,8 +5,6 @@
#import "chrome/browser/ui/cocoa/chrome_browser_window.h"
#include "base/logging.h"
-#import "chrome/browser/ui/cocoa/themed_window.h"
-#include "ui/base/theme_provider.h"
@implementation ChromeBrowserWindow
@@ -28,25 +26,4 @@
[self setOpaque:YES];
}
-- (ui::ThemeProvider*)themeProvider {
- id delegate = [self delegate];
- if (![delegate respondsToSelector:@selector(themeProvider)])
- return NULL;
- return [delegate themeProvider];
-}
-
-- (ThemedWindowStyle)themedWindowStyle {
- id delegate = [self delegate];
- if (![delegate respondsToSelector:@selector(themedWindowStyle)])
- return THEMED_NORMAL;
- return [delegate themedWindowStyle];
-}
-
-- (NSPoint)themePatternPhase {
- id delegate = [self delegate];
- if (![delegate respondsToSelector:@selector(themePatternPhase)])
- return NSMakePoint(0, 0);
- return [delegate themePatternPhase];
-}
-
@end
diff --git a/chrome/browser/ui/cocoa/themed_browser_window.h b/chrome/browser/ui/cocoa/themed_browser_window.h
new file mode 100644
index 0000000..a413797
--- /dev/null
+++ b/chrome/browser/ui/cocoa/themed_browser_window.h
@@ -0,0 +1,19 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_COCOA_THEMED_BROWSER_WINDOW_H_
+#define CHROME_BROWSER_UI_COCOA_THEMED_BROWSER_WINDOW_H_
+#pragma once
+
+#import <Cocoa/Cocoa.h>
+
+#include "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
+
+// Common base class for themed browser windows.
+@interface ThemedBrowserWindow : ChromeEventProcessingWindow {
+}
+
+@end
+
+#endif // CHROME_BROWSER_UI_COCOA_CHROME_BROWSER_WINDOW_H_
diff --git a/chrome/browser/ui/cocoa/themed_browser_window.mm b/chrome/browser/ui/cocoa/themed_browser_window.mm
new file mode 100644
index 0000000..363e6e9
--- /dev/null
+++ b/chrome/browser/ui/cocoa/themed_browser_window.mm
@@ -0,0 +1,34 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/ui/cocoa/themed_browser_window.h"
+
+#include "base/logging.h"
+#import "chrome/browser/ui/cocoa/themed_window.h"
+#include "ui/base/theme_provider.h"
+
+@implementation ThemedBrowserWindow
+
+- (ui::ThemeProvider*)themeProvider {
+ id delegate = [self delegate];
+ if (![delegate respondsToSelector:@selector(themeProvider)])
+ return NULL;
+ return [delegate themeProvider];
+}
+
+- (ThemedWindowStyle)themedWindowStyle {
+ id delegate = [self delegate];
+ if (![delegate respondsToSelector:@selector(themedWindowStyle)])
+ return THEMED_NORMAL;
+ return [delegate themedWindowStyle];
+}
+
+- (NSPoint)themePatternPhase {
+ id delegate = [self delegate];
+ if (![delegate respondsToSelector:@selector(themePatternPhase)])
+ return NSMakePoint(0, 0);
+ return [delegate themePatternPhase];
+}
+
+@end
diff --git a/chrome/browser/ui/panels/panel_browser_window_cocoa.h b/chrome/browser/ui/panels/panel_browser_window_cocoa.h
index 381c47f..73620e0d 100644
--- a/chrome/browser/ui/panels/panel_browser_window_cocoa.h
+++ b/chrome/browser/ui/panels/panel_browser_window_cocoa.h
@@ -70,6 +70,8 @@ class PanelBrowserWindowCocoa : public NativePanel {
FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, TitlebarViewClose);
FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, MenuItems);
FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, KeyEvent);
+ FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, ThemeProvider);
+ FRIEND_TEST_ALL_PREFIXES(PanelBrowserWindowCocoaTest, SetTitle);
bool isClosed();
diff --git a/chrome/browser/ui/panels/panel_browser_window_cocoa.mm b/chrome/browser/ui/panels/panel_browser_window_cocoa.mm
index d3fba0d..facaf2d 100644
--- a/chrome/browser/ui/panels/panel_browser_window_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_browser_window_cocoa.mm
@@ -126,7 +126,9 @@ gfx::NativeWindow PanelBrowserWindowCocoa::GetNativePanelHandle() {
}
void PanelBrowserWindowCocoa::UpdatePanelTitleBar() {
- NOTIMPLEMENTED();
+ if (!is_shown_)
+ return;
+ [controller_ updateTitleBar];
}
void PanelBrowserWindowCocoa::ShowTaskManagerForPanel() {
diff --git a/chrome/browser/ui/panels/panel_browser_window_cocoa_unittest.mm b/chrome/browser/ui/panels/panel_browser_window_cocoa_unittest.mm
index 8c3cbab..781e6ec 100644
--- a/chrome/browser/ui/panels/panel_browser_window_cocoa_unittest.mm
+++ b/chrome/browser/ui/panels/panel_browser_window_cocoa_unittest.mm
@@ -17,6 +17,7 @@
#import "chrome/browser/ui/cocoa/browser_test_helper.h"
#import "chrome/browser/ui/cocoa/browser_window_utils.h"
#import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
+#import "chrome/browser/ui/cocoa/run_loop_testing.h"
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_manager.h"
#import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h"
@@ -27,6 +28,7 @@
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/tab_contents/test_tab_contents.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gtest_mac.h"
// Main test class.
class PanelBrowserWindowCocoaTest : public CocoaTest {
@@ -329,3 +331,30 @@ TEST_F(PanelBrowserWindowCocoaTest, KeyEvent) {
inWindow:[native_window->controller_ window]];
ClosePanelAndWait(panel->browser());
}
+
+// Verify that the theme provider is properly plumbed through.
+TEST_F(PanelBrowserWindowCocoaTest, ThemeProvider) {
+ Panel* panel = CreateTestPanel("Test Panel");
+ ASSERT_TRUE(panel);
+
+ PanelBrowserWindowCocoa* native_window =
+ static_cast<PanelBrowserWindowCocoa*>(panel->native_panel());
+ ASSERT_TRUE(native_window);
+ EXPECT_TRUE(NULL != [[native_window->controller_ window] themeProvider]);
+ ClosePanelAndWait(panel->browser());
+}
+
+TEST_F(PanelBrowserWindowCocoaTest, SetTitle) {
+ Panel* panel = CreateTestPanel("Test Panel");
+ ASSERT_TRUE(panel);
+
+ PanelBrowserWindowCocoa* native_window =
+ static_cast<PanelBrowserWindowCocoa*>(panel->native_panel());
+ ASSERT_TRUE(native_window);
+ NSString* previousTitle = [[native_window->controller_ window] title];
+ [native_window->controller_ updateTitleBar];
+ chrome::testing::NSRunLoopRunAllPending();
+ EXPECT_NSEQ(@"Untitled", [[native_window->controller_ window] title]);
+ EXPECT_NSNE([[native_window->controller_ window] title], previousTitle);
+ ClosePanelAndWait(panel->browser());
+}
diff --git a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h
index a074475..b3722d4 100644
--- a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h
+++ b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h
@@ -7,6 +7,7 @@
#import <Cocoa/Cocoa.h>
+#import "chrome/browser/ui/cocoa/background_gradient_view.h"
#import "chrome/browser/ui/cocoa/tracking_area.h"
@class CrTrackingArea;
@@ -22,7 +23,7 @@
// differently based on being key window) so it appears easier to simply overlay
// the standard titlebar.
-@interface PanelTitlebarViewCocoa : NSView {
+@interface PanelTitlebarViewCocoa : BackgroundGradientView {
IBOutlet PanelWindowControllerCocoa* controller_;
NSButton* closeButton_; // Created explicitly, not from NIB. Weak, destroyed
// when view is destroyed, as a subview.
@@ -35,6 +36,8 @@
// Attaches this view to the controller_'s window as a titlebar.
- (void)attach;
+- (void)setTitle:(NSString*)newTitle;
+
// Should be called when size of the titlebar changes.
- (void)updateCloseButtonLayout;
diff --git a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm
index 0f367fc..61f0c3e 100644
--- a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm
@@ -7,9 +7,12 @@
#import <Cocoa/Cocoa.h>
#include "base/logging.h"
+#include "chrome/browser/themes/theme_service.h"
+#import "chrome/browser/ui/cocoa/themed_window.h"
#import "chrome/browser/ui/cocoa/tracking_area.h"
#import "chrome/browser/ui/panels/panel_window_controller_cocoa.h"
#import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h"
+#include "ui/base/theme_provider.h"
const int kRoundedCornerSize = 6;
const int kCloseButtonLeftPadding = 8;
@@ -45,13 +48,10 @@ const int kCloseButtonLeftPadding = 8;
topRightCornerRadius:kRoundedCornerSize
bottomLeftCornerRadius:0.0
bottomRightCornerRadius:0.0];
- // TODO(dimich): paint theme image here.
- [[NSColor colorWithDeviceRed:1 green:1 blue:0 alpha:0.9] setFill];
- [path fill];
- [[NSColor colorWithCalibratedWhite:0.4 alpha:1.0] set];
- NSPoint from = [self bounds].origin;
- NSPoint to = NSMakePoint(from.x + NSWidth([self bounds]), from.y);
- [NSBezierPath strokeLineFromPoint:from toPoint:to];
+ [path addClip];
+ NSPoint phase = [[self window] themePatternPhase];
+ [[NSGraphicsContext currentContext] setPatternPhase:phase];
+ [self drawBackgroundWithOpaque:YES];
}
- (void)attach {
@@ -84,6 +84,10 @@ const int kCloseButtonLeftPadding = 8;
[self setAutoresizingMask:(NSViewMinYMargin | NSViewWidthSizable)];
}
+- (void)setTitle:(NSString*)newTitle {
+ // TODO(dcheng): Implement.
+}
+
- (void)updateCloseButtonLayout {
NSRect buttonBounds = [closeButton_ bounds];
NSRect bounds = [self bounds];
diff --git a/chrome/browser/ui/panels/panel_window_controller_cocoa.h b/chrome/browser/ui/panels/panel_window_controller_cocoa.h
index 9956999e..24f0f5df 100644
--- a/chrome/browser/ui/panels/panel_window_controller_cocoa.h
+++ b/chrome/browser/ui/panels/panel_window_controller_cocoa.h
@@ -12,8 +12,10 @@
#import <Cocoa/Cocoa.h>
#import "base/mac/cocoa_protocols.h"
+#include "base/memory/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
#import "chrome/browser/ui/cocoa/browser_command_executor.h"
+#import "chrome/browser/ui/cocoa/themed_window.h"
@class FindBarCocoaController;
class PanelBrowserWindowCocoa;
@@ -24,11 +26,16 @@ class PanelBrowserWindowCocoa;
@private
IBOutlet PanelTitlebarViewCocoa* titlebar_view_;
scoped_ptr<PanelBrowserWindowCocoa> windowShim_;
+ scoped_nsobject<NSString> pendingWindowTitle_;
}
// Load the browser window nib and do any Cocoa-specific initialization.
- (id)initWithBrowserWindow:(PanelBrowserWindowCocoa*)window;
+- (ui::ThemeProvider*)themeProvider;
+- (ThemedWindowStyle)themedWindowStyle;
+- (NSPoint)themePatternPhase;
+
// Returns the TabContents' native view. It renders the content of the web page
// in the Panel.
- (NSView*)tabContentsView;
@@ -42,6 +49,8 @@ class PanelBrowserWindowCocoa;
// Shows the window for the first time. Only happens once.
- (void)revealAnimatedWithFrame:(const NSRect&)frame;
+- (void)updateTitleBar;
+
// Adds the FindBar controller's view to this Panel. Must only be
// called once per PanelWindowControllerCocoa.
- (void)addFindBar:(FindBarCocoaController*)findBarCocoaController;
diff --git a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
index f521570..b63f6ac 100644
--- a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
@@ -8,9 +8,14 @@
#include "base/logging.h"
#include "base/mac/mac_util.h"
+#include "base/sys_string_conversions.h"
#include "chrome/app/chrome_command_ids.h" // IDC_*
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tabs/tab_strip_model.h"
+#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser.h"
+#import "chrome/browser/ui/cocoa/browser_window_utils.h"
#import "chrome/browser/ui/cocoa/event_utils.h"
#import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
#import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
@@ -42,6 +47,22 @@ enum {
return self;
}
+- (ui::ThemeProvider*)themeProvider {
+ return ThemeServiceFactory::GetForProfile(windowShim_->browser()->profile());
+}
+
+- (ThemedWindowStyle)themedWindowStyle {
+ ThemedWindowStyle style = THEMED_POPUP;
+ if (windowShim_->browser()->profile()->IsOffTheRecord())
+ style |= THEMED_INCOGNITO;
+ return style;
+}
+
+- (NSPoint)themePatternPhase {
+ NSView* windowView = [[[self window] contentView] superview];
+ return [BrowserWindowUtils themePatternPhaseFor:windowView withTabStrip:nil];
+}
+
- (void)awakeFromNib {
NSWindow* window = [self window];
@@ -106,6 +127,16 @@ enum {
[self enableTabContentsViewAutosizing];
}
+- (void)updateTitleBar {
+ NSString* newTitle = base::SysUTF16ToNSString(
+ windowShim_->browser()->GetWindowTitleForCurrentTab());
+ pendingWindowTitle_.reset(
+ [BrowserWindowUtils scheduleReplaceOldTitle:pendingWindowTitle_.get()
+ withNewTitle:newTitle
+ forWindow:[self window]]);
+ [titlebar_view_ setTitle:newTitle];
+}
+
- (void)addFindBar:(FindBarCocoaController*)findBarCocoaController {
NSView* contentView = [[self window] contentView];
[contentView addSubview:[findBarCocoaController view]];
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index b5028eb..09935b4 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2698,6 +2698,8 @@
'browser/ui/cocoa/task_manager_mac.mm',
'browser/ui/cocoa/theme_install_bubble_view.h',
'browser/ui/cocoa/theme_install_bubble_view.mm',
+ 'browser/ui/cocoa/themed_browser_window.h',
+ 'browser/ui/cocoa/themed_browser_window.mm',
'browser/ui/cocoa/themed_window.h',
'browser/ui/cocoa/themed_window.mm',
'browser/ui/cocoa/toolbar/back_forward_menu_controller.h',