summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-19 04:26:34 +0000
committerskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-19 04:26:34 +0000
commitaf87d31a117bb0a5a117f5565375738e4c490b52 (patch)
treef931612c621c26c6bb9b5384ada6f33bd23f7634 /chrome
parentcae190ddfaee956222146ab4d6858f3277583b5b (diff)
downloadchromium_src-af87d31a117bb0a5a117f5565375738e4c490b52.zip
chromium_src-af87d31a117bb0a5a117f5565375738e4c490b52.tar.gz
chromium_src-af87d31a117bb0a5a117f5565375738e4c490b52.tar.bz2
Adding the extension matching mechanism
BUG=169920 TEST=unittest Review URL: https://chromiumcodereview.appspot.com/11961002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177833 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc25
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_unittest.cc5
2 files changed, 18 insertions, 12 deletions
diff --git a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
index 4a885cd..3f26665 100644
--- a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
+++ b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
@@ -140,6 +140,9 @@ AppShortcutLauncherItemController::GetRunningApplications() {
refocus_pattern.Parse(refocus_url_.spec());
}
+ const Extension* extension =
+ launcher_controller()->GetExtensionForAppID(app_id());
+
for (BrowserList::const_reverse_iterator it =
BrowserList::begin_last_active();
it != BrowserList::end_last_active(); ++it) {
@@ -151,17 +154,17 @@ AppShortcutLauncherItemController::GetRunningApplications() {
content::WebContents* web_contents = tab_strip->GetWebContentsAt(
(index + active_index) % tab_strip->count());
const GURL tab_url = web_contents->GetURL();
- // The following cases are a successful application identification:
- // a.) There is a refocus pattern given and it matches.
- // or
- // b.) The tab was launched as an app of the searched type AND
- // either there is no refocus pattern or the url matches it.
- // This is needed since a V1 applications can change the URL over
- // time, and might therefore loose it's "app" status.
- if (refocus_pattern.MatchesURL(tab_url) &&
- (!refocus_pattern.match_all_urls() ||
- launcher_controller()->GetPerAppInterface()->
- IsWebContentHandledByApplication(web_contents, app_id())))
+ // There are three ways to identify the association of a URL with this
+ // extension:
+ // - The refocus pattern is matched (needed for apps like drive).
+ // - The extension's origin + extent gets matched.
+ // - The launcher controller knows that the tab got created for this app.
+ if ((!refocus_pattern.match_all_urls() &&
+ refocus_pattern.MatchesURL(tab_url)) ||
+ (extension->OverlapsWithOrigin(tab_url) &&
+ extension->web_extent().MatchesURL(tab_url)) ||
+ launcher_controller()->GetPerAppInterface()->
+ IsWebContentHandledByApplication(web_contents, app_id()))
items.push_back(web_contents);
}
}
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_unittest.cc
index e79136e..a9850ba 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_unittest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_unittest.cc
@@ -343,7 +343,10 @@ TEST_F(ChromeLauncherControllerPerAppTest, BrowserMenuGeneration) {
chrome::CloseTab(browser2.get());
}
-// Check that V1 apps are correctly reflected in the launcher menu.
+// Check that V1 apps are correctly reflected in the launcher menu using the
+// refocus logic.
+// Note that the extension matching logic is tested by the extension system
+// and does not need a separate test here.
TEST_F(ChromeLauncherControllerPerAppTest, V1AppMenuGeneration) {
EXPECT_EQ(1U, BrowserList::size());
EXPECT_EQ(0, browser()->tab_strip_model()->count());