Skip to content

Commit c740fd6

Browse files
committed
[Transparency] add switch to disable the code
1 parent e837e00 commit c740fd6

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

src/browser/native_window.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "base/memory/weak_ptr.h"
2424
#include "base/values.h"
25+
#include "base/command_line.h"
2526
#include "content/nw/src/browser/capture_page_helper.h"
2627
#include "content/nw/src/common/shell_switches.h"
2728
#include "content/nw/src/nw_package.h"
@@ -38,6 +39,9 @@
3839
#include "content/nw/src/browser/native_window_aura.h"
3940
#endif
4041

42+
namespace content {
43+
extern bool g_support_transparency;
44+
}
4145

4246
namespace nw {
4347

@@ -73,7 +77,9 @@ NativeWindow::NativeWindow(const base::WeakPtr<content::Shell>& shell,
7377
has_frame_(true),
7478
capture_page_helper_(NULL) {
7579
manifest->GetBoolean(switches::kmFrame, &has_frame_);
76-
manifest->GetBoolean(switches::kmTransparent, &transparent_);
80+
content::g_support_transparency = !base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kmDisableTransparency);
81+
if (content::g_support_transparency)
82+
manifest->GetBoolean(switches::kmTransparent, &transparent_);
7783

7884
LoadAppIconFromPackage(manifest);
7985
}

src/browser/native_window_aura.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
8282
#include "ash/accelerators/accelerator_table.h"
8383
#endif
8484

85+
namespace content {
86+
extern bool g_support_transparency;
87+
}
8588

8689

8790
namespace nw {
@@ -296,7 +299,8 @@ NativeWindowAura::NativeWindowAura(const base::WeakPtr<content::Shell>& shell,
296299
params.delegate = this;
297300
params.remove_standard_frame = !has_frame();
298301
params.use_system_default_icon = true;
299-
if (transparent_) params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
302+
if (content::g_support_transparency && transparent_)
303+
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
300304
if (is_fullscreen_)
301305
params.show_state = ui::SHOW_STATE_FULLSCREEN;
302306

@@ -396,6 +400,8 @@ bool NativeWindowAura::IsFullscreen() {
396400
}
397401

398402
void NativeWindowAura::SetTransparent(bool transparent) {
403+
if (!content::g_support_transparency)
404+
return;
399405
#if defined(OS_WIN)
400406
// Check for Windows Vista or higher, transparency isn't supported in
401407
// anything lower.

src/browser/native_window_mac.mm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
#include "third_party/skia/include/core/SkRegion.h"
4242
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
4343

44+
namespace content {
45+
extern bool g_support_transparency;
46+
}
47+
4448
@interface NSWindow (NSPrivateApis)
4549
- (void)setBottomCornerRounded:(BOOL)rounded;
4650
@end
@@ -282,7 +286,7 @@ - (void)drawCustomFrameRect:(NSRect)rect forView:(NSView*)view {
282286
[[NSBezierPath bezierPathWithRoundedRect:[view bounds]
283287
xRadius:cornerRadius
284288
yRadius:cornerRadius] addClip];
285-
if ([self isOpaque])
289+
if ([self isOpaque] || !content::g_support_transparency)
286290
[[NSColor whiteColor] set];
287291
else
288292
[[NSColor clearColor] set];
@@ -548,6 +552,7 @@ - (void)drawRect:(NSRect)dirtyRect {
548552

549553
void NativeWindowCocoa::SetTransparent(bool transparent) {
550554

555+
if (!content::g_support_transparency) return;
551556
if (!transparent_ && transparent) {
552557
opaque_color_ = [window() backgroundColor];
553558
}

src/common/shell_switches.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const char kmAsDesktop[] = "as_desktop";
7373
const char kmFullscreen[] = "fullscreen";
7474
const char kmInitialFocus[] = "focus";
7575
const char kmTransparent[] = "transparent";
76+
const char kmDisableTransparency[] = "disable_transparency";
7677

7778
// Make windows icon hide show or hide in taskbar.
7879
const char kmShowInTaskbar[] = "show_in_taskbar";

src/common/shell_switches.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ extern const char kmKiosk[];
5555
extern const char kmAlwaysOnTop[];
5656
extern const char kmInitialFocus[];
5757
extern const char kmTransparent[];
58+
extern const char kmDisableTransparency[];
5859

5960
extern const char kmWebgl[];
6061
extern const char kmJava[];

0 commit comments

Comments
 (0)