Set a default Search Engine for Google Chrome - c#

I have to develop an exe application that replace the default search engine of Google Chrome and set my private search engine of Google Chrome after installing on that exe.

Preferences are saved within Preferences file in C:\Users\##UserName##\AppData\Local\Google\Chrome\User Data\Default.
That's a JSON file. You should look for following part of the file:
"default_search_provider": {
"alternate_urls": [ "{google:baseURL}#q={searchTerms}", "{google:baseURL}search#q={searchTerms}", "{google:baseURL}webhp#q={searchTerms}" ],
"enabled": true,
"encodings": "UTF-8",
"icon_url": "http://www.google.com/favicon.ico",
"id": "2",
"image_url": "{google:baseURL}searchbyimage/upload",
"image_url_post_params": "encoded_image={google:imageThumbnail},image_url={google:imageURL},sbisrc={google:imageSearchSource},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight}",
"instant_url": "{google:baseURL}webhp?sourceid=chrome-instant&{google:RLZ}{google:forceInstantResults}{google:instantExtendedEnabledParameter}{google:ntpIsThemedParameter}{google:omniboxStartMarginParameter}ie={inputEncoding}",
"instant_url_post_params": "",
"keyword": "google.com",
"name": "Google",
"new_tab_url": "{google:baseURL}_/chrome/newtab?{google:RLZ}{google:instantExtendedEnabledParameter}{google:ntpIsThemedParameter}ie={inputEncoding}",
"prepopulate_id": "1",
"search_terms_replacement_key": "espv",
"search_url": "{google:baseURL}search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:bookmarkBarPinned}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}{google:omniboxStartMarginParameter}ie={inputEncoding}",
"search_url_post_params": "",
"suggest_url": "{google:baseSuggestURL}search?{google:searchFieldtrialParameter}client={google:suggestClient}&xssi=t&q={searchTerms}&{google:cursorPosition}{google:zeroPrefixUrl}{google:pageClassification}sugkey={google:suggestAPIKeyParameter}",
"suggest_url_post_params": "",
"synced_guid": "CE1B8BFD-412B-4AB3-B597-325B07CA7E76"
},
I have no idea how will browser react if you change that file from outside the browser! It's possible that it will be synced back into version stored in cloud when user decided to sync Chrome settings between different machines using Google Account.

I don't think there is an API for doing this via JavaScript or else.
However, this might possible by using the SQLite data file and editing it.
The file on typical Windows 7 can be found at:
C:\Users\ABC\AppData\Local\Google\Chrome\User Data\Default and file is named as 'Web Data'.
To add a search engine, add an entry to the 'keywords' table.
To change the default search engine, edit the 'Default Search Provider ID' value inside the 'meta' table.
Note: This method is not officially supported and you may mess up chrome settings.
Courtesy: Setting the Default Search Provider on Chrome via a script

Related

How to get remote debugging URL of specific ChromiumWebBrowser instance in CefSharp?

Goal
I am trying to get remote debugging URL of specific ChromiumWebBrowser object after initializing it with new ChromiumWebBrowser(...)
Application Info
My application creates multiple ChromiumWebBrowser worker instances at runtime, the number of instances varies according to workload. All of them navigates to some URLs and perform tasks(clicks on buttons, fills inputs, collects values) on sites. If the worker finds unexpected result after it's actions(Couldn't find the div element with given id), it sends notification to the user and hands out it's remote debugging URL which is allowing the user to take control of worker and investigate what went wrong during process.
The Problem
I don't know how to obtain remote debugging URL of specific ChromiumWebBrowser object
e.g. it would be nice if the URL variable could instantiated that easy in the following code block but ChromiumWebBrowser class doesn't have such property (RemoteDebuggingUrl).
ChromiumWebBrowser worker1 = new ChromiumWebBrowser(...);
string URL = worker1.RemoteDebuggingUrl;
Efforts
I decided to dig down into the source code of CefSharp to find out how remote debugging server creates links per ChromiumWebBrowser basis, e.g. i assumed maybe it is accessing of ChromiumWebBrowser objects ID like property because the links of browsers in remote debugging main page (accessed via http://localhost:8088) is like following url ;
http://localhost:8088/devtools/inspector.html?ws=localhost:8088/devtools/page/FA54735587998EFD141A2300AE57F70C
The "FA54735587998EFD141A2300AE57F70C" part is the ID of the remote debugging link as seen in http://localhost:8088/json
[
{
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:8088/devtools/page/FA54735587998EFD141A2300AE57F70C",
"id": "FA54735587998EFD141A2300AE57F70C",
"title": "Sign In",
"type": "page",
"url": "https://af.sts.mapfre.net/adfs/ls/?SAMLRequest=hZJda8IwFIb%2FSsm9TVvFj9AKtk4Q3BDddrGbEeopBpqkyzl1279fWnFzF3NXgZPzJs9zkhSlrhuxaOlodvDWAlLwoWuDot%2FIWOuMsBIVCiM1oKBS7Bf3G5GEkWicJVvaml1FbickIjhS1rBgvczYa5zP8tE0XxXjPJrdjYer8SiaTIplnAxXwyguWPAMDn1%2FxnzchxBbWBskaciXong2iJNBMn6MExFNxTB5YcHSOygjqU8diRoUnMsqRMJQy6ZyEBogLg8V8ho5CwprELrzbpGX5yZRts75daB0U6tSEQtW1pXQDzBjlawROsytN1Un%2BK4sLuLdZa0Gtwd3UiU87TY%2FkJ7uQlhaHZLjGuraGt5YpB1g0zGwedrNWfSjcPM%2Fsym%2FbkvP7%2FzgvdbLrfXonx24lv9odxV1GFR9qyAnDSqv74U82HvhQJKXJNcC4%2FPzlb9%2F0%2FwL",
"webSocketDebuggerUrl": "ws://localhost:8088/devtools/page/FA54735587998EFD141A2300AE57F70C"
}
]
Finally i couldn't navigate to the implementation of following symbol using Visual Studio 2019
bool CefInitialize(const CefMainArgs& args,
const CefSettings& settings,
CefRefPtr<CefApp> application,
void* windows_sandbox_info);
in purpose of finding how remote debugging server works. I located this symbol in "cef_app.h" header file which is part of the cef-sdk.75.1.14 Nuget Package.
I tried to find the implementation of this symbol because i thought it is the entry point of remote debugging server, because it takes CefSettings parameter which includes RemoteDebuggingPort which was 8088 in my case.

Sync gateway is not syncing with Couchbase server in Xamarin

I am trying to use couchbase for online and offline database in my xamarin application .
the offline part is working good , but it doesn't sync .
I followed this tutorial :
https://docs.couchbase.com/userprofile-couchbase-mobile/sync/userprofile/xamarin/userprofile_sync.html
I have installed couchbase server , I created a bucket named : userprofile , and a user and I have enabled the Application Access and Read Only Admin roles.
also I installed sync gateway and I have configured it ,
here is my configuration .json file
{
"log": ["*"],
"databases": {
"userprofile": {
"server": "http://127.0.0.1:8091",
"bucket": "user-profile",
"username": "Maria",
"password": "123456",
"enable_shared_bucket_access": true,
"import_docs": true,
"num_index_replicas": 0,
"delta_sync" :{"enabled":true},
"users": {
"Maria": { "password": "123456"},
"GUEST": { "disabled": false, "admin_channels": ["*"] }
},
"sync": `function (doc, oldDoc) {
if (doc.sdk) {
channel(doc.sdk);
}
}`
}
}
}
and I used this command to configure the sync gateway :
C:\Program Files\Couchbase\Sync Gateway\sync_gateway sync-gateway-config-userprofile-walrus.json
also I have changed the sync url to ws://10.0.2.2:4984 because I am using android emulator .
but it did not sync between devices , can anyone help me please ?
1) How are you verifying if the sync is working (what steps did you follow for testing)? If you are following the instructions here, that won't work with the config you have above. Because the only valid user that you have configured in your config file is the one with credentials "username" and "password" and the steps in tutorial indicates a different username/password. So make sure you log into your app with the credentials you have in your config file and try out
2) You indicated that you have a Couchbase Server running that you have configured for Sync Gateway access. But your config file indicates that you are using "walrus" mode (Walrus mode is a memory only mode intended only for dev/test purposes). In other words, in walrus mode, you are not pointing to an actual couchbase server.
If you want to sync with a backend Couchbase Server(which you should), then replace the "walrus:" in the "server" property in the config file to point to the couchbase server.
3) The best resource to troubleshoot is the Sync Gateway logs. That should give sufficient hints as to what is going wrong with the sync. Post the errors you are seeing if any if the above tips don't work
4) Check out this tutorial for relevant background. Probably from this point

Control application versions on registered MDM device from Google Android Management API

Is there a way to control which version of a particular application from the play store should be installed on the fully managed device using Android Management API?
Example - Install Version 1.0, 2.0 based on what the Admin decides.
Can something be done with ApplicationPolicy and control the application versions, updates from the policy of the device?
{
"packageName": string,
"installType": enum(InstallType),
"lockTaskAllowed": boolean,
"defaultPermissionPolicy": enum(PermissionPolicy),
"permissionGrants": [
{
object(PermissionGrant)
}
],
"managedConfiguration": {
object
},
"disabled": boolean,
"minimumVersionCode": number,
"delegatedScopes": [
enum(DelegatedScope)
],
"managedConfigurationTemplate": {
object(ManagedConfigurationTemplate)
}
}
At the moment I don't believe this is possible. I believe even for Android Management API it still obeys the rules of Google Play where the user is given the latest version.
--- edit
I've just thought of a hack which might make this possible. Eseentially you could give every version of the app a different package name in your build tool, then use admin based targeting to choose which package names are available. It's a bit of a hack, and I probably wouldn't recommend it, but it might be the only way to do what you want.

human handoff bot sample not running

I was trying to run this github bot framework sample but I am getting error.
I have configured Bot on Bot Framework Portal, add botID, AppID, AppPwd in web.config, enabled Directline, configured ngrok.
As soon as I am opening index.html page I am getting following error.
JavaScript critical error at line 83, column 32 in
http://localhost:3979/agentdashboard/index.html?s=DIRECTLINEKEY\n\nSCRIPT1002:
Syntax error
Any idea whats wrong?
JavaScript critical error at line 83, column 32 in http://localhost:3979/agentdashboard/index.html?s=DIRECTLINEKEY\n\nSCRIPT1002: Syntax error
I checked the JavaScript code written in index.html, and I find that the arrow function expression are used. Such as:
const connect = () => {
var name;
if(!connected)
name = "connect"
else
name = "disconnect"
botConnection
.postActivity({type: "event", value: "", from: user, name: name})
.subscribe(connectionSuccess);
};
If you are using the browser that does not support it, which will cause Syntax error.
Same error in Internet Explorer:
Please refer to Browser compatibility of Arrow functions, and browse index.html in the browser that supports arrow function expression to check if it works for you.

Bot framework emulator not working

I started learning bot framework last week, and i decided to start off with the default bot project that returns your input and its number of character. But unfortunately, I couldn't test the bot application in bot emulator. It can't just send my input. It displays "couldn't send" whenever I forward an input.
My endpoint url which is http://localhost:3979/api/messages/ is correctly written there.
What could be wrong? I'm just a starter in bot framework and bot building.
As I'm not aware of the exact code which you are trying to execute, I'd suggest few points to be checked again.
Checkpoints:
Make sure you are running the code in debug mode with any browser (Edge, chrome, explorer etc.) and then run in the emulator.
Configure or link the emulator with ngrok. (Though it is not required when running locally but it may resolve if the emulator is not working with firewall issues)
Please check the Microsoft App Id and Microsoft App Password are the same in emulator and Web.config file.
Try with blank Microsoft App Id and Microsoft App Password in both Web.config file and emulator.
Check if the endpoints on the browser and emulator are the same
If you are encountering other errors like 401, 405, 500 please check this article.
In case if all the check points are right and you are still encountering an issue while running the code in emulator, there might be an issue with the code or reference libraries. You can also check the working example.
Check your visual studio .bot file. It should be like this.......
{
"name": "EmulatorBot",
"description": "",
"services": [
{
"type": "endpoint",[enter image description here][1]
"endpoint": "http://localhost:3978/api/messages",
"name": "EmulatorBot20181123022900",
"id": "25"
}
],
"padlock": "",
"version": "2.0",
"path": "C:\\Users\\suraj.tiwari\\Desktop\\Bot NK\\EmulatorBot\\EmulatorBot.bot",
"overrides": null
}
Add an Endpoint for your bot
Endpoint url : http://localhost:3978/api/messages
Name : EmulatorBot20181123022900

Categories