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/views/ash/extension_utils.h" | 5 #include "chrome/browser/ui/views/ash/extension_utils.h" |
6 | 6 |
7 #include "chrome/browser/event_disposition.h" | 7 #include "chrome/browser/event_disposition.h" |
8 #include "chrome/browser/extensions/extension_prefs.h" | 8 #include "chrome/browser/extensions/extension_prefs.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/extensions/application_launch.h" | 11 #include "chrome/browser/ui/extensions/application_launch.h" |
12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 | 14 |
15 namespace extension_utils { | 15 namespace extension_utils { |
16 | 16 |
17 // Opens an extension. |event_flags| holds the flags of the event | 17 // Opens an extension. |event_flags| holds the flags of the event |
18 // which invokes this extension. | 18 // which invokes this extension. |
19 void OpenExtension(Profile* profile, | 19 void OpenExtension(Profile* profile, |
20 const extensions::Extension* extension, | 20 const extensions::Extension* extension, |
21 int event_flags) { | 21 int event_flags) { |
22 DCHECK(profile); | 22 DCHECK(profile); |
23 DCHECK(extension); | 23 DCHECK(extension); |
24 | 24 |
25 WindowOpenDisposition disposition = | 25 WindowOpenDisposition disposition = |
26 chrome::DispositionFromEventFlags(event_flags); | 26 chrome::DispositionFromEventFlags(event_flags); |
27 extension_misc::LaunchContainer container; | |
27 | 28 |
28 GURL url; | 29 GURL url; |
29 if (extension->id() == extension_misc::kWebStoreAppId) | 30 if (extension->id() == extension_misc::kWebStoreAppId) |
30 url = extension->GetFullLaunchURL(); | 31 url = extension->GetFullLaunchURL(); |
31 | 32 |
32 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) { | 33 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) { |
33 // Opens in a tab. | 34 container = extension_misc::LAUNCH_TAB; |
34 application_launch::OpenApplication( | |
35 profile, extension, extension_misc::LAUNCH_TAB, url, disposition, NULL); | |
36 } else if (disposition == NEW_WINDOW) { | 35 } else if (disposition == NEW_WINDOW) { |
37 // Force a new window open. | 36 container = extension_misc::LAUNCH_WINDOW; |
38 application_launch::OpenApplication( | |
39 profile, extension, extension_misc::LAUNCH_WINDOW, url, | |
40 disposition, NULL); | |
41 } else { | 37 } else { |
42 // Look at preference to find the right launch container. If no preference | 38 // Look at preference to find the right launch container. If no preference |
43 // is set, launch as a regular tab. | 39 // is set, launch as a regular tab. |
44 extension_misc::LaunchContainer launch_container = | 40 container = |
45 profile->GetExtensionService()->extension_prefs()->GetLaunchContainer( | 41 profile->GetExtensionService()->extension_prefs()->GetLaunchContainer( |
46 extension, ExtensionPrefs::LAUNCH_DEFAULT); | 42 extension, ExtensionPrefs::LAUNCH_DEFAULT); |
43 disposition = NEW_FOREGROUND_TAB; | |
44 } | |
47 | 45 |
48 application_launch::OpenApplication( | 46 application_launch::LaunchParams params(profile, extension, container, |
49 profile, extension, launch_container, GURL(url), | 47 disposition); |
50 NEW_FOREGROUND_TAB, NULL); | 48 params.override_url = url; |
Mihai Parparita -not on Chrome
2012/07/11 00:38:36
Is this actually needed? The only possible value f
benwells
2012/07/12 04:21:02
Wow yeah, deleted!
| |
51 } | 49 application_launch::OpenApplication(params); |
52 } | 50 } |
53 | 51 |
54 } // namespace extension_utils | 52 } // namespace extension_utils |
OLD | NEW |