Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: apps/app_window.cc

Issue 375183002: Add app.window.alphaEnabled() and onAlphaEnabledChanged. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "apps/app_window.h" 5 #include "apps/app_window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "apps/app_window_geometry_cache.h" 9 #include "apps/app_window_geometry_cache.h"
10 #include "apps/app_window_registry.h" 10 #include "apps/app_window_registry.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 frame(AppWindow::FRAME_CHROME), 158 frame(AppWindow::FRAME_CHROME),
159 has_frame_color(false), 159 has_frame_color(false),
160 active_frame_color(SK_ColorBLACK), 160 active_frame_color(SK_ColorBLACK),
161 inactive_frame_color(SK_ColorBLACK), 161 inactive_frame_color(SK_ColorBLACK),
162 transparent_background(false), 162 transparent_background(false),
163 creator_process_id(0), 163 creator_process_id(0),
164 state(ui::SHOW_STATE_DEFAULT), 164 state(ui::SHOW_STATE_DEFAULT),
165 hidden(false), 165 hidden(false),
166 resizable(true), 166 resizable(true),
167 focused(true), 167 focused(true),
168 always_on_top(false) {} 168 always_on_top(false) {}
tapted 2014/07/14 03:30:24 initialize requested_transparent_background_?
jackhou1 2014/07/14 04:51:02 Done.
169 169
170 AppWindow::CreateParams::~CreateParams() {} 170 AppWindow::CreateParams::~CreateParams() {}
171 171
172 gfx::Rect AppWindow::CreateParams::GetInitialWindowBounds( 172 gfx::Rect AppWindow::CreateParams::GetInitialWindowBounds(
173 const gfx::Insets& frame_insets) const { 173 const gfx::Insets& frame_insets) const {
174 // Combine into a single window bounds. 174 // Combine into a single window bounds.
175 gfx::Rect combined_bounds(window_spec.bounds); 175 gfx::Rect combined_bounds(window_spec.bounds);
176 if (content_spec.bounds.x() != BoundsSpecification::kUnspecifiedPosition) 176 if (content_spec.bounds.x() != BoundsSpecification::kUnspecifiedPosition)
177 combined_bounds.set_x(content_spec.bounds.x() - frame_insets.left()); 177 combined_bounds.set_x(content_spec.bounds.x() - frame_insets.left());
178 if (content_spec.bounds.y() != BoundsSpecification::kUnspecifiedPosition) 178 if (content_spec.bounds.y() != BoundsSpecification::kUnspecifiedPosition)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // Initialize the window 277 // Initialize the window
278 CreateParams new_params = LoadDefaults(params); 278 CreateParams new_params = LoadDefaults(params);
279 window_type_ = new_params.window_type; 279 window_type_ = new_params.window_type;
280 window_key_ = new_params.window_key; 280 window_key_ = new_params.window_key;
281 281
282 // Windows cannot be always-on-top in fullscreen mode for security reasons. 282 // Windows cannot be always-on-top in fullscreen mode for security reasons.
283 cached_always_on_top_ = new_params.always_on_top; 283 cached_always_on_top_ = new_params.always_on_top;
284 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) 284 if (new_params.state == ui::SHOW_STATE_FULLSCREEN)
285 new_params.always_on_top = false; 285 new_params.always_on_top = false;
286 286
287 requested_transparent_background_ = new_params.transparent_background;
288
287 native_app_window_.reset(delegate_->CreateNativeAppWindow(this, new_params)); 289 native_app_window_.reset(delegate_->CreateNativeAppWindow(this, new_params));
288 290
289 // Prevent the browser process from shutting down while this window exists. 291 // Prevent the browser process from shutting down while this window exists.
290 AppsClient::Get()->IncrementKeepAliveCount(); 292 AppsClient::Get()->IncrementKeepAliveCount();
291 UpdateExtensionAppIcon(); 293 UpdateExtensionAppIcon();
292 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this); 294 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this);
293 295
294 if (new_params.hidden) { 296 if (new_params.hidden) {
295 // Although the window starts hidden by default, calling Hide() here 297 // Although the window starts hidden by default, calling Hide() here
296 // notifies observers of the window being hidden. 298 // notifies observers of the window being hidden.
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 OnNativeWindowChanged(); 737 OnNativeWindowChanged();
736 } 738 }
737 739
738 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; } 740 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; }
739 741
740 void AppWindow::WindowEventsReady() { 742 void AppWindow::WindowEventsReady() {
741 can_send_events_ = true; 743 can_send_events_ = true;
742 SendOnWindowShownIfShown(); 744 SendOnWindowShownIfShown();
743 } 745 }
744 746
747 bool AppWindow::RequestedTransparentBackground() const {
748 return requested_transparent_background_;
749 }
750
745 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { 751 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const {
746 DCHECK(properties); 752 DCHECK(properties);
747 753
748 properties->SetBoolean("fullscreen", 754 properties->SetBoolean("fullscreen",
749 native_app_window_->IsFullscreenOrPending()); 755 native_app_window_->IsFullscreenOrPending());
750 properties->SetBoolean("minimized", native_app_window_->IsMinimized()); 756 properties->SetBoolean("minimized", native_app_window_->IsMinimized());
751 properties->SetBoolean("maximized", native_app_window_->IsMaximized()); 757 properties->SetBoolean("maximized", native_app_window_->IsMaximized());
752 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop()); 758 properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop());
753 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor()); 759 properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor());
760 properties->SetBoolean("alphaEnabled",
761 requested_transparent_background_ &&
762 native_app_window_->CanHaveAlphaEnabled());
754 763
755 // These properties are undocumented and are to enable testing. Alpha is 764 // These properties are undocumented and are to enable testing. Alpha is
756 // removed to 765 // removed to
757 // make the values easier to check. 766 // make the values easier to check.
758 SkColor transparent_white = ~SK_ColorBLACK; 767 SkColor transparent_white = ~SK_ColorBLACK;
759 properties->SetInteger( 768 properties->SetInteger(
760 "activeFrameColor", 769 "activeFrameColor",
761 native_app_window_->ActiveFrameColor() & transparent_white); 770 native_app_window_->ActiveFrameColor() & transparent_white);
762 properties->SetInteger( 771 properties->SetInteger(
763 "inactiveFrameColor", 772 "inactiveFrameColor",
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 region.bounds.x(), 1151 region.bounds.x(),
1143 region.bounds.y(), 1152 region.bounds.y(),
1144 region.bounds.right(), 1153 region.bounds.right(),
1145 region.bounds.bottom(), 1154 region.bounds.bottom(),
1146 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 1155 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
1147 } 1156 }
1148 return sk_region; 1157 return sk_region;
1149 } 1158 }
1150 1159
1151 } // namespace apps 1160 } // namespace apps
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698