| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" | 5 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" |
| 6 | 6 |
| 7 #include "ash/wm/window_util.h" | 7 #include "ash/wm/window_util.h" |
| 8 #include "chrome/browser/favicon/favicon_tab_helper.h" | 8 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 9 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
| 10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" | 10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 void AppShortcutLauncherItemController::Activate() { | 81 void AppShortcutLauncherItemController::Activate() { |
| 82 content::WebContents* content = GetLRUApplication(); | 82 content::WebContents* content = GetLRUApplication(); |
| 83 if (!content) { | 83 if (!content) { |
| 84 Launch(ui::EF_NONE); | 84 Launch(ui::EF_NONE); |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 Browser* browser = chrome::FindBrowserWithWebContents(content); | 87 Browser* browser = chrome::FindBrowserWithWebContents(content); |
| 88 TabStripModel* tab_strip = browser->tab_strip_model(); | 88 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 89 int index = tab_strip->GetIndexOfWebContents(content); | 89 int index = tab_strip->GetIndexOfWebContents(content); |
| 90 DCHECK_NE(TabStripModel::kNoTab, index); | 90 DCHECK_NE(TabStripModel::kNoTab, index); |
| 91 tab_strip->ActivateTabAt(index, false); | 91 |
| 92 browser->window()->Show(); | 92 int old_index = tab_strip->active_index(); |
| 93 ash::wm::ActivateWindow(browser->window()->GetNativeWindow()); | 93 if (index != old_index) |
| 94 tab_strip->ActivateTabAt(index, false); |
| 95 app_controller_->ActivateWindowOrMinimizeIfActive( |
| 96 browser->window(), |
| 97 index == old_index && GetRunningApplications().size() == 1); |
| 94 } | 98 } |
| 95 | 99 |
| 96 void AppShortcutLauncherItemController::Close() { | 100 void AppShortcutLauncherItemController::Close() { |
| 97 // Close all running 'programs' of this type. | 101 // Close all running 'programs' of this type. |
| 98 std::vector<content::WebContents*> content = | 102 std::vector<content::WebContents*> content = |
| 99 app_controller_->GetV1ApplicationsFromAppId(app_id()); | 103 app_controller_->GetV1ApplicationsFromAppId(app_id()); |
| 100 for (size_t i = 0; i < content.size(); i++) { | 104 for (size_t i = 0; i < content.size(); i++) { |
| 101 Browser* browser = chrome::FindBrowserWithWebContents(content[i]); | 105 Browser* browser = chrome::FindBrowserWithWebContents(content[i]); |
| 102 if (!browser) | 106 if (!browser) |
| 103 continue; | 107 continue; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 // - The refocus pattern is matched (needed for apps like drive). | 225 // - The refocus pattern is matched (needed for apps like drive). |
| 222 // - The extension's origin + extent gets matched. | 226 // - The extension's origin + extent gets matched. |
| 223 // - The launcher controller knows that the tab got created for this app. | 227 // - The launcher controller knows that the tab got created for this app. |
| 224 return ((!refocus_pattern.match_all_urls() && | 228 return ((!refocus_pattern.match_all_urls() && |
| 225 refocus_pattern.MatchesURL(tab_url)) || | 229 refocus_pattern.MatchesURL(tab_url)) || |
| 226 (extension->OverlapsWithOrigin(tab_url) && | 230 (extension->OverlapsWithOrigin(tab_url) && |
| 227 extension->web_extent().MatchesURL(tab_url)) || | 231 extension->web_extent().MatchesURL(tab_url)) || |
| 228 launcher_controller()->GetPerAppInterface()-> | 232 launcher_controller()->GetPerAppInterface()-> |
| 229 IsWebContentHandledByApplication(web_contents, app_id())); | 233 IsWebContentHandledByApplication(web_contents, app_id())); |
| 230 } | 234 } |
| OLD | NEW |