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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/web_applications/web_app.h" | 32 #include "chrome/browser/web_applications/web_app.h" |
33 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
34 #include "chrome/common/extensions/extension_constants.h" | 34 #include "chrome/common/extensions/extension_constants.h" |
35 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 35 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
36 #include "chrome/common/extensions/manifest_url_handler.h" | 36 #include "chrome/common/extensions/manifest_url_handler.h" |
37 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
38 #include "content/public/browser/render_view_host.h" | 38 #include "content/public/browser/render_view_host.h" |
39 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
40 #include "content/public/browser/web_contents_view.h" | 40 #include "content/public/browser/web_contents_view.h" |
41 #include "content/public/common/renderer_preferences.h" | 41 #include "content/public/common/renderer_preferences.h" |
| 42 #include "extensions/browser/extension_registry.h" |
42 #include "extensions/common/constants.h" | 43 #include "extensions/common/constants.h" |
43 #include "extensions/common/extension.h" | 44 #include "extensions/common/extension.h" |
44 #include "grit/generated_resources.h" | 45 #include "grit/generated_resources.h" |
45 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
46 #include "ui/base/window_open_disposition.h" | 47 #include "ui/base/window_open_disposition.h" |
47 #include "ui/gfx/rect.h" | 48 #include "ui/gfx/rect.h" |
48 | 49 |
49 #if defined(OS_MACOSX) | 50 #if defined(OS_MACOSX) |
50 #include "chrome/browser/ui/browser_commands_mac.h" | 51 #include "chrome/browser/ui/browser_commands_mac.h" |
51 #endif | 52 #endif |
52 | 53 |
53 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
54 #include "win8/util/win8_util.h" | 55 #include "win8/util/win8_util.h" |
55 #endif | 56 #endif |
56 | 57 |
57 using content::WebContents; | 58 using content::WebContents; |
58 using extensions::Extension; | 59 using extensions::Extension; |
59 using extensions::ExtensionPrefs; | 60 using extensions::ExtensionPrefs; |
| 61 using extensions::ExtensionRegistry; |
60 | 62 |
61 namespace { | 63 namespace { |
62 | 64 |
63 // Attempts to launch a packaged app, prompting the user to enable it if | 65 // Attempts to launch a packaged app, prompting the user to enable it if |
64 // necessary. If a prompt is required it will be shown inside the AppList. | 66 // necessary. If a prompt is required it will be shown inside the AppList. |
65 // This class manages its own lifetime. | 67 // This class manages its own lifetime. |
66 class EnableViaAppListFlow : public ExtensionEnableFlowDelegate { | 68 class EnableViaAppListFlow : public ExtensionEnableFlowDelegate { |
67 public: | 69 public: |
68 EnableViaAppListFlow(ExtensionService* service, | 70 EnableViaAppListFlow(ExtensionService* service, |
69 Profile* profile, | 71 Profile* profile, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 std::string extension_id_; | 116 std::string extension_id_; |
115 base::Closure callback_; | 117 base::Closure callback_; |
116 scoped_ptr<ExtensionEnableFlow> flow_; | 118 scoped_ptr<ExtensionEnableFlow> flow_; |
117 | 119 |
118 DISALLOW_COPY_AND_ASSIGN(EnableViaAppListFlow); | 120 DISALLOW_COPY_AND_ASSIGN(EnableViaAppListFlow); |
119 }; | 121 }; |
120 | 122 |
121 const Extension* GetExtension(const AppLaunchParams& params) { | 123 const Extension* GetExtension(const AppLaunchParams& params) { |
122 if (params.extension_id.empty()) | 124 if (params.extension_id.empty()) |
123 return NULL; | 125 return NULL; |
124 ExtensionService* service = | 126 ExtensionRegistry* registry = ExtensionRegistry::Get(params.profile); |
125 extensions::ExtensionSystem::Get(params.profile)->extension_service(); | 127 return registry->GetExtensionById(params.extension_id, |
126 const Extension* extension = service->GetExtensionById( | 128 ExtensionRegistry::ENABLED | |
127 params.extension_id, | 129 ExtensionRegistry::DISABLED | |
128 ExtensionService::INCLUDE_ENABLED | ExtensionService::INCLUDE_DISABLED | | 130 ExtensionRegistry::TERMINATED); |
129 ExtensionService::INCLUDE_TERMINATED); | |
130 if (!extension) | |
131 extension = service->GetTerminatedExtension(params.extension_id); | |
132 return extension; | |
133 } | 131 } |
134 | 132 |
135 // Get the launch URL for a given extension, with optional override/fallback. | 133 // Get the launch URL for a given extension, with optional override/fallback. |
136 // |override_url|, if non-empty, will be preferred over the extension's | 134 // |override_url|, if non-empty, will be preferred over the extension's |
137 // launch url. | 135 // launch url. |
138 GURL UrlForExtension(const Extension* extension, | 136 GURL UrlForExtension(const Extension* extension, |
139 const GURL& override_url) { | 137 const GURL& override_url) { |
140 if (!extension) | 138 if (!extension) |
141 return override_url; | 139 return override_url; |
142 | 140 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when | 506 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when |
509 // the web app info is available, extensions::TabHelper notifies Browser via | 507 // the web app info is available, extensions::TabHelper notifies Browser via |
510 // OnDidGetApplicationInfo, which calls | 508 // OnDidGetApplicationInfo, which calls |
511 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as | 509 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as |
512 // pending web app action. | 510 // pending web app action. |
513 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( | 511 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( |
514 extensions::TabHelper::UPDATE_SHORTCUT); | 512 extensions::TabHelper::UPDATE_SHORTCUT); |
515 | 513 |
516 return tab; | 514 return tab; |
517 } | 515 } |
OLD | NEW |