diff options
-rw-r--r-- | apps/app_window.cc | 12 | ||||
-rw-r--r-- | apps/app_window.h | 3 | ||||
-rw-r--r-- | apps/ui/native_app_window.h | 3 | ||||
-rw-r--r-- | apps/ui/views/app_window_frame_view.cc | 15 | ||||
-rw-r--r-- | apps/ui/views/app_window_frame_view.h | 6 | ||||
-rw-r--r-- | apps/ui/views/native_app_window_views.cc | 8 | ||||
-rw-r--r-- | apps/ui/views/native_app_window_views.h | 3 | ||||
-rw-r--r-- | chrome/browser/extensions/api/app_window/app_window_api.cc | 34 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h | 3 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm | 7 | ||||
-rw-r--r-- | chrome/browser/ui/views/apps/chrome_native_app_window_views.cc | 23 | ||||
-rw-r--r-- | chrome/browser/ui/views/apps/chrome_native_app_window_views.h | 6 | ||||
-rw-r--r-- | chrome/common/extensions/api/app_window.idl | 18 | ||||
-rw-r--r-- | chrome/renderer/resources/extensions/app_window_custom_bindings.js | 13 | ||||
-rw-r--r-- | chrome/test/data/extensions/platform_apps/window_api/test.js | 41 |
15 files changed, 154 insertions, 41 deletions
diff --git a/apps/app_window.cc b/apps/app_window.cc index efe31d2..cf20eea 100644 --- a/apps/app_window.cc +++ b/apps/app_window.cc @@ -709,7 +709,17 @@ void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { properties->SetBoolean("maximized", native_app_window_->IsMaximized()); properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); - properties->SetInteger("frameColor", native_app_window_->FrameColor()); + + // These properties are undocumented and are to enable testing. Alpha is + // removed to + // make the values easier to check. + SkColor transparent_white = ~SK_ColorBLACK; + properties->SetInteger( + "activeFrameColor", + native_app_window_->ActiveFrameColor() & transparent_white); + properties->SetInteger( + "inactiveFrameColor", + native_app_window_->InactiveFrameColor() & transparent_white); gfx::Rect content_bounds = GetClientBounds(); gfx::Size content_min_size = native_app_window_->GetContentMinimumSize(); diff --git a/apps/app_window.h b/apps/app_window.h index cb9bf17..aecd250 100644 --- a/apps/app_window.h +++ b/apps/app_window.h @@ -142,7 +142,8 @@ class AppWindow : public content::NotificationObserver, Frame frame; bool has_frame_color; - SkColor frame_color; + SkColor active_frame_color; + SkColor inactive_frame_color; bool transparent_background; // Only supported on ash. // The initial content/inner bounds specification (excluding any window diff --git a/apps/ui/native_app_window.h b/apps/ui/native_app_window.h index ba033a1..cde4c1d 100644 --- a/apps/ui/native_app_window.h +++ b/apps/ui/native_app_window.h @@ -60,7 +60,8 @@ class NativeAppWindow : public ui::BaseWindow, // Returns information about the window's frame. virtual bool HasFrameColor() const = 0; - virtual SkColor FrameColor() const = 0; + virtual SkColor ActiveFrameColor() const = 0; + virtual SkColor InactiveFrameColor() const = 0; // Returns the difference between the window bounds (including titlebar and // borders) and the content bounds, if any. diff --git a/apps/ui/views/app_window_frame_view.cc b/apps/ui/views/app_window_frame_view.cc index 6a14e1f..db4d52b 100644 --- a/apps/ui/views/app_window_frame_view.cc +++ b/apps/ui/views/app_window_frame_view.cc @@ -39,11 +39,13 @@ const char AppWindowFrameView::kViewClassName[] = AppWindowFrameView::AppWindowFrameView(views::Widget* widget, NativeAppWindow* window, bool draw_frame, - const SkColor& frame_color) + const SkColor& active_frame_color, + const SkColor& inactive_frame_color) : widget_(widget), window_(window), draw_frame_(draw_frame), - frame_color_(frame_color), + active_frame_color_(active_frame_color), + inactive_frame_color_(inactive_frame_color), close_button_(NULL), maximize_button_(NULL), restore_button_(NULL), @@ -232,8 +234,6 @@ void AppWindowFrameView::GetWindowMask(const gfx::Size& size, // We got nothing to say about no window mask. } -// views::View implementation. - gfx::Size AppWindowFrameView::GetPreferredSize() { gfx::Size pref = widget_->client_view()->GetPreferredSize(); gfx::Rect bounds(0, 0, pref.width(), pref.height()); @@ -308,7 +308,10 @@ void AppWindowFrameView::OnPaint(gfx::Canvas* canvas) { SkPaint paint; paint.setAntiAlias(false); paint.setStyle(SkPaint::kFill_Style); - paint.setColor(frame_color_); + if (widget_->IsActive()) + paint.setColor(active_frame_color_); + else + paint.setColor(inactive_frame_color_); gfx::Path path; path.moveTo(0, 0); path.lineTo(width(), 0); @@ -350,8 +353,6 @@ gfx::Size AppWindowFrameView::GetMaximumSize() { return max_size; } -// views::ButtonListener implementation. - void AppWindowFrameView::ButtonPressed(views::Button* sender, const ui::Event& event) { DCHECK(draw_frame_); diff --git a/apps/ui/views/app_window_frame_view.h b/apps/ui/views/app_window_frame_view.h index 5f15431..a0fa71d 100644 --- a/apps/ui/views/app_window_frame_view.h +++ b/apps/ui/views/app_window_frame_view.h @@ -51,7 +51,8 @@ class AppWindowFrameView : public views::NonClientFrameView, AppWindowFrameView(views::Widget* widget, NativeAppWindow* window, bool draw_frame, - const SkColor& frame_color); + const SkColor& active_frame_color, + const SkColor& inactive_frame_color); virtual ~AppWindowFrameView(); void Init(); @@ -90,7 +91,8 @@ class AppWindowFrameView : public views::NonClientFrameView, views::Widget* widget_; NativeAppWindow* window_; bool draw_frame_; - SkColor frame_color_; + SkColor active_frame_color_; + SkColor inactive_frame_color_; views::ImageButton* close_button_; views::ImageButton* maximize_button_; views::ImageButton* restore_button_; diff --git a/apps/ui/views/native_app_window_views.cc b/apps/ui/views/native_app_window_views.cc index 304b1cf..04e7d9f 100644 --- a/apps/ui/views/native_app_window_views.cc +++ b/apps/ui/views/native_app_window_views.cc @@ -363,7 +363,13 @@ bool NativeAppWindowViews::IsFrameless() const { return frameless_; } bool NativeAppWindowViews::HasFrameColor() const { return false; } -SkColor NativeAppWindowViews::FrameColor() const { return SK_ColorBLACK; } +SkColor NativeAppWindowViews::ActiveFrameColor() const { + return SK_ColorBLACK; +} + +SkColor NativeAppWindowViews::InactiveFrameColor() const { + return SK_ColorBLACK; +} gfx::Insets NativeAppWindowViews::GetFrameInsets() const { if (frameless_) diff --git a/apps/ui/views/native_app_window_views.h b/apps/ui/views/native_app_window_views.h index 47f4ba1..696cb2f 100644 --- a/apps/ui/views/native_app_window_views.h +++ b/apps/ui/views/native_app_window_views.h @@ -146,7 +146,8 @@ class NativeAppWindowViews : public NativeAppWindow, const content::NativeWebKeyboardEvent& event) OVERRIDE; virtual bool IsFrameless() const OVERRIDE; virtual bool HasFrameColor() const OVERRIDE; - virtual SkColor FrameColor() const OVERRIDE; + virtual SkColor ActiveFrameColor() const OVERRIDE; + virtual SkColor InactiveFrameColor() const OVERRIDE; virtual gfx::Insets GetFrameInsets() const OVERRIDE; virtual void HideWithApp() OVERRIDE; virtual void ShowWithApp() OVERRIDE; diff --git a/chrome/browser/extensions/api/app_window/app_window_api.cc b/chrome/browser/extensions/api/app_window/app_window_api.cc index 3c82405..14af30a 100644 --- a/chrome/browser/extensions/api/app_window/app_window_api.cc +++ b/chrome/browser/extensions/api/app_window/app_window_api.cc @@ -44,8 +44,10 @@ const char kInvalidWindowId[] = const char kInvalidColorSpecification[] = "The color specification could not be parsed."; const char kInvalidChannelForFrameOptions[] = - "frameOptions is only available in dev channel."; + "Frame options are only available in dev channel."; const char kColorWithFrameNone[] = "Windows with no frame cannot have a color."; +const char kInactiveColorWithoutColor[] = + "frame.inactiveColor must be used with frame.color."; const char kConflictingBoundsOptions[] = "The $1 property cannot be specified for both inner and outer bounds."; } // namespace app_window_constants @@ -451,13 +453,30 @@ bool AppWindowCreateFunction::GetFrameOptions( return false; } - if (image_util::ParseCSSColorString(*options.frame->as_frame_options->color, - &create_params->frame_color)) { - create_params->has_frame_color = true; - return true; + if (!image_util::ParseCSSColorString( + *options.frame->as_frame_options->color, + &create_params->active_frame_color)) { + error_ = app_window_constants::kInvalidColorSpecification; + return false; + } + + create_params->has_frame_color = true; + create_params->inactive_frame_color = create_params->active_frame_color; + + if (options.frame->as_frame_options->inactive_color.get()) { + if (!image_util::ParseCSSColorString( + *options.frame->as_frame_options->inactive_color, + &create_params->inactive_frame_color)) { + error_ = app_window_constants::kInvalidColorSpecification; + return false; + } } - error_ = app_window_constants::kInvalidColorSpecification; + return true; + } + + if (options.frame->as_frame_options->inactive_color.get()) { + error_ = app_window_constants::kInactiveColorWithoutColor; return false; } @@ -473,7 +492,8 @@ void AppWindowCreateFunction::UpdateFrameOptionsForChannel( // TODO(benwells): Remove this code once we get agreement to use the new // native style frame. create_params->has_frame_color = true; - create_params->frame_color = SK_ColorWHITE; + create_params->active_frame_color = SK_ColorWHITE; + create_params->inactive_frame_color = SK_ColorWHITE; } #endif } diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h index 94eb252..0bc5110 100644 --- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h +++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h @@ -123,7 +123,8 @@ class NativeAppWindowCocoa : public apps::NativeAppWindow, const content::NativeWebKeyboardEvent& event) OVERRIDE; virtual bool IsFrameless() const OVERRIDE; virtual bool HasFrameColor() const OVERRIDE; - virtual SkColor FrameColor() const OVERRIDE; + virtual SkColor ActiveFrameColor() const OVERRIDE; + virtual SkColor InactiveFrameColor() const OVERRIDE; virtual gfx::Insets GetFrameInsets() const OVERRIDE; // These are used to simulate Mac-style hide/show. Since windows can be hidden diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm index 395e1d3..1b4af00 100644 --- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm +++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm @@ -723,7 +723,12 @@ bool NativeAppWindowCocoa::HasFrameColor() const { return false; } -SkColor NativeAppWindowCocoa::FrameColor() const { +SkColor NativeAppWindowCocoa::ActiveFrameColor() const { + // TODO(benwells): Implement this. + return SkColor(); +} + +SkColor NativeAppWindowCocoa::InactiveFrameColor() const { // TODO(benwells): Implement this. return SkColor(); } diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc index 76af22f..590164d 100644 --- a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc +++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc @@ -192,7 +192,9 @@ class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate, ChromeNativeAppWindowViews::ChromeNativeAppWindowViews() : is_fullscreen_(false), has_frame_color_(false), - frame_color_(SK_ColorBLACK) {} + active_frame_color_(SK_ColorBLACK), + inactive_frame_color_(SK_ColorBLACK) { +} ChromeNativeAppWindowViews::~ChromeNativeAppWindowViews() {} @@ -347,8 +349,12 @@ ChromeNativeAppWindowViews::CreateStandardDesktopAppFrame() { apps::AppWindowFrameView* ChromeNativeAppWindowViews::CreateNonStandardAppFrame() { - apps::AppWindowFrameView* frame = new apps::AppWindowFrameView( - widget(), this, has_frame_color_, frame_color_); + apps::AppWindowFrameView* frame = + new apps::AppWindowFrameView(widget(), + this, + has_frame_color_, + active_frame_color_, + inactive_frame_color_); frame->Init(); #if defined(USE_ASH) // For Aura windows on the Ash desktop the sizes are different and the user @@ -669,7 +675,13 @@ bool ChromeNativeAppWindowViews::HasFrameColor() const { return has_frame_color_; } -SkColor ChromeNativeAppWindowViews::FrameColor() const { return frame_color_; } +SkColor ChromeNativeAppWindowViews::ActiveFrameColor() const { + return active_frame_color_; +} + +SkColor ChromeNativeAppWindowViews::InactiveFrameColor() const { + return inactive_frame_color_; +} // NativeAppWindowViews implementation. @@ -678,7 +690,8 @@ void ChromeNativeAppWindowViews::InitializeWindow( const AppWindow::CreateParams& create_params) { DCHECK(widget()); has_frame_color_ = create_params.has_frame_color; - frame_color_ = create_params.frame_color; + active_frame_color_ = create_params.active_frame_color; + inactive_frame_color_ = create_params.inactive_frame_color; if (create_params.window_type == AppWindow::WINDOW_TYPE_PANEL || create_params.window_type == AppWindow::WINDOW_TYPE_V1_PANEL) { InitializePanelWindow(create_params); diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views.h b/chrome/browser/ui/views/apps/chrome_native_app_window_views.h index 864c0c3..ec2b160 100644 --- a/chrome/browser/ui/views/apps/chrome_native_app_window_views.h +++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views.h @@ -75,7 +75,8 @@ class ChromeNativeAppWindowViews : public apps::NativeAppWindowViews, virtual void UpdateBadgeIcon() OVERRIDE; virtual void UpdateShape(scoped_ptr<SkRegion> region) OVERRIDE; virtual bool HasFrameColor() const OVERRIDE; - virtual SkColor FrameColor() const OVERRIDE; + virtual SkColor ActiveFrameColor() const OVERRIDE; + virtual SkColor InactiveFrameColor() const OVERRIDE; // NativeAppWindowViews implementation. virtual void InitializeWindow( @@ -90,7 +91,8 @@ class ChromeNativeAppWindowViews : public apps::NativeAppWindowViews, scoped_ptr<SkRegion> shape_; bool has_frame_color_; - SkColor frame_color_; + SkColor active_frame_color_; + SkColor inactive_frame_color_; gfx::Size preferred_size_; // The class that registers for keyboard shortcuts for extension commands. diff --git a/chrome/common/extensions/api/app_window.idl b/chrome/common/extensions/api/app_window.idl index 80b9b28..0b2d3e8 100644 --- a/chrome/common/extensions/api/app_window.idl +++ b/chrome/common/extensions/api/app_window.idl @@ -105,9 +105,22 @@ namespace app.window { // nested elements.<br> DOMString? type; // Allows the frame color to be set. Frame coloring is only available if the - // frame type is <code>chrome</code>. + // frame type is <code>chrome</code>.<br> // Frame coloring is experimental and only available in dev channel. DOMString? color; + // Allows the frame color of the window when active to be set. Frame + // coloring is only available if the frame type is <code>chrome</code>.<br> + // Frame coloring is only available if the frame type is + // <code>chrome</code>.<br> + // Frame coloring is experimental and only available in dev channel. + DOMString? activeColor; + // Allows the frame color of the window when inactive to be set differently + // to the active color. Frame + // coloring is only available if the frame type is <code>chrome</code>.<br> + // <code>inactiveColor</code> must be used in conjunction with <code> + // color</code>.<br> + // Frame coloring is experimental and only available in dev channel. + DOMString? inactiveColor; }; // State of a window: normal, fullscreen, maximized, minimized. @@ -329,7 +342,8 @@ namespace app.window { // Accessors for testing. [nodoc] boolean hasFrameColor; - [nodoc] long frameColor; + [nodoc] long activeFrameColor; + [nodoc] long inactiveFrameColor; // Set whether the window should stay above most other windows. Requires the // <code>"app.window.alwaysOnTop"</code> permission. diff --git a/chrome/renderer/resources/extensions/app_window_custom_bindings.js b/chrome/renderer/resources/extensions/app_window_custom_bindings.js index c19214e..87ec1b3 100644 --- a/chrome/renderer/resources/extensions/app_window_custom_bindings.js +++ b/chrome/renderer/resources/extensions/app_window_custom_bindings.js @@ -251,8 +251,14 @@ appWindow.registerCustomHook(function(bindingsAPI) { return appWindowData.hasFrameColor; }}); - Object.defineProperty(AppWindow.prototype, 'frameColor', {get: function() { - return appWindowData.frameColor; + Object.defineProperty(AppWindow.prototype, 'activeFrameColor', + {get: function() { + return appWindowData.activeFrameColor; + }}); + + Object.defineProperty(AppWindow.prototype, 'inactiveFrameColor', + {get: function() { + return appWindowData.inactiveFrameColor; }}); appWindowData = { @@ -284,7 +290,8 @@ appWindow.registerCustomHook(function(bindingsAPI) { maximized: params.maximized, alwaysOnTop: params.alwaysOnTop, hasFrameColor: params.hasFrameColor, - frameColor: params.frameColor + activeFrameColor: params.activeFrameColor, + inactiveFrameColor: params.inactiveFrameColor }; currentAppWindow = new AppWindow; }); diff --git a/chrome/test/data/extensions/platform_apps/window_api/test.js b/chrome/test/data/extensions/platform_apps/window_api/test.js index b2a53ee..4dd1dea 100644 --- a/chrome/test/data/extensions/platform_apps/window_api/test.js +++ b/chrome/test/data/extensions/platform_apps/window_api/test.js @@ -1272,7 +1272,8 @@ function testFrameColors() { }, callbackPass(function(win) { chrome.test.assertEq(true, win.hasFrameColor); - chrome.test.assertEq(-16777216, win.frameColor); + chrome.test.assertEq(0x000000, win.activeFrameColor); + chrome.test.assertEq(0x000000, win.inactiveFrameColor); win.close(); })); }, @@ -1285,7 +1286,24 @@ function testFrameColors() { }, callbackPass(function(win) { chrome.test.assertEq(true, win.hasFrameColor); - chrome.test.assertEq(-1, win.frameColor); + chrome.test.assertEq(0xFFFFFF, win.activeFrameColor); + chrome.test.assertEq(0xFFFFFF, win.inactiveFrameColor); + win.close(); + })); + }, + + function testWithActiveInactive() { + chrome.app.window.create('test.html', { + frame: { + type: 'chrome', + color: '#000000', + inactiveColor: '#FFFFFF' + } + }, + callbackPass(function(win) { + chrome.test.assertEq(true, win.hasFrameColor); + chrome.test.assertEq(0x000000, win.activeFrameColor); + chrome.test.assertEq(0xFFFFFF, win.inactiveFrameColor); win.close(); })); }, @@ -1298,7 +1316,8 @@ function testFrameColors() { }, callbackPass(function(win) { chrome.test.assertEq(true, win.hasFrameColor); - chrome.test.assertEq(-1, win.frameColor); + chrome.test.assertEq(0xFFFFFF, win.activeFrameColor); + chrome.test.assertEq(0xFFFFFF, win.inactiveFrameColor); win.close(); })); }, @@ -1313,7 +1332,16 @@ function testFrameColors() { callbackFail('Windows with no frame cannot have a color.')); }, - function testWithInvalidColor() { + function testWithInactiveColorAndNoColor() { + chrome.app.window.create('test.html', { + frame: { + inactiveColor: '#FFF' + } + }, + callbackFail('frame.inactiveColor must be used with frame.color.')); + }, + + function testWithInvalidColor() { chrome.app.window.create('test.html', { frame: { color: 'DontWorryBeHappy' @@ -1330,7 +1358,8 @@ function testFrameColorsInStable() { chrome.app.window.create('test.html', callbackPass(function(win) { if (navigator.platform.substr(0, 3).toLowerCase() == "win") { chrome.test.assertEq(true, win.hasFrameColor); - chrome.test.assertEq(-1, win.frameColor); + chrome.test.assertEq(0xFFFFFF, win.activeFrameColor); + chrome.test.assertEq(0xFFFFFF, win.inactiveFrameColor); } else { chrome.test.assertEq(false, win.hasFrameColor); } @@ -1344,7 +1373,7 @@ function testFrameColorsInStable() { color: '#FFF' } }, - callbackFail('frameOptions is only available in dev channel.')); + callbackFail('Frame options are only available in dev channel.')); } ]); } |