mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 720932 - Clean up default search engine code [r=wesj]
This commit is contained in:
parent
3eceafc02c
commit
eabddd5e28
@ -124,7 +124,7 @@ public class AwesomeBar extends Activity implements GeckoEventListener {
|
||||
mAwesomeTabs = (AwesomeBarTabs) findViewById(R.id.awesomebar_tabs);
|
||||
mAwesomeTabs.setOnUrlOpenListener(new AwesomeBarTabs.OnUrlOpenListener() {
|
||||
public void onUrlOpen(String url) {
|
||||
submitAndFinish(url);
|
||||
openUrlAndFinish(url);
|
||||
}
|
||||
|
||||
public void onSearch(String engine) {
|
||||
@ -134,7 +134,7 @@ public class AwesomeBar extends Activity implements GeckoEventListener {
|
||||
|
||||
mGoButton.setOnClickListener(new Button.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
submitAndFinish(mText.getText().toString());
|
||||
openUrlAndFinish(mText.getText().toString());
|
||||
}
|
||||
});
|
||||
|
||||
@ -168,7 +168,7 @@ public class AwesomeBar extends Activity implements GeckoEventListener {
|
||||
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
submitAndFinish(mText.getText().toString());
|
||||
openUrlAndFinish(mText.getText().toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ public class AwesomeBar extends Activity implements GeckoEventListener {
|
||||
if (event.getAction() != KeyEvent.ACTION_DOWN)
|
||||
return true;
|
||||
|
||||
submitAndFinish(mText.getText().toString());
|
||||
openUrlAndFinish(mText.getText().toString());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -306,13 +306,6 @@ public class AwesomeBar extends Activity implements GeckoEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void submitAndFinish(String url) {
|
||||
if (isSearchUrl(url))
|
||||
openSearchAndFinish(url, "__default__");
|
||||
else
|
||||
openUrlAndFinish(url);
|
||||
}
|
||||
|
||||
private void cancelAndFinish() {
|
||||
setResult(Activity.RESULT_CANCELED);
|
||||
finish();
|
||||
|
@ -51,9 +51,6 @@ XPCOMUtils.defineLazyGetter(this, "PluralForm", function() {
|
||||
return PluralForm;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "URIFixup",
|
||||
"@mozilla.org/docshell/urifixup;1", "nsIURIFixup");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "Haptic",
|
||||
"@mozilla.org/widget/hapticfeedback;1", "nsIHapticFeedback");
|
||||
|
||||
@ -792,19 +789,12 @@ var BrowserApp = {
|
||||
});
|
||||
},
|
||||
|
||||
getSearchOrFixupURI: function(aParams) {
|
||||
getSearchOrURI: function getSearchOrURI(aParams) {
|
||||
let uri;
|
||||
if (aParams.engine) {
|
||||
let engine;
|
||||
// If the default engine was requested, we just pass the URL through
|
||||
// and let the third-party fixup send it to the default search.
|
||||
if (aParams.engine != "__default__")
|
||||
engine = Services.search.getEngineByName(aParams.engine);
|
||||
|
||||
let engine = Services.search.getEngineByName(aParams.engine);
|
||||
if (engine)
|
||||
uri = engine.getSubmission(aParams.url).uri;
|
||||
} else {
|
||||
uri = URIFixup.createFixupURI(aParams.url, Ci.nsIURIFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP);
|
||||
}
|
||||
return uri ? uri.spec : aParams.url;
|
||||
},
|
||||
@ -921,7 +911,7 @@ var BrowserApp = {
|
||||
| Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP
|
||||
};
|
||||
|
||||
let url = this.getSearchOrFixupURI(data);
|
||||
let url = this.getSearchOrURI(data);
|
||||
|
||||
// Don't show progress throbber for about:home
|
||||
if (url == "about:home")
|
||||
|
Loading…
Reference in New Issue
Block a user