summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser.cc
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 18:11:08 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 18:11:08 +0000
commit1b613008b9931d51c4d9a597e0340425ef3e8234 (patch)
tree267cc4c9b50762ed811815c536f3dd078fd1a7fb /chrome/browser/browser.cc
parent6acf9e0de851fc2089a2f80b8314f23c980cde21 (diff)
downloadchromium_src-1b613008b9931d51c4d9a597e0340425ef3e8234.zip
chromium_src-1b613008b9931d51c4d9a597e0340425ef3e8234.tar.gz
chromium_src-1b613008b9931d51c4d9a597e0340425ef3e8234.tar.bz2
Interpret typed url into an apps extent from the NTP omnibox as launch event
Note that this doesn't cover the case of a typed url that redirects into an app's extent. BUG=44911 TEST=NONE Review URL: http://codereview.chromium.org/2777002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49556 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser.cc')
-rw-r--r--chrome/browser/browser.cc34
1 files changed, 25 insertions, 9 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 82ddea5..db65551 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1194,16 +1194,32 @@ void Browser::OpenCurrentURL() {
WindowOpenDisposition open_disposition =
location_bar->GetWindowOpenDisposition();
GURL url(WideToUTF8(location_bar->GetInputString()));
- if (open_disposition == CURRENT_TAB &&
- tabstrip_model()->IsTabPinned(selected_index())) {
- // To make pinned tabs feel more permanent any requests from the omnibox
- // to open a url in the current tab with a host different from the current
- // host of the pinned tab result in creating a new tab. We allow changes to
- // the path so that the user can trigger reloads or fix up parts of the url
- // without spawning a new tab.
+
+ if (open_disposition == CURRENT_TAB) {
TabContents* selected_contents = GetSelectedTabContents();
- if (!selected_contents || url.host() != selected_contents->GetURL().host())
- open_disposition = NEW_FOREGROUND_TAB;
+ Extension* extension = profile()->GetExtensionsService()
+ ->GetExtensionByWebExtent(url);
+
+ if (extension && selected_contents &&
+ selected_contents->GetURL().GetOrigin() ==
+ GURL(chrome::kChromeUINewTabURL).GetOrigin()) {
+ // If the |url| is within an app's web extent and it was typed into the
+ // omnibox of an NTP page, interpret as an app launch and close the NTP
+ // tab.
+ Browser::OpenApplication(profile(), extension,
+ extension->launch_container());
+ CloseTabContents(selected_contents);
+ return;
+ } else if (tabstrip_model()->IsTabPinned(selected_index())) {
+ // To make pinned tabs feel more permanent any requests from the omnibox
+ // to open a url in the current tab with a host different from the current
+ // host of the pinned tab result in creating a new tab. We allow changes
+ // to the path so that the user can trigger reloads or fix up parts of the
+ // url without spawning a new tab.
+ if (!selected_contents ||
+ url.host() != selected_contents->GetURL().host())
+ open_disposition = NEW_FOREGROUND_TAB;
+ }
}
OpenURLAtIndex(NULL, url, GURL(),
open_disposition,