| 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/tab_helper.h" | 5 #include "chrome/browser/extensions/tab_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/app_notify_channel_ui.h" | 7 #include "chrome/browser/extensions/app_notify_channel_ui.h" |
| 8 #include "chrome/browser/extensions/crx_installer.h" | 8 #include "chrome/browser/extensions/crx_installer.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_tab_util.h" | 10 #include "chrome/browser/extensions/extension_tab_util.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 scoped_refptr<CrxInstaller> installer( | 252 scoped_refptr<CrxInstaller> installer( |
| 253 CrxInstaller::Create(extension_service, prompt)); | 253 CrxInstaller::Create(extension_service, prompt)); |
| 254 installer->InstallWebApp(info); | 254 installer->InstallWebApp(info); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void TabHelper::OnInlineWebstoreInstall( | 257 void TabHelper::OnInlineWebstoreInstall( |
| 258 int install_id, | 258 int install_id, |
| 259 int return_route_id, | 259 int return_route_id, |
| 260 const std::string& webstore_item_id, | 260 const std::string& webstore_item_id, |
| 261 const GURL& requestor_url) { | 261 const GURL& requestor_url) { |
| 262 WebstoreInlineInstaller::Callback callback = |
| 263 base::Bind(&TabHelper::OnInlineInstallComplete, base::Unretained(this), |
| 264 install_id, return_route_id); |
| 262 scoped_refptr<WebstoreInlineInstaller> installer(new WebstoreInlineInstaller( | 265 scoped_refptr<WebstoreInlineInstaller> installer(new WebstoreInlineInstaller( |
| 263 web_contents(), | 266 web_contents(), |
| 264 install_id, | |
| 265 return_route_id, | |
| 266 webstore_item_id, | 267 webstore_item_id, |
| 268 WebstoreInlineInstaller::REQUIRE_VERIFIED_SITE, |
| 267 requestor_url, | 269 requestor_url, |
| 268 this)); | 270 callback)); |
| 269 installer->BeginInstall(); | 271 installer->BeginInstall(); |
| 270 } | 272 } |
| 271 | 273 |
| 272 void TabHelper::OnGetAppNotifyChannel(const GURL& requestor_url, | 274 void TabHelper::OnGetAppNotifyChannel(const GURL& requestor_url, |
| 273 const std::string& client_id, | 275 const std::string& client_id, |
| 274 int return_route_id, | 276 int return_route_id, |
| 275 int callback_id) { | 277 int callback_id) { |
| 276 // Check for permission first. | 278 // Check for permission first. |
| 277 Profile* profile = | 279 Profile* profile = |
| 278 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 280 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 if (!image.IsEmpty()) { | 410 if (!image.IsEmpty()) { |
| 409 extension_app_icon_ = *image.ToSkBitmap(); | 411 extension_app_icon_ = *image.ToSkBitmap(); |
| 410 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); | 412 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); |
| 411 } | 413 } |
| 412 } | 414 } |
| 413 | 415 |
| 414 WindowController* TabHelper::GetExtensionWindowController() const { | 416 WindowController* TabHelper::GetExtensionWindowController() const { |
| 415 return ExtensionTabUtil::GetWindowControllerOfTab(web_contents()); | 417 return ExtensionTabUtil::GetWindowControllerOfTab(web_contents()); |
| 416 } | 418 } |
| 417 | 419 |
| 418 void TabHelper::OnInlineInstallSuccess(int install_id, int return_route_id) { | 420 void TabHelper::OnInlineInstallComplete(int install_id, |
| 419 Send(new ExtensionMsg_InlineWebstoreInstallResponse( | 421 int return_route_id, |
| 420 return_route_id, install_id, true, "")); | 422 bool success, |
| 421 } | 423 const std::string& error) { |
| 422 | 424 if (success) { |
| 423 void TabHelper::OnInlineInstallFailure(int install_id, | 425 Send(new ExtensionMsg_InlineWebstoreInstallResponse( |
| 424 int return_route_id, | 426 return_route_id, install_id, true, "")); |
| 425 const std::string& error) { | 427 } else { |
| 426 Send(new ExtensionMsg_InlineWebstoreInstallResponse( | 428 Send(new ExtensionMsg_InlineWebstoreInstallResponse( |
| 427 return_route_id, install_id, false, error)); | 429 return_route_id, install_id, false, error)); |
| 430 } |
| 428 } | 431 } |
| 429 | 432 |
| 430 WebContents* TabHelper::GetAssociatedWebContents() const { | 433 WebContents* TabHelper::GetAssociatedWebContents() const { |
| 431 return web_contents(); | 434 return web_contents(); |
| 432 } | 435 } |
| 433 | 436 |
| 434 void TabHelper::GetApplicationInfo(int32 page_id) { | 437 void TabHelper::GetApplicationInfo(int32 page_id) { |
| 435 Send(new ExtensionMsg_GetApplicationInfo(routing_id(), page_id)); | 438 Send(new ExtensionMsg_GetApplicationInfo(routing_id(), page_id)); |
| 436 } | 439 } |
| 437 | 440 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 450 // malware site etc). When this happens, we abort the shortcut update. | 453 // malware site etc). When this happens, we abort the shortcut update. |
| 451 NavigationEntry* entry = controller.GetLastCommittedEntry(); | 454 NavigationEntry* entry = controller.GetLastCommittedEntry(); |
| 452 if (entry) | 455 if (entry) |
| 453 GetApplicationInfo(entry->GetPageID()); | 456 GetApplicationInfo(entry->GetPageID()); |
| 454 else | 457 else |
| 455 pending_web_app_action_ = NONE; | 458 pending_web_app_action_ = NONE; |
| 456 } | 459 } |
| 457 } | 460 } |
| 458 | 461 |
| 459 } // namespace extensions | 462 } // namespace extensions |
| OLD | NEW |