summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm5
-rw-r--r--chrome/chrome_browser_ui.gypi39
-rw-r--r--ui/app_list/DEPS3
-rw-r--r--ui/app_list/app_list.gyp12
-rw-r--r--ui/app_list/cocoa/app_list_view.h24
-rw-r--r--ui/app_list/cocoa/app_list_view.mm51
-rw-r--r--ui/app_list/cocoa/app_list_view_unittest.mm37
-rw-r--r--ui/app_list/cocoa/app_list_view_window.h2
-rw-r--r--ui/app_list/cocoa/app_list_view_window.mm16
-rw-r--r--ui/app_list/cocoa/app_list_view_window_unittest.mm51
-rw-r--r--ui/ui.gyp56
11 files changed, 243 insertions, 53 deletions
diff --git a/chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm b/chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm
index dca6589..b2eb549 100644
--- a/chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm
+++ b/chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm
@@ -9,6 +9,7 @@
#include "base/time.h"
#include "base/timer.h"
#include "chrome/browser/ui/app_list/app_list_util.h"
+#include "ui/app_list/cocoa/app_list_view.h"
#include "ui/app_list/cocoa/app_list_view_window.h"
namespace {
@@ -35,6 +36,10 @@ base::LazyInstance<AppListController>::Leaky g_app_list_controller =
void AppListController::CreateAppList() {
current_window_.reset([[AppListViewWindow alloc] initAsBubble]);
+ scoped_nsobject<AppListView> contentView(
+ [[AppListView alloc] initWithViewDelegate:NULL]);
+
+ [current_window_ setAppListView:contentView];
}
void AppListController::ShowAppList() {
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index 378c6ea..255335ea 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -2621,46 +2621,11 @@
'browser/ui/webui/help/version_updater_basic.cc',
'browser/ui/webui/help/version_updater_basic.h',
],
- 'sources': [
- # Build Apple sample code
- '../third_party/apple_sample_code/ImageAndTextCell.h',
- '../third_party/apple_sample_code/ImageAndTextCell.m',
- # Build the necessary GTM sources
- '../third_party/GTM/AppKit/GTMFadeTruncatingTextFieldCell.h',
- '../third_party/GTM/AppKit/GTMFadeTruncatingTextFieldCell.m',
- '../third_party/GTM/AppKit/GTMIBArray.h',
- '../third_party/GTM/AppKit/GTMIBArray.m',
- '../third_party/GTM/AppKit/GTMKeyValueAnimation.h',
- '../third_party/GTM/AppKit/GTMKeyValueAnimation.m',
- '../third_party/GTM/AppKit/GTMNSAnimation+Duration.h',
- '../third_party/GTM/AppKit/GTMNSAnimation+Duration.m',
- '../third_party/GTM/AppKit/GTMNSBezierPath+CGPath.h',
- '../third_party/GTM/AppKit/GTMNSBezierPath+CGPath.m',
- '../third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.m',
- '../third_party/GTM/AppKit/GTMNSColor+Luminance.m',
- '../third_party/GTM/AppKit/GTMUILocalizer.h',
- '../third_party/GTM/AppKit/GTMUILocalizer.m',
- '../third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h',
- '../third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.m',
- '../third_party/GTM/Foundation/GTMNSNumber+64Bit.h',
- '../third_party/GTM/Foundation/GTMNSNumber+64Bit.m',
- '../third_party/GTM/Foundation/GTMNSObject+KeyValueObserving.h',
- '../third_party/GTM/Foundation/GTMNSObject+KeyValueObserving.m',
- # MolokoCacao additions
- '../third_party/molokocacao/NSBezierPath+MCAdditions.h',
- '../third_party/molokocacao/NSBezierPath+MCAdditions.m',
- # Build necessary Mozilla sources
- '../third_party/mozilla/NSScreen+Utils.h',
- '../third_party/mozilla/NSScreen+Utils.m',
- '../third_party/mozilla/NSWorkspace+Utils.h',
- '../third_party/mozilla/NSWorkspace+Utils.m',
+ 'dependencies': [
+ '../ui/ui.gyp:ui_cocoa_third_party_toolkits',
],
'include_dirs': [
- '../third_party/apple',
'../third_party/GTM',
- '../third_party/GTM/AppKit',
- '../third_party/GTM/DebugUtils',
- '../third_party/GTM/Foundation',
],
'actions': [
{
diff --git a/ui/app_list/DEPS b/ui/app_list/DEPS
index 9337d4b..4bb0b29 100644
--- a/ui/app_list/DEPS
+++ b/ui/app_list/DEPS
@@ -2,4 +2,7 @@ include_rules = [
"+skia",
"+third_party/skia",
"+ui",
+
+ # Allow inclusion of third-party code:
+ "+third_party/GTM", # Google Toolbox for Mac.
]
diff --git a/ui/app_list/app_list.gyp b/ui/app_list/app_list.gyp
index e678365..24791d0 100644
--- a/ui/app_list/app_list.gyp
+++ b/ui/app_list/app_list.gyp
@@ -34,6 +34,8 @@
'app_list_switches.h',
'app_list_view_delegate.h',
'apps_grid_view_delegate.h',
+ 'cocoa/app_list_view.h',
+ 'cocoa/app_list_view.mm',
'cocoa/app_list_view_window.h',
'cocoa/app_list_view_window.mm',
'pagination_model.cc',
@@ -83,7 +85,14 @@
['exclude', 'views/'],
],
}],
- ['OS!="mac"', {
+ ['OS=="mac"', {
+ 'dependencies': [
+ '../ui.gyp:ui_cocoa_third_party_toolkits',
+ ],
+ 'include_dirs': [
+ '../../third_party/GTM',
+ ],
+ }, { # OS!="mac"
'sources/': [
['exclude', 'cocoa/'],
],
@@ -107,6 +116,7 @@
'test/app_list_test_suite.cc',
'test/app_list_test_suite.h',
'test/run_all_unittests.cc',
+ 'cocoa/app_list_view_unittest.mm',
'cocoa/app_list_view_window_unittest.mm',
'views/apps_grid_view_unittest.cc',
'views/test/apps_grid_view_test_api.cc',
diff --git a/ui/app_list/cocoa/app_list_view.h b/ui/app_list/cocoa/app_list_view.h
new file mode 100644
index 0000000..b6f918a
--- /dev/null
+++ b/ui/app_list/cocoa/app_list_view.h
@@ -0,0 +1,24 @@
+// Copyright 2013 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 <Cocoa/Cocoa.h>
+
+#include "base/memory/scoped_ptr.h"
+
+namespace app_list {
+class AppListModel;
+class AppListViewDelegate;
+}
+
+// AppListView is the top-level view and controller of app list UI.
+@interface AppListView : NSView {
+ @private
+ scoped_ptr<app_list::AppListModel> model_;
+ scoped_ptr<app_list::AppListViewDelegate> delegate_;
+}
+
+// Takes ownership of |appListViewDelegate|.
+- (id)initWithViewDelegate:(app_list::AppListViewDelegate*)appListViewDelegate;
+
+@end
diff --git a/ui/app_list/cocoa/app_list_view.mm b/ui/app_list/cocoa/app_list_view.mm
new file mode 100644
index 0000000..e6543c7
--- /dev/null
+++ b/ui/app_list/cocoa/app_list_view.mm
@@ -0,0 +1,51 @@
+// Copyright 2013 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 "ui/app_list/cocoa/app_list_view.h"
+
+#import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h"
+#include "ui/app_list/app_list_model.h"
+#include "ui/app_list/app_list_view_delegate.h"
+
+// The roundedness of the corners of the bubble.
+const int kBubbleCornerRadius = 3;
+// The grayscale value for the window edge stroke.
+const float kWindowEdge = 0.7f;
+
+@implementation AppListView;
+
+- (id)initWithViewDelegate:(app_list::AppListViewDelegate*)appListViewDelegate {
+ const int kViewWidth = 200;
+ const int kViewHeight = 200;
+ NSRect frame = NSMakeRect(0, 0, kViewWidth, kViewHeight);
+ if ((self = [super initWithFrame:frame])) {
+ model_.reset(new app_list::AppListModel());
+ delegate_.reset(appListViewDelegate);
+ }
+
+ return self;
+}
+
+- (void)drawRect:(NSRect)rect {
+ NSRect bounds = [self bounds];
+ NSBezierPath* border =
+ [NSBezierPath gtm_bezierPathWithRoundRect:bounds
+ cornerRadius:kBubbleCornerRadius];
+
+ [[NSColor grayColor] set];
+ [border fill];
+
+ // Inset so the stroke is inside the bounds.
+ bounds = NSInsetRect(bounds, 0.5, 0.5);
+
+ // TODO(tapted): Update the window border to use assets rather than vectors.
+ border =
+ [NSBezierPath gtm_bezierPathWithRoundRect:bounds
+ cornerRadius:kBubbleCornerRadius];
+
+ [[NSColor colorWithDeviceWhite:kWindowEdge alpha:1.0f] set];
+ [border stroke];
+}
+
+@end
diff --git a/ui/app_list/cocoa/app_list_view_unittest.mm b/ui/app_list/cocoa/app_list_view_unittest.mm
new file mode 100644
index 0000000..1c5f322
--- /dev/null
+++ b/ui/app_list/cocoa/app_list_view_unittest.mm
@@ -0,0 +1,37 @@
+// Copyright 2013 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.
+
+#include "base/memory/scoped_nsobject.h"
+#import "testing/gtest_mac.h"
+#import "ui/app_list/cocoa/app_list_view.h"
+#import "ui/base/test/ui_cocoa_test_helper.h"
+
+namespace {
+
+class AppListViewTest : public ui::CocoaTest {
+ public:
+ AppListViewTest() {}
+
+ virtual void SetUp() OVERRIDE {
+ ui::CocoaTest::SetUp();
+ view_.reset([[AppListView alloc] initWithViewDelegate:NULL]);
+ [[test_window() contentView] addSubview:view_];
+ }
+
+ protected:
+ scoped_nsobject<AppListView> view_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AppListViewTest);
+};
+
+} // namespace
+
+TEST_VIEW(AppListViewTest, view_);
+
+// Test allocating the view with no delegate or model, and showing.
+TEST_F(AppListViewTest, AddViewAndShow) {
+ EXPECT_TRUE([view_ superview]);
+ [view_ display];
+}
diff --git a/ui/app_list/cocoa/app_list_view_window.h b/ui/app_list/cocoa/app_list_view_window.h
index 8d18efa..2fe4222 100644
--- a/ui/app_list/cocoa/app_list_view_window.h
+++ b/ui/app_list/cocoa/app_list_view_window.h
@@ -9,4 +9,6 @@
- (id)initAsBubble;
+- (void)setAppListView:(NSView*)view;
+
@end
diff --git a/ui/app_list/cocoa/app_list_view_window.mm b/ui/app_list/cocoa/app_list_view_window.mm
index 96a0049..50445de 100644
--- a/ui/app_list/cocoa/app_list_view_window.mm
+++ b/ui/app_list/cocoa/app_list_view_window.mm
@@ -4,21 +4,27 @@
#import "ui/app_list/cocoa/app_list_view_window.h"
+#import "ui/base/cocoa/window_size_constants.h"
+
@implementation AppListViewWindow;
- (id)initAsBubble {
- const int kWindowWidth = 200;
- const int kWindowHeight = 200;
- NSRect frame = NSMakeRect(0, 0, kWindowWidth, kWindowHeight);
- if ((self = [super initWithContentRect:frame
+ if ((self = [super initWithContentRect:ui::kWindowSizeDeterminedLater
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO])) {
[self setReleasedWhenClosed:NO];
- [self setBackgroundColor:[NSColor grayColor]];
+ [self setBackgroundColor:[NSColor clearColor]];
+ [self setOpaque:NO];
+ [self setHasShadow:NO];
}
return self;
}
+- (void)setAppListView:(NSView*)view {
+ [self setContentSize:[view frame].size];
+ [self setContentView:view];
+}
+
@end
diff --git a/ui/app_list/cocoa/app_list_view_window_unittest.mm b/ui/app_list/cocoa/app_list_view_window_unittest.mm
index 5f5e187..0c2de51 100644
--- a/ui/app_list/cocoa/app_list_view_window_unittest.mm
+++ b/ui/app_list/cocoa/app_list_view_window_unittest.mm
@@ -2,18 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/memory/scoped_nsobject.h"
+#import "base/memory/scoped_nsobject.h"
#import "testing/gtest_mac.h"
+#import "ui/app_list/cocoa/app_list_view.h"
#import "ui/app_list/cocoa/app_list_view_window.h"
#import "ui/base/test/ui_cocoa_test_helper.h"
-// Unit test harness for Cocoa-specific interactions with the app_list.
+namespace {
+
class AppListViewWindowTest : public ui::CocoaTest {
public:
- AppListViewWindowTest() {
- Init();
- window_.reset([[AppListViewWindow alloc] initAsBubble]);
- }
+ AppListViewWindowTest();
+
+ void Show();
+ void Release();
protected:
scoped_nsobject<AppListViewWindow> window_;
@@ -22,11 +24,40 @@ class AppListViewWindowTest : public ui::CocoaTest {
DISALLOW_COPY_AND_ASSIGN(AppListViewWindowTest);
};
-// Test showing, hiding and closing the AppListViewWindow with no content.
-TEST_F(AppListViewWindowTest, ShowHideCloseRelease) {
+AppListViewWindowTest::AppListViewWindowTest() {
+ Init();
+ window_.reset([[AppListViewWindow alloc] initAsBubble]);
+}
+
+void AppListViewWindowTest::Show() {
[window_ makeKeyAndOrderFront:nil];
- [window_ close];
- [window_ setReleasedWhenClosed:YES];
+}
+
+void AppListViewWindowTest::Release() {
+ EXPECT_TRUE(window_.get());
+ EXPECT_FALSE([window_ isReleasedWhenClosed]);
[window_ close];
window_.reset();
}
+
+} // namespace
+
+// Test showing, hiding and closing the AppListViewWindow with no content.
+TEST_F(AppListViewWindowTest, ShowHideCloseRelease) {
+ Show();
+ EXPECT_TRUE([window_ isVisible]);
+ [window_ close]; // Hide.
+ EXPECT_FALSE([window_ isVisible]);
+ Show();
+ Release();
+}
+
+// Test allocating the AppListView in an AppListViewWindow, and showing.
+TEST_F(AppListViewWindowTest, AddViewAndShow) {
+ scoped_nsobject<AppListView> contentView(
+ [[AppListView alloc] initWithViewDelegate:NULL]);
+ [window_ setAppListView:contentView];
+ Show();
+ EXPECT_TRUE([contentView superview]);
+ Release();
+}
diff --git a/ui/ui.gyp b/ui/ui.gyp
index f074cdb..20b549c 100644
--- a/ui/ui.gyp
+++ b/ui/ui.gyp
@@ -898,5 +898,61 @@
},
],
}],
+ ['OS=="mac"', {
+ 'targets': [
+ {
+ 'target_name': 'ui_cocoa_third_party_toolkits',
+ 'type': '<(component)',
+ 'sources': [
+ # Build Apple sample code
+ '../third_party/apple_sample_code/ImageAndTextCell.h',
+ '../third_party/apple_sample_code/ImageAndTextCell.m',
+ # Build the necessary GTM sources
+ '../third_party/GTM/AppKit/GTMFadeTruncatingTextFieldCell.h',
+ '../third_party/GTM/AppKit/GTMFadeTruncatingTextFieldCell.m',
+ '../third_party/GTM/AppKit/GTMIBArray.h',
+ '../third_party/GTM/AppKit/GTMIBArray.m',
+ '../third_party/GTM/AppKit/GTMKeyValueAnimation.h',
+ '../third_party/GTM/AppKit/GTMKeyValueAnimation.m',
+ '../third_party/GTM/AppKit/GTMNSAnimation+Duration.h',
+ '../third_party/GTM/AppKit/GTMNSAnimation+Duration.m',
+ '../third_party/GTM/AppKit/GTMNSBezierPath+CGPath.h',
+ '../third_party/GTM/AppKit/GTMNSBezierPath+CGPath.m',
+ '../third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h',
+ '../third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.m',
+ '../third_party/GTM/AppKit/GTMNSColor+Luminance.m',
+ '../third_party/GTM/AppKit/GTMUILocalizer.h',
+ '../third_party/GTM/AppKit/GTMUILocalizer.m',
+ '../third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h',
+ '../third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.m',
+ '../third_party/GTM/Foundation/GTMNSNumber+64Bit.h',
+ '../third_party/GTM/Foundation/GTMNSNumber+64Bit.m',
+ '../third_party/GTM/Foundation/GTMNSObject+KeyValueObserving.h',
+ '../third_party/GTM/Foundation/GTMNSObject+KeyValueObserving.m',
+ # MolokoCacao additions
+ '../third_party/molokocacao/NSBezierPath+MCAdditions.h',
+ '../third_party/molokocacao/NSBezierPath+MCAdditions.m',
+ # Build necessary Mozilla sources
+ '../third_party/mozilla/NSScreen+Utils.h',
+ '../third_party/mozilla/NSScreen+Utils.m',
+ '../third_party/mozilla/NSWorkspace+Utils.h',
+ '../third_party/mozilla/NSWorkspace+Utils.m',
+ ],
+ 'include_dirs': [
+ '..',
+ '../third_party/apple',
+ '../third_party/GTM',
+ '../third_party/GTM/AppKit',
+ '../third_party/GTM/DebugUtils',
+ '../third_party/GTM/Foundation',
+ ],
+ 'link_settings': {
+ 'libraries': [
+ '$(SDKROOT)/System/Library/Frameworks/Cocoa.framework',
+ ],
+ },
+ },
+ ],
+ }],
],
}