Skip to content

Commit caedb6a

Browse files
committed
[Screen Selection]
add application name to the UI, cancelChooseDesktopMedia implementation
1 parent 9e81217 commit caedb6a

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/api/screen/desktop_capture_api.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "content/public/browser/render_process_host.h"
1313
#include "content/public/browser/render_view_host.h"
1414
#include "content/public/browser/web_contents.h"
15+
#include "content/nw/src/nw_package.h"
16+
#include "content/nw/src/nw_shell.h"
1517
#include "net/base/net_util.h"
1618
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
1719
#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h"
@@ -68,7 +70,8 @@ bool DesktopCaptureChooseDesktopMediaFunction::RunSync() {
6870
// also be used to determine where to show the picker's UI.
6971
content::WebContents* web_contents = content::WebContents::FromRenderViewHost(render_view_host());
7072
DCHECK(web_contents);
71-
base::string16 target_name;
73+
content::Shell* shell = content::Shell::windows()[0];
74+
base::string16 app_name = base::UTF8ToUTF16(shell->GetPackage()->GetName());
7275

7376
// Register to be notified when the tab is closed.
7477
Observe(web_contents);
@@ -136,8 +139,8 @@ bool DesktopCaptureChooseDesktopMediaFunction::RunSync() {
136139
picker_->Show(web_contents,
137140
parent_window,
138141
parent_window,
139-
target_name,
140-
target_name,
142+
app_name,
143+
app_name,
141144
media_list.Pass(),
142145
callback);
143146
return true;

src/api/screen/screen.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ void Screen::Call(DispatcherHost* dispatcher_host,
164164
// Screen Picker GUI is still active, return false;
165165
result->AppendBoolean(false);
166166
}
167+
} else if (method == "CancelChooseDesktopMedia") {
168+
if (gpDCCDMF) {
169+
gpDCCDMF->Cancel();
170+
gpDCCDMF = NULL;
171+
result->AppendBoolean(true);
172+
} else {
173+
result->AppendBoolean(false);
174+
}
167175
}
168176

169177
}

src/api/screen/screen.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ Screen.prototype.chooseDesktopMedia = function(array, callback) {
7474
return false;
7575
}
7676

77+
Screen.prototype.cancelChooseDesktopMedia = function() {
78+
return nw.callStaticMethodSync('Screen', 'CancelChooseDesktopMedia', [ this.id ])[0];
79+
}
7780
// ======== Screen functions End ========
7881

7982
// Store App object in node's context.

0 commit comments

Comments
 (0)