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/extensions/extension_tab_helper.h" | 5 #include "chrome/browser/extensions/extension_tab_helper.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/extensions/webstore_inline_installer.h" | 8 #include "chrome/browser/extensions/webstore_inline_installer.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/sessions/restore_tab_helper.h" | 10 #include "chrome/browser/sessions/restore_tab_helper.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 bool handled = true; | 130 bool handled = true; |
131 IPC_BEGIN_MESSAGE_MAP(ExtensionTabHelper, message) | 131 IPC_BEGIN_MESSAGE_MAP(ExtensionTabHelper, message) |
132 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DidGetApplicationInfo, | 132 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DidGetApplicationInfo, |
133 OnDidGetApplicationInfo) | 133 OnDidGetApplicationInfo) |
134 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InstallApplication, | 134 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InstallApplication, |
135 OnInstallApplication) | 135 OnInstallApplication) |
136 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InlineWebstoreInstall, | 136 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InlineWebstoreInstall, |
137 OnInlineWebstoreInstall) | 137 OnInlineWebstoreInstall) |
138 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppNotifyChannel, | 138 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppNotifyChannel, |
139 OnGetAppNotifyChannel) | 139 OnGetAppNotifyChannel) |
| 140 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppInstallState, |
| 141 OnGetAppInstallState); |
140 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | 142 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
141 IPC_MESSAGE_UNHANDLED(handled = false) | 143 IPC_MESSAGE_UNHANDLED(handled = false) |
142 IPC_END_MESSAGE_MAP() | 144 IPC_END_MESSAGE_MAP() |
143 return handled; | 145 return handled; |
144 } | 146 } |
145 | 147 |
146 void ExtensionTabHelper::OnDidGetApplicationInfo( | 148 void ExtensionTabHelper::OnDidGetApplicationInfo( |
147 int32 page_id, const WebApplicationInfo& info) { | 149 int32 page_id, const WebApplicationInfo& info) { |
148 web_app_info_ = info; | 150 web_app_info_ = info; |
149 | 151 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 client_id, | 218 client_id, |
217 requestor_url, | 219 requestor_url, |
218 return_route_id, | 220 return_route_id, |
219 callback_id, | 221 callback_id, |
220 ui, | 222 ui, |
221 this->AsWeakPtr())); | 223 this->AsWeakPtr())); |
222 channel_setup->Start(); | 224 channel_setup->Start(); |
223 // We'll get called back in AppNotifyChannelSetupComplete. | 225 // We'll get called back in AppNotifyChannelSetupComplete. |
224 } | 226 } |
225 | 227 |
| 228 void ExtensionTabHelper::OnGetAppInstallState(const GURL& requestor_url, |
| 229 int return_route_id, |
| 230 int callback_id) { |
| 231 Profile* profile = |
| 232 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 233 ExtensionService* extension_service = profile->GetExtensionService(); |
| 234 const ExtensionSet* extensions = extension_service->extensions(); |
| 235 const ExtensionSet* disabled = extension_service->disabled_extensions(); |
| 236 |
| 237 ExtensionURLInfo url(requestor_url); |
| 238 std::string state; |
| 239 if (extensions->GetHostedAppByURL(url)) |
| 240 state = extension_misc::kAppStateInstalled; |
| 241 else if (disabled->GetHostedAppByURL(url)) |
| 242 state = extension_misc::kAppStateDisabled; |
| 243 else |
| 244 state = extension_misc::kAppStateNotInstalled; |
| 245 |
| 246 Send(new ExtensionMsg_GetAppInstallStateResponse( |
| 247 return_route_id, state, callback_id)); |
| 248 } |
| 249 |
226 void ExtensionTabHelper::AppNotifyChannelSetupComplete( | 250 void ExtensionTabHelper::AppNotifyChannelSetupComplete( |
227 const std::string& channel_id, | 251 const std::string& channel_id, |
228 const std::string& error, | 252 const std::string& error, |
229 const AppNotifyChannelSetup* setup) { | 253 const AppNotifyChannelSetup* setup) { |
230 CHECK(setup); | 254 CHECK(setup); |
231 | 255 |
232 // If the setup was successful, record that fact in ExtensionService. | 256 // If the setup was successful, record that fact in ExtensionService. |
233 if (!channel_id.empty() && error.empty()) { | 257 if (!channel_id.empty() && error.empty()) { |
234 Profile* profile = | 258 Profile* profile = |
235 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 259 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 void ExtensionTabHelper::OnInlineInstallFailure(int install_id, | 340 void ExtensionTabHelper::OnInlineInstallFailure(int install_id, |
317 int return_route_id, | 341 int return_route_id, |
318 const std::string& error) { | 342 const std::string& error) { |
319 Send(new ExtensionMsg_InlineWebstoreInstallResponse( | 343 Send(new ExtensionMsg_InlineWebstoreInstallResponse( |
320 return_route_id, install_id, false, error)); | 344 return_route_id, install_id, false, error)); |
321 } | 345 } |
322 | 346 |
323 WebContents* ExtensionTabHelper::GetAssociatedWebContents() const { | 347 WebContents* ExtensionTabHelper::GetAssociatedWebContents() const { |
324 return web_contents(); | 348 return web_contents(); |
325 } | 349 } |
OLD | NEW |