| 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/extensions/application_launch.h" | 5 #include "chrome/browser/ui/extensions/application_launch.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "apps/launcher.h" | 9 #include "apps/launcher.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 // No browser for this profile, need to open a new one. | 232 // No browser for this profile, need to open a new one. |
| 233 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, | 233 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, |
| 234 profile, | 234 profile, |
| 235 launch_params.desktop_type)); | 235 launch_params.desktop_type)); |
| 236 browser->window()->Show(); | 236 browser->window()->Show(); |
| 237 // There's no current tab in this browser window, so add a new one. | 237 // There's no current tab in this browser window, so add a new one. |
| 238 disposition = NEW_FOREGROUND_TAB; | 238 disposition = NEW_FOREGROUND_TAB; |
| 239 } else { | 239 } else { |
| 240 // For existing browser, ensure its window is shown and activated. | 240 // For existing browser, ensure its window is shown and activated. |
| 241 browser->window()->Show(); | 241 browser->window()->Show(); |
| 242 browser->window()->Activate(); | 242 // TODO(johnme): Can we sometimes be certain this was for a user gesture? |
| 243 browser->window()->Activate(false /* user_gesture */); |
| 243 } | 244 } |
| 244 | 245 |
| 245 extensions::LaunchType launch_type = | 246 extensions::LaunchType launch_type = |
| 246 extensions::GetLaunchType(ExtensionPrefs::Get(profile), extension); | 247 extensions::GetLaunchType(ExtensionPrefs::Get(profile), extension); |
| 247 UMA_HISTOGRAM_ENUMERATION("Extensions.AppTabLaunchType", launch_type, 100); | 248 UMA_HISTOGRAM_ENUMERATION("Extensions.AppTabLaunchType", launch_type, 100); |
| 248 | 249 |
| 249 int add_type = TabStripModel::ADD_ACTIVE; | 250 int add_type = TabStripModel::ADD_ACTIVE; |
| 250 if (launch_type == extensions::LAUNCH_TYPE_PINNED) | 251 if (launch_type == extensions::LAUNCH_TYPE_PINNED) |
| 251 add_type |= TabStripModel::ADD_PINNED; | 252 add_type |= TabStripModel::ADD_PINNED; |
| 252 | 253 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); | 407 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); |
| 407 | 408 |
| 408 return tab; | 409 return tab; |
| 409 } | 410 } |
| 410 | 411 |
| 411 bool CanLaunchViaEvent(const extensions::Extension* extension) { | 412 bool CanLaunchViaEvent(const extensions::Extension* extension) { |
| 412 const extensions::Feature* feature = | 413 const extensions::Feature* feature = |
| 413 extensions::FeatureProvider::GetAPIFeature("app.runtime"); | 414 extensions::FeatureProvider::GetAPIFeature("app.runtime"); |
| 414 return feature->IsAvailableToExtension(extension).is_available(); | 415 return feature->IsAvailableToExtension(extension).is_available(); |
| 415 } | 416 } |
| OLD | NEW |