How to implement Chrome Metro mode? - google-chrome

I want implement like Chrome Metro mode in my desktop app.
Please help me.
class WRLAppViewSource : public mswr::RuntimeClass<winapp::Core::IFrameworkViewSource> {
...
};
mswrw::RoInitializeWrapper roinit(RO_INIT_MULTITHREADED);
HRESULT hr;
mswr::ComPtr<winapp::Core::ICoreApplication> core_app;
hr = CreateActivationFactory(
RuntimeClass_Windows_ApplicationModel_Core_CoreApplication,
core_app.GetAddressOf());
HSTRING id;
hr = core_app->get_Id(&id);
auto viewSource = mswr::Make<WRLAppViewSource>();
hr = core_app->Run(viewSource.Get());
"hr = core_app->Run(viewSource.Get()); " return "hr = 0x80004015 : The class is configured to run as a security id different from the caller".

The "Metro mode" environment (typically used by Windows Store apps) that Chrome, IE, and FireFox use is not available to general purpose desktop apps.
Chrome can do this because it is a "New experience enabled desktop browser" and is selected by the user as the default browser. If you change your default browser to IE then Chrome will lose this ability and IE will gain it.
If you are writing a browser then take a look at the Developing a new experience enabled Desktop Browser white paper.
If you are not writing a browser and are trying to add a Windows Store UI to an existing desktop enterprise app then take a look at Brokered Windows Runtime Components (BWRC). BWRCs allow a side-loaded .Net Windows Store app to interop with a desktop component so the Windows Store app can provide a modern UI which connects to an existing back-end.

Related

Spawn default browser with HTML string

I have code (and for decades) that:
given some HTML string in memory
hand that document to an Internet Explorer object
and make Internet Explorer (separate process) visible
all without littering the user's computer with temporary files
In other words:
void SpawnIEWithSource(string szSourceHTML)
{
IWebBrowser ie = (IWebBrowser)CoCreateInstance(CLASS_InternetExplorer, null, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
UuidOf(IUnknown));
ie.Navigate2("about:blank");
ie.Document.Write(szSourceHtml);
ie.Document.Close;
ie.Visible = True;
}
Pros:
opens an HTML report out of process
does not create a temporary file
Cons:
hard-codes the use of Internet Explorer, rather than the user's preferred browser
But IE is going away
Microsoft recently announced that Internet Explorer (the product) will no longer come with Windows, but Internet Explorer (the programming api) will continue to work:
As announced today, Microsoft Edge with IE mode is officially replacing the Internet Explorer 11 desktop application on Windows 10. As a result, the Internet Explorer 11 desktop application will go out of support and be retired on June 15, 2022 for certain versions of Windows 10.
Out of scope at the time of this announcement (unaffected):
Internet Explorer mode in Microsoft Edge
Internet Explorer platform (MSHTML/Trident), including WebOC
Internet Explorer 11 desktop application on:
Windows 8.1
Windows 7 Extended Security Updates (ESU)
Windows 10 Server SAC (all versions)
Windows 10 IoT Long-Term Servicing Channel (LTSC) (all versions)
Windows 10 Server LTSC (all versions)
Windows 10 client LTSC (all versions)
What is the MSHTML (Trident) engine? How does that relate to IE mode?
The MSHTML (Trident) engine is the underlying platform for Internet Explorer 11. This is the same engine used by IE mode and it will continue to be supported (in other words, unaffected by this announcement). WebOC will also continue to be supported. If you have a custom or third-party app that relies on the MSHTML platform, you can expect it to continue to work.
(emphasis mine)
Which means that Microsoft is breaking 23 years of backwards compatibility - and replacing it with...nothing.
So i need to find a way to replace it.
spawn the default browser
give it HTML i want to display
all without temporary files
Bonus Reading
.NET: How to make WebBrowser control launch in IE, display HTML, out of process?
How to put the WebBrowser control into IE9 into standards?
How to start browser with html string with lua
Creating an IWebBrowser2 control
I'd encode HTML into Base64 and make it a Data-URI. All modern browsers are able to handle such URIs. This however won't work if your HTML string is too big.
Basically, it'd go like this:
string Base64Encode(string plainText) {
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}
void SpawnBrowserWithSource(string szSourceHTML) {
System.Diagnostics.Process.Start("data:text/html;base64," + Base64Encode(szSourceHTML));
}
Resulting in:
(code snippets are from the following Stackoverflow answers: base64 encoding and opening default browser)
If you know the user uses Chrome or Edge, you can replace the WebBrowser instance with ChromiumWebBrowser, and use the LoadHtml method to inject the content.
Relevant links:
web browser control in winform with google chrome c#
https://www.telerik.com/support/kb/winforms/details/how-to-embed-chrome-browser-in-a-winforms-application
https://cefsharp.github.io/api/51.0.0/html/T_CefSharp_WinForms_ChromiumWebBrowser.htm

StageWebView - Change system browser

Running StageWebView on a Windows Desktop machine, uses IE as it's browser, no matter what is the systems default Internet Browser. Is it possible to change this to Chrome?
I'm not interested in the built in Webkit browser in AIR
Sorry but the answer is no, the StageWebView class on mobile or desktop uses the OS provided web control to display content on the Stage:
On desktop computers (in the desktop and extended desktop profiles),
the StageWebView class uses the system web control provided by the
Flash Player plugin.
Thus on Windows that would be Internet Explorer (IE) via the IWebBrowser2 interface which Google's Chrome does not support.
Note: This is assuming you are passing true for the useNative parameter on the StageWebView constructor, otherwise the on Windows/OS-X you would get the old built-in Webkit version. This can be checked by seeing which user-agent is used (try http://whatsmyuseragent.com or similar to verify)
Air 18 (or 19 beta results in same rendering) on Windows and OS-X:

Why CEF app is not rendering Polymer UI?

I have developed a web application using Polymer and packaging it as a CEF App. When I launch the application, I only get a blank screen while same application in browser is rendered properly.
I'm using CefSharp (V- 1.19.0.41824) to embed a webView control in my winform application. Below is the code that I'm using for displaying web content in webView -
webView = new WebView();
webView.Load("http://localhost:8000/sampleApp/")
Any pointer will be very useful.
If the current core chrome version used by CEF is lower than 36, then you'll need to enable the experimental flags to allow the web components features.
I don't know how you would enable those flags in your project, but I do know that web components and html link/includes where only made mainstream in the browser core from chrome 36 onwards.

Open url in system browser windows phon

I am making an html5 app for windows phone 8 and I have a link that is generated by JavaScript and passed into a frame. I would like to put an open in browser button on the application bar. With ios you can do this by adding the _system to the link is there an equivalent in WP? Is there any way to open the browser without using the launcher or is there a way to get the JavaScript variable into the launcher?
You can use Launchers to open and system application
Below is the sample code for the same:
WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.Uri = new Uri("http://msdn.microsoft.com", UriKind.Absolute);
webBrowserTask.Show();
MSDN Reference:
How to use the web browser task for Windows Phone

Can a HTML5 web application access the camera on a Windows 7 tablet

I have a HTML/Javascript web application which integrates with a device's camera using PhoneGap.
Is there any way we can run the application on a Windows 7 tablet (e.g. as a normal website) and be able to integrate with the camera on the device.
You will be, eventually, when the getUserMedia API is implemented in more browsers (currently only available in Opera and special builds of other browsers), but at the moment, no.
I don't believe there is a way to do this.
We enabled photos to be dragged into the application to support this feature. It means the user takes a photo as dictated by the tablet and then has to drag/select the appropriate photo file to add to the application.