Why the modification of http header not work in CEF? - google-chrome

I implemented CefRequestHandler interface. In the OnBeforeBrowse method I want to add custom http header but it seems not work. The related code as below
virtual bool OnBeforeBrowse( CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame,
CefRefPtr< CefRequest > request, CefRequestHandler::NavType navType, bool isRedirect )
{
CefRequest::HeaderMap hdrMap;
request->GetHeaderMap(hdrMap);
hdrMap.insert(std::make_pair("Test", "test"));
request->SetHeaderMap(hdrMap);
return false;
}
The request parameter is passed as a pointer so I think the action performed on it should take effect, but actually not.
I'm new to use CEF library, I want't to know is there a way to add custom header before navigation? Thank you in advance!

You can't modify request there:
CefRequestHandler::OnBeforeBrowse()
but try to implement this:
CefRequestHandler::OnBeforeResourceLoad()

Related

I am not able to redirect registered user to dashboard page with link

if (response.success) {
this.redirectURL = response.data.loginUrl;
// this.URL='http://'+location.host+'/login'+'/'+this.redirectURL;
this.router.navigate(['/login?token=', this.redirectURL]);}
Here is the code ,it should move me to cognito page but its moving to login page in angular I am not sure where I am wrong
use +(plus) instead of ,(comma)
this.router.navigate(['/login?token='+this.redirectURL]);}
If you want to use query params, you can also adopt this approach.
this.router.navigate(['login'], { queryParams: { token: 20 } });
Most likely the reason behind the issue you are facing is that the comma-separated navigation turns to slash-separated one, e.g.
let redirectURL = '1234'
this.router.navigate(['/login?token=', redirectURL])
// this line above results to /login?token=/1234'
So in order to avoid that you should either use the solution that I suggest or the one mentioned by abhishek sahu, where the usage of + for concatenation is encouraged.

hash key "#" stripped from ussd code in "tel:" links on html pages

Good day all.
I have a simple link on a webpage, in where the user can call an USSD number:
*CLICK HERE AND CALL *111*2#
this is pretty straight forward; now, if I test it on desktop browser, it popups an alert asking me if I want to call (with skype) the number *111*2#, and thats ok.
with my Android phone (S Note 3), when testing this page, the phone (or something) stripped out the last "#" (only the last) from the link, resulting in a call to *111*2.
does anyone has experienced this? or knows how to prevent this?
Use URL encoding for special character in a URL. For example # equals %23
This worked for me:
<a ng-href="tel:%23 224">#224</a>
As you can see:
You need to use Uri.encode("#")
For example String number = "tel:*111*2" + Uri.encode("#");
Try this way,hope this will help you to solve your problem.
webview = (WebView) findViewById(R.id.webview);
webview.loadData("*CLICK HERE AND CALL *111*2#","text/html", "utf-16");
webview.setWebViewClient(new CustomWebViewClient());
private class CustomWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView wv, String url) {
if(url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse(url.replace("#","%23")));
startActivity(intent);
return true;
}
return false;
}
}
You can use below way to display the USSD in dialer
*CLICK HERE AND CALL *111*2#

Route values could not taking to the values

I want to route from one page to another page.
Candidatesvas- controller
Here I have code,
[Authorize, HttpPost,HandleErrorWithAjaxFilter]
public ActionResult Details(FormCollection collection)
{
Order order = _repository.GetOrder(LoggedInOrder.Id);
order.CreateDate = DateTime.Now;
order.Amount = 360;
order.Validity = 60;
_repository.Save();
}
when I click Index page,"any link", it saves in db and go to next details page.
Index.aspx:
<%:Html.actionlink("Details","Details","Candidatesvas")%>
like that...
Global.ascx:
routes.MapRouteLowercase(
"SaveVas",
"details/candidatesvas",
new { controller = "Candidatesvas", action = "Details" }
);
But when i click link, it shows "resource cannot be found". i changed many way. please help me. i can't find out the issue?
Your controller action is decorated with the [HttPost] attribute which means that this action is only accessible with the POST verb. Then you have shown some link on your page:
<%:Html.ActionLink("Details","Details","Candidatesvas")%>
But as you know a link sends GET request. If you want to be able to invoke this action you should either remove the [HttpPost] attribute from it or use an HTML <form> instead of a link.
try this
<%:Html.actionlink("Details","Details","Candidatesvas",null,null)%>
You can't use Html.actionlink for post method.
go for jquery
Or call form submit on click function.

Need a good reference for Google Generic Widget class

I want to see all the methods that I can use on a Generic Widget in Google Apps script, but I can't find anything unsubstantial.
There are two methods to see all public methods. The following code does this
function test() {
var app = UiApp.getActiveApplication();
// Method 1
var functions1 = Object.keys(app);
// Method 2
var functions2 = [];
for (var f in app) {
functions2.push(f);
}
}
The arrays functions1 and functions2 contain the same list of public functions of any object, also any generic widget.
I think this is the link you are looking for.
https://developers.google.com/apps-script/class_widget
Keep in mind that Apps script is built upon Google's Web Toolkit (used in the App engine service). You can look at that to have better understanding of how things work.
However, Apps Script is another service and as you will quickly see, everytime a widget gets implemented in Apps Script it has less property's and methods.
Lastly, you could always post a feature request on http://code.google.com/p/google-apps-script-issues/. If other people 'star' it enough, google might implement your request. Its a fairly honest system and they do prioritise their efforts based upon it.
Did you see this?:
http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/gwt/user/client/ui/Widget.html
I don't know if anyone will have some use, but if you want to save yourself some time here is the list of all the methods you can use on a Generic Widget in Google. Feel Free to fill in some info on any methods.
addKeyPressHandler,
setReadOnly,
setDialogTitle,
setStylePrimaryName,
addMouseDownHandler,
addBeforeSelectionHandler,
addSubmitCompleteHandler,
setModal, setGlassEnabled,
setAutoHideEnabled,
setWidgetPosition,
setPreviewingAllNativeEvents,
addSouth,
addKeyUpHandler,
setCellHorizontalAlignment,
addMouseMoveHandler,
setTabEnabled,
setWidgetLeftRight,
removeRow,
setLimit,
addStyleName,
getId,
showDatePicker,
setWidgetBottomHeight,
setDefaultValue,
setCommand,
setPopupPositionAndShow,
setWidgetLeftWidth,
setWidgetHorizontalPosition,
setStyleName,
setAlwaysShowScrollBars,
addMouseWheelHandler,
setHref,
addTab,
addSubmitHandler,
setItemSelected,
hideDatePicker,
remove,
addLoadHandler,
setItemText,
setVisibleRect,
addItem,
setLayoutData,
showDocsPicker,
clear,
insertRow,
setFormValue,
setUrl,
setWidgetVerticalPosition,
addEast,
setAction,
removeCell,
setCellHeight,
setId,
addWest,
addClickHandler,
setCharacterWidth,
setCaptionText,
setTabText,
setCellWidth,
addScrollHandler,
setScrollPosition,
setVisible,
setUserObject,
setVisibleLines,
setMaxLength,
setSelectionRange,
setMethod,
setSelectedIndex,
addMouseOverHandler,
addNorth,
setWordWrap,
removeItem,
addCloseHandler,
setStyleAttribute,
setCellPadding,
insertCell,
addChangeHandler,
setText,
setContentWidget,
setGlassStyleName,
resize,
setTarget,
setAccessKey,
addAutoHidePartner,
setTag,
setInitialView,
setSelectedItem,
addView,
setBorderWidth,
setSubMenu,
removeCells,
setCurrentMonth,
setTextAlignment,
setID,
addFocusHandler,
setVerticalAlignment,
setPixelSize,
setTabIndex,
selectTab,
setResource,
setWidgetTopHeight,
setFormat,
setStackText,
setVisibleLength,
addSeparator,
setTitle,
setVisibleItemCount,
setHeight,
setSpacing,
addMouseOutHandler,
toString,
addMouseUpHandler,
setPopupPosition,
setName,
setWidgetTopBottom,
setHorizontalScrollPosition,
setTargetHistoryToken,
setCellSpacing,
setPopupStyleName,
getTag,
addCell,
addStyleDependentName,
setDown,
addInitializeHandler,
setWidget,
setChecked,
add,
addKeyDownHandler,
setCursorPos,
getType,
setEnabled,
setState,
setWidth,
setUrlAndVisibleRect,
setFocus,
setDirection,
addErrorHandler,
addValueChangeHandler,
setSize,
addSelectionHandler,
addBlurHandler,
setMultiSelectEnabled,
setValue,
setHorizontalAlignment,
setEncoding,
setAutoSelectEnabled,
setAutoOpen,
setWidgetMinSize,
setCellVerticalAlignment,
setWidgetRightWidth,
setAnimationEnabled,
setSelected,
setHTML

call code behind functions with html controls

I have a simple function that I want to call in the code behind file name Move
and I was trying to see how this can be done and Im not using asp image button because not trying to use asp server side controls since they tend not to work well with ASP.net MVC..the way it is set up now it will look for a javascript function named Move but I want it to call a function named move in code behind of the same view
<img alt='move' id="Move" src="/Content/img/hPrevious.png" onclick="Move()"/>
protected void Move(){
}
//based on Search criteria update a new table
protected void Search(object sender EventArgs e)
{
for (int i = 0; i < data.Count; i++){
HtmlTableRow row = new HtmlTableRow();
HtmlTableCell CheckCell = new HtmlTableCell();
HtmlTableCell firstCell = new HtmlTableCell();
HtmlTableCell SecondCell = new HtmlTableCell();
CheckBox Check = new CheckBox();
Check.ID = data[i].ID;
CheckCell.Controls.Add(Check);
lbl1.Text = data[i].Date;
lbl2.Text = data[i].Name;
row.Cells.Add(CheckCell);
row.Cells.Add(firstCell);
row.Cells.Add(SecondCell);
Table.Rows.Add(row);
}
}
Scott Guthrie has a very good example on how to do this using routing rules.
This would give you the ability to have the user navigate to a URL in the format /Search/[Query]/[PageNumber] like http://site/Search/Hippopotamus/3 and it would show page 3 of the search results for hippopotamus.
Then in your view just make the next button point to "http://site/Search/Hippopotamus/4", no javascript required.
Of course if you wanted to use javascript you could do something like this:
function Move() {
var href = 'http://blah/Search/Hippopotamus/2';
var slashPos = href.lastIndexOf('/');
var page = parseInt(href.substring(slashPos + 1, href.length));
href = href.substring(0, slashPos + 1);
window.location = href + (++page);
}
But that is much more convoluted than just incrementing the page number parameter in the controller and setting the URL of the next button.
You cannot do postbacks or call anything in a view from JavaScript in an ASP.NET MVC application. Anything you want to call from JavaScript must be an action on a controller. It's hard to say more without having more details about what you're trying to do, but if you want to call some method "Move" in your web application from JavaScript, then "Move" must be an action on a controller.
Based on comments, I'm going to update this answer with a more complete description of how you might implement what I understand as the problem described in the question. However, there's quite a bit of information missing from the question so I'm speculating here. Hopefully, the general idea will get through, even if some of the details do not match TStamper's exact code.
Let's start with a Controller action:
public ActionResult ShowMyPage();
{
return View();
}
Now I know that I want to re-display this page, and do so using an argument passed from a JavaScript function in the page. Since I'll be displaying the same page again, I'll just alter the action to take an argument. String arguments are nullable, so I can continue to do the initial display of the page as I always have, without having to worry about specifying some kind of default value for the argument. Here's the new version:
public ActionResult ShowMyPage(string searchQuery);
{
ViewData["SearchQuery"] = searchQuery;
return View();
}
Now I need to call this page again in JavaScript. So I use the same URL I used to display the page initially, but I append a query string parameter with the table name:
http://example.com/MyControllerName/ShowMyPage?searchQuery=tableName
Finally, in my aspx I can call a code behind function, passing the searchQuery from the view data. Once again, I have strong reservations about using code behind in an MVC application, but this will work.
How to call a code-behind function in aspx:
<% Search(ViewData["searchQuery"]); %>
I've changed the arguments. Since you're not handling an event (with a few exceptions, such as Page_Load, there aren't any in MVC), the Search function doesn't need the signature of an event handler. But I did add the "tablename" argument so that you can pass that from the aspx.
Once more, I'll express my reservations about doing this in code behind. It strikes me that you are trying to use standard ASP.NET techniques inside of the MVC framework, when MVC works differently. I'd strongly suggest going through the MVC tutorials to see examples of more standard ways of doing this sort of thing.