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 "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/bookmark_app_helper.h" | 16 #include "chrome/browser/extensions/bookmark_app_helper.h" |
| 17 #include "chrome/browser/extensions/crx_installer.h" |
16 #include "chrome/browser/extensions/error_console/error_console.h" | 18 #include "chrome/browser/extensions/error_console/error_console.h" |
17 #include "chrome/browser/extensions/extension_action.h" | 19 #include "chrome/browser/extensions/extension_action.h" |
18 #include "chrome/browser/extensions/extension_action_manager.h" | 20 #include "chrome/browser/extensions/extension_action_manager.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/extensions/extension_tab_util.h" | 22 #include "chrome/browser/extensions/extension_tab_util.h" |
21 #include "chrome/browser/extensions/image_loader.h" | 23 #include "chrome/browser/extensions/image_loader.h" |
22 #include "chrome/browser/extensions/page_action_controller.h" | 24 #include "chrome/browser/extensions/page_action_controller.h" |
23 #include "chrome/browser/extensions/script_executor.h" | 25 #include "chrome/browser/extensions/script_executor.h" |
24 #include "chrome/browser/extensions/webstore_inline_installer.h" | 26 #include "chrome/browser/extensions/webstore_inline_installer.h" |
25 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" | 27 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" |
(...skipping 329 matching lines...) Loading... |
355 break; | 357 break; |
356 } | 358 } |
357 | 359 |
358 // The hosted app action will be cleared once the installation completes or | 360 // The hosted app action will be cleared once the installation completes or |
359 // fails. | 361 // fails. |
360 if (pending_web_app_action_ != CREATE_HOSTED_APP) | 362 if (pending_web_app_action_ != CREATE_HOSTED_APP) |
361 pending_web_app_action_ = NONE; | 363 pending_web_app_action_ = NONE; |
362 #endif | 364 #endif |
363 } | 365 } |
364 | 366 |
365 void TabHelper::OnInlineWebstoreInstall( | 367 void TabHelper::OnInlineWebstoreInstall(int install_id, |
366 int install_id, | 368 int return_route_id, |
367 int return_route_id, | 369 const std::string& webstore_item_id, |
368 const std::string& webstore_item_id, | 370 const GURL& requestor_url, |
369 const GURL& requestor_url) { | 371 int listeners_mask) { |
| 372 #if defined(ENABLE_EXTENSIONS) |
| 373 // Check that the listener is reasonable. We should never get anything other |
| 374 // than an install stage listener, a download listener, or both. |
| 375 if ((listeners_mask & ~(api::webstore::INSTALL_STAGE_LISTENER | |
| 376 api::webstore::DOWNLOAD_PROGRESS_LISTENER)) != 0) { |
| 377 NOTREACHED(); |
| 378 return; |
| 379 } |
| 380 // Inform the Webstore API that an inline install is happening, in case the |
| 381 // page requested status updates. |
| 382 Profile* profile = |
| 383 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 384 WebstoreAPI::Get(profile)->OnInlineInstallStart( |
| 385 return_route_id, this, webstore_item_id, listeners_mask); |
| 386 #endif |
| 387 |
370 WebstoreStandaloneInstaller::Callback callback = | 388 WebstoreStandaloneInstaller::Callback callback = |
371 base::Bind(&TabHelper::OnInlineInstallComplete, base::Unretained(this), | 389 base::Bind(&TabHelper::OnInlineInstallComplete, base::Unretained(this), |
372 install_id, return_route_id); | 390 install_id, return_route_id); |
373 scoped_refptr<WebstoreInlineInstaller> installer( | 391 scoped_refptr<WebstoreInlineInstaller> installer( |
374 webstore_inline_installer_factory_->CreateInstaller( | 392 webstore_inline_installer_factory_->CreateInstaller( |
375 web_contents(), | 393 web_contents(), |
376 webstore_item_id, | 394 webstore_item_id, |
377 requestor_url, | 395 requestor_url, |
378 callback)); | 396 callback)); |
379 installer->BeginInstall(); | 397 installer->BeginInstall(); |
(...skipping 167 matching lines...) Loading... |
547 } | 565 } |
548 } | 566 } |
549 | 567 |
550 void TabHelper::SetTabId(RenderViewHost* render_view_host) { | 568 void TabHelper::SetTabId(RenderViewHost* render_view_host) { |
551 render_view_host->Send( | 569 render_view_host->Send( |
552 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), | 570 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), |
553 SessionID::IdForTab(web_contents()))); | 571 SessionID::IdForTab(web_contents()))); |
554 } | 572 } |
555 | 573 |
556 } // namespace extensions | 574 } // namespace extensions |
OLD | NEW |