Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(781)

Side by Side Diff: chrome/browser/extensions/tab_helper.cc

Issue 175263003: Add chrome.webstore API methods to allow sites to see progress of installation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Julien's II Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/extensions/activity_log/activity_log.h" 12 #include "chrome/browser/extensions/activity_log/activity_log.h"
13 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" 13 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h"
14 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist ry.h" 14 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist ry.h"
15 #include "chrome/browser/extensions/api/webstore/webstore_api.h"
15 #include "chrome/browser/extensions/crx_installer.h" 16 #include "chrome/browser/extensions/crx_installer.h"
16 #include "chrome/browser/extensions/error_console/error_console.h" 17 #include "chrome/browser/extensions/error_console/error_console.h"
17 #include "chrome/browser/extensions/extension_action.h" 18 #include "chrome/browser/extensions/extension_action.h"
18 #include "chrome/browser/extensions/extension_action_manager.h" 19 #include "chrome/browser/extensions/extension_action_manager.h"
19 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/extension_tab_util.h" 21 #include "chrome/browser/extensions/extension_tab_util.h"
21 #include "chrome/browser/extensions/favicon_downloader.h" 22 #include "chrome/browser/extensions/favicon_downloader.h"
22 #include "chrome/browser/extensions/image_loader.h" 23 #include "chrome/browser/extensions/image_loader.h"
23 #include "chrome/browser/extensions/page_action_controller.h" 24 #include "chrome/browser/extensions/page_action_controller.h"
24 #include "chrome/browser/extensions/script_executor.h" 25 #include "chrome/browser/extensions/script_executor.h"
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 break; 557 break;
557 } 558 }
558 559
559 // The hosted app action will be cleared once the installation completes or 560 // The hosted app action will be cleared once the installation completes or
560 // fails. 561 // fails.
561 if (pending_web_app_action_ != CREATE_HOSTED_APP) 562 if (pending_web_app_action_ != CREATE_HOSTED_APP)
562 pending_web_app_action_ = NONE; 563 pending_web_app_action_ = NONE;
563 #endif 564 #endif
564 } 565 }
565 566
566 void TabHelper::OnInlineWebstoreInstall( 567 void TabHelper::OnInlineWebstoreInstall(int install_id,
567 int install_id, 568 int return_route_id,
568 int return_route_id, 569 const std::string& webstore_item_id,
569 const std::string& webstore_item_id, 570 const GURL& requestor_url,
570 const GURL& requestor_url) { 571 int listeners_mask) {
572 #if defined(ENABLE_EXTENSIONS)
573 // Check that the listener is reasonable. We should never get anything other
574 // than an install stage listener, a download listener, or both.
575 if ((listeners_mask & ~(api::webstore::INSTALL_STAGE_LISTENER |
576 api::webstore::DOWNLOAD_PROGRESS_LISTENER)) != 0) {
577 NOTREACHED();
578 return;
579 }
580 // Inform the Webstore API that an inline install is happening, in case the
581 // page requested status updates.
582 Profile* profile =
583 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
584 WebstoreAPI::Get(profile)->OnInlineInstallStart(
585 return_route_id, this, webstore_item_id, listeners_mask);
586 #endif
587
571 WebstoreStandaloneInstaller::Callback callback = 588 WebstoreStandaloneInstaller::Callback callback =
572 base::Bind(&TabHelper::OnInlineInstallComplete, base::Unretained(this), 589 base::Bind(&TabHelper::OnInlineInstallComplete, base::Unretained(this),
573 install_id, return_route_id); 590 install_id, return_route_id);
574 scoped_refptr<WebstoreInlineInstaller> installer( 591 scoped_refptr<WebstoreInlineInstaller> installer(
575 webstore_inline_installer_factory_->CreateInstaller( 592 webstore_inline_installer_factory_->CreateInstaller(
576 web_contents(), 593 web_contents(),
577 webstore_item_id, 594 webstore_item_id,
578 requestor_url, 595 requestor_url,
579 callback)); 596 callback));
580 installer->BeginInstall(); 597 installer->BeginInstall();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 } 796 }
780 } 797 }
781 798
782 void TabHelper::SetTabId(RenderViewHost* render_view_host) { 799 void TabHelper::SetTabId(RenderViewHost* render_view_host) {
783 render_view_host->Send( 800 render_view_host->Send(
784 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), 801 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(),
785 SessionID::IdForTab(web_contents()))); 802 SessionID::IdForTab(web_contents())));
786 } 803 }
787 804
788 } // namespace extensions 805 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698