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/macros.h" | 10 #include "base/macros.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 gfx::Rect initial_bounds; | 187 gfx::Rect initial_bounds; |
188 if (!params.override_bounds.IsEmpty()) { | 188 if (!params.override_bounds.IsEmpty()) { |
189 initial_bounds = params.override_bounds; | 189 initial_bounds = params.override_bounds; |
190 } else if (extension) { | 190 } else if (extension) { |
191 initial_bounds.set_width( | 191 initial_bounds.set_width( |
192 extensions::AppLaunchInfo::GetLaunchWidth(extension)); | 192 extensions::AppLaunchInfo::GetLaunchWidth(extension)); |
193 initial_bounds.set_height( | 193 initial_bounds.set_height( |
194 extensions::AppLaunchInfo::GetLaunchHeight(extension)); | 194 extensions::AppLaunchInfo::GetLaunchHeight(extension)); |
195 } | 195 } |
196 | 196 |
| 197 // TODO(erg): AppLaunchParams should pass through the user_gesture from the |
| 198 // extension system here. |
197 Browser::CreateParams browser_params(Browser::CreateParams::CreateForApp( | 199 Browser::CreateParams browser_params(Browser::CreateParams::CreateForApp( |
198 app_name, true /* trusted_source */, initial_bounds, profile)); | 200 app_name, true /* trusted_source */, initial_bounds, profile, true)); |
199 | 201 |
200 browser_params.initial_show_state = DetermineWindowShowState(profile, | 202 browser_params.initial_show_state = DetermineWindowShowState(profile, |
201 params.container, | 203 params.container, |
202 extension); | 204 extension); |
203 | 205 |
204 Browser* browser = new Browser(browser_params); | 206 Browser* browser = new Browser(browser_params); |
205 ui::PageTransition transition = | 207 ui::PageTransition transition = |
206 (extension ? ui::PAGE_TRANSITION_AUTO_BOOKMARK | 208 (extension ? ui::PAGE_TRANSITION_AUTO_BOOKMARK |
207 : ui::PAGE_TRANSITION_AUTO_TOPLEVEL); | 209 : ui::PAGE_TRANSITION_AUTO_TOPLEVEL); |
208 | 210 |
(...skipping 14 matching lines...) Expand all Loading... |
223 const GURL& url) { | 225 const GURL& url) { |
224 const Extension* extension = GetExtension(launch_params); | 226 const Extension* extension = GetExtension(launch_params); |
225 CHECK(extension); | 227 CHECK(extension); |
226 Profile* const profile = launch_params.profile; | 228 Profile* const profile = launch_params.profile; |
227 WindowOpenDisposition disposition = launch_params.disposition; | 229 WindowOpenDisposition disposition = launch_params.disposition; |
228 | 230 |
229 Browser* browser = chrome::FindTabbedBrowser(profile, false); | 231 Browser* browser = chrome::FindTabbedBrowser(profile, false); |
230 WebContents* contents = NULL; | 232 WebContents* contents = NULL; |
231 if (!browser) { | 233 if (!browser) { |
232 // No browser for this profile, need to open a new one. | 234 // No browser for this profile, need to open a new one. |
233 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile)); | 235 // |
| 236 // TODO(erg): AppLaunchParams should pass user_gesture from the extension |
| 237 // system to here. |
| 238 browser = |
| 239 new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile, true)); |
234 browser->window()->Show(); | 240 browser->window()->Show(); |
235 // There's no current tab in this browser window, so add a new one. | 241 // There's no current tab in this browser window, so add a new one. |
236 disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; | 242 disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
237 } else { | 243 } else { |
238 // For existing browser, ensure its window is shown and activated. | 244 // For existing browser, ensure its window is shown and activated. |
239 browser->window()->Show(); | 245 browser->window()->Show(); |
240 browser->window()->Activate(); | 246 browser->window()->Activate(); |
241 } | 247 } |
242 | 248 |
243 extensions::LaunchType launch_type = | 249 extensions::LaunchType launch_type = |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); | 415 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); |
410 | 416 |
411 return tab; | 417 return tab; |
412 } | 418 } |
413 | 419 |
414 bool CanLaunchViaEvent(const extensions::Extension* extension) { | 420 bool CanLaunchViaEvent(const extensions::Extension* extension) { |
415 const extensions::Feature* feature = | 421 const extensions::Feature* feature = |
416 extensions::FeatureProvider::GetAPIFeature("app.runtime"); | 422 extensions::FeatureProvider::GetAPIFeature("app.runtime"); |
417 return feature && feature->IsAvailableToExtension(extension).is_available(); | 423 return feature && feature->IsAvailableToExtension(extension).is_available(); |
418 } | 424 } |
OLD | NEW |