Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a3502f8

Browse files
committed
Add 'show' window field that controls whether window should show on start.
1 parent 767eda5 commit a3502f8

8 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/browser/native_window.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ NativeWindow* NativeWindow::Create(content::Shell* shell,
9797
window->SetTitle(title);
9898

9999
// Then show it.
100-
window->Show();
100+
bool show = true;
101+
manifest->GetBoolean(switches::kmShow, &show);
102+
if (show)
103+
window->Show();
101104

102105
return window;
103106
}

src/browser/native_window_mac.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ - (void)showDevTools:(id)sender {
289289
}
290290

291291
void NativeWindowCocoa::Focus(bool focus) {
292-
if (focus)
292+
if (focus && [window() isVisible])
293293
[window() makeKeyAndOrderFront:nil];
294294
else
295295
[window() orderBack:nil];

src/common/shell_switches.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,6 @@ const char kmMaxHeight[] = "max_height";
7474
const char kmAsDesktop[] = "as_desktop";
7575
const char kmFullscreen[] = "fullscreen";
7676
const char kmFrame[] = "frame";
77+
const char kmShow[] = "show";
7778

7879
} // namespace switches

src/common/shell_switches.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ extern const char kmMaxHeight[];
4343
extern const char kmAsDesktop[];
4444
extern const char kmFullscreen[];
4545
extern const char kmFrame[];
46+
extern const char kmShow[];
4647

4748
} // namespace switches
4849

src/shell.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ Shell* Shell::Create(BrowserContext* browser_context,
6161
base_web_contents);
6262

6363
Shell* shell = new Shell(web_contents, GetPackage()->window());
64-
shell->LoadURL(url);
64+
web_contents->GetController().LoadURL(
65+
url,
66+
Referrer(),
67+
PAGE_TRANSITION_TYPED,
68+
std::string());
6569
return shell;
6670
}
6771

tests/window/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
win.close(true);
2323
this.close(true);
2424
});
25+
26+
gui.Window.get().show();
2527
</script>
2628
<button onclick="win.focus()">Focus</button>
2729
<br/>

tests/window/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"width": 400,
99
"height": 500,
1010
"resizable": false,
11+
"show": false,
1112
"frame": false
1213
}
1314
}

tests/window/popup.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<meta http-equiv="content-type" content="text/html; charset=utf-8">
44
<title>New Window</title>
55
</head>
6-
<body>
6+
<body style="margin:0">
77
<div style="width: 100%; height: 50px; background-color: green; -webkit-app-region: drag;">
88
</div>
99
This is the popup window<br/>
@@ -41,6 +41,10 @@
4141
win.on('restore', function() {
4242
console.log('Window is restored');
4343
});
44+
45+
window.onload = function() {
46+
gui.Window.get().show();
47+
}
4448
</script>
4549
<button onclick="javascript:enable = true;">Enable to be closed</button>
4650
<br/>

0 commit comments

Comments
 (0)