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" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 | 99 |
100 TabHelper::TabHelper(content::WebContents* web_contents) | 100 TabHelper::TabHelper(content::WebContents* web_contents) |
101 : content::WebContentsObserver(web_contents), | 101 : content::WebContentsObserver(web_contents), |
102 extension_app_(NULL), | 102 extension_app_(NULL), |
103 extension_function_dispatcher_( | 103 extension_function_dispatcher_( |
104 Profile::FromBrowserContext(web_contents->GetBrowserContext()), this), | 104 Profile::FromBrowserContext(web_contents->GetBrowserContext()), this), |
105 pending_web_app_action_(NONE), | 105 pending_web_app_action_(NONE), |
106 script_executor_(new ScriptExecutor(web_contents, | 106 script_executor_(new ScriptExecutor(web_contents, |
107 &script_execution_observers_)), | 107 &script_execution_observers_)), |
108 location_bar_controller_(new LocationBarController(web_contents)), | 108 location_bar_controller_(new LocationBarController(web_contents)), |
109 image_loader_ptr_factory_(this), | 109 image_loader_ptr_factory_(this) { |
110 webstore_inline_installer_factory_(new WebstoreInlineInstallerFactory()) { | 110 #if defined(ENABLE_EXTENSIONS) |
Lei Zhang
2014/06/20 23:22:04
I'll likely land https://codereview.chromium.org/3
| |
111 // TODO(thestig) Add this back to the initializer list when TabHelper is no | |
112 // longer built on mobile. | |
113 webstore_inline_installer_factory_.reset( | |
114 new WebstoreInlineInstallerFactory()); | |
115 #endif | |
116 | |
111 // The ActiveTabPermissionManager requires a session ID; ensure this | 117 // The ActiveTabPermissionManager requires a session ID; ensure this |
112 // WebContents has one. | 118 // WebContents has one. |
113 SessionTabHelper::CreateForWebContents(web_contents); | 119 SessionTabHelper::CreateForWebContents(web_contents); |
114 if (web_contents->GetRenderViewHost()) | 120 if (web_contents->GetRenderViewHost()) |
115 SetTabId(web_contents->GetRenderViewHost()); | 121 SetTabId(web_contents->GetRenderViewHost()); |
116 active_tab_permission_granter_.reset(new ActiveTabPermissionGranter( | 122 active_tab_permission_granter_.reset(new ActiveTabPermissionGranter( |
117 web_contents, | 123 web_contents, |
118 SessionID::IdForTab(web_contents), | 124 SessionID::IdForTab(web_contents), |
119 Profile::FromBrowserContext(web_contents->GetBrowserContext()))); | 125 Profile::FromBrowserContext(web_contents->GetBrowserContext()))); |
120 | 126 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 api::webstore::DOWNLOAD_PROGRESS_LISTENER)) != 0) { | 409 api::webstore::DOWNLOAD_PROGRESS_LISTENER)) != 0) { |
404 NOTREACHED(); | 410 NOTREACHED(); |
405 return; | 411 return; |
406 } | 412 } |
407 // Inform the Webstore API that an inline install is happening, in case the | 413 // Inform the Webstore API that an inline install is happening, in case the |
408 // page requested status updates. | 414 // page requested status updates. |
409 Profile* profile = | 415 Profile* profile = |
410 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 416 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
411 WebstoreAPI::Get(profile)->OnInlineInstallStart( | 417 WebstoreAPI::Get(profile)->OnInlineInstallStart( |
412 return_route_id, this, webstore_item_id, listeners_mask); | 418 return_route_id, this, webstore_item_id, listeners_mask); |
413 #endif | |
414 | 419 |
415 WebstoreStandaloneInstaller::Callback callback = | 420 WebstoreStandaloneInstaller::Callback callback = |
416 base::Bind(&TabHelper::OnInlineInstallComplete, base::Unretained(this), | 421 base::Bind(&TabHelper::OnInlineInstallComplete, base::Unretained(this), |
417 install_id, return_route_id); | 422 install_id, return_route_id); |
418 scoped_refptr<WebstoreInlineInstaller> installer( | 423 scoped_refptr<WebstoreInlineInstaller> installer( |
419 webstore_inline_installer_factory_->CreateInstaller( | 424 webstore_inline_installer_factory_->CreateInstaller( |
420 web_contents(), | 425 web_contents(), |
421 webstore_item_id, | 426 webstore_item_id, |
422 requestor_url, | 427 requestor_url, |
423 callback)); | 428 callback)); |
424 installer->BeginInstall(); | 429 installer->BeginInstall(); |
430 #endif // defined(ENABLE_EXTENSIONS) | |
425 } | 431 } |
426 | 432 |
427 void TabHelper::OnGetAppInstallState(const GURL& requestor_url, | 433 void TabHelper::OnGetAppInstallState(const GURL& requestor_url, |
428 int return_route_id, | 434 int return_route_id, |
429 int callback_id) { | 435 int callback_id) { |
430 ExtensionRegistry* registry = | 436 ExtensionRegistry* registry = |
431 ExtensionRegistry::Get(web_contents()->GetBrowserContext()); | 437 ExtensionRegistry::Get(web_contents()->GetBrowserContext()); |
432 const ExtensionSet& extensions = registry->enabled_extensions(); | 438 const ExtensionSet& extensions = registry->enabled_extensions(); |
433 const ExtensionSet& disabled_extensions = registry->disabled_extensions(); | 439 const ExtensionSet& disabled_extensions = registry->disabled_extensions(); |
434 | 440 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
594 } | 600 } |
595 } | 601 } |
596 | 602 |
597 void TabHelper::SetTabId(RenderViewHost* render_view_host) { | 603 void TabHelper::SetTabId(RenderViewHost* render_view_host) { |
598 render_view_host->Send( | 604 render_view_host->Send( |
599 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), | 605 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), |
600 SessionID::IdForTab(web_contents()))); | 606 SessionID::IdForTab(web_contents()))); |
601 } | 607 } |
602 | 608 |
603 } // namespace extensions | 609 } // namespace extensions |
OLD | NEW |