| 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/active_script_controller.h" | 12 #include "chrome/browser/extensions/active_script_controller.h" |
| 13 #include "chrome/browser/extensions/activity_log/activity_log.h" | 13 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 14 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" | 14 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" |
| 15 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist
ry.h" | 15 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist
ry.h" |
| 16 #include "chrome/browser/extensions/api/webstore/webstore_api.h" | 16 #include "chrome/browser/extensions/api/webstore/webstore_api.h" |
| 17 #include "chrome/browser/extensions/bookmark_app_helper.h" | 17 #include "chrome/browser/extensions/bookmark_app_helper.h" |
| 18 #include "chrome/browser/extensions/error_console/error_console.h" | 18 #include "chrome/browser/extensions/error_console/error_console.h" |
| 19 #include "chrome/browser/extensions/extension_action.h" | 19 #include "chrome/browser/extensions/extension_action.h" |
| 20 #include "chrome/browser/extensions/extension_action_manager.h" | 20 #include "chrome/browser/extensions/extension_action_manager.h" |
| 21 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 22 #include "chrome/browser/extensions/extension_tab_util.h" | 22 #include "chrome/browser/extensions/extension_tab_util.h" |
| 23 #include "chrome/browser/extensions/location_bar_controller.h" | 23 #include "chrome/browser/extensions/location_bar_controller.h" |
| 24 #include "chrome/browser/extensions/webstore_inline_installer.h" | 24 #include "chrome/browser/extensions/webstore_inline_installer.h" |
| 25 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" | 25 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/sessions/session_id.h" | |
| 28 #include "chrome/browser/sessions/session_tab_helper.h" | 27 #include "chrome/browser/sessions/session_tab_helper.h" |
| 29 #include "chrome/browser/shell_integration.h" | 28 #include "chrome/browser/shell_integration.h" |
| 30 #include "chrome/browser/ui/browser_commands.h" | 29 #include "chrome/browser/ui/browser_commands.h" |
| 31 #include "chrome/browser/ui/browser_dialogs.h" | 30 #include "chrome/browser/ui/browser_dialogs.h" |
| 32 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
| 33 #include "chrome/browser/ui/browser_window.h" | 32 #include "chrome/browser/ui/browser_window.h" |
| 34 #include "chrome/browser/ui/host_desktop.h" | 33 #include "chrome/browser/ui/host_desktop.h" |
| 35 #include "chrome/browser/web_applications/web_app.h" | 34 #include "chrome/browser/web_applications/web_app.h" |
| 36 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
| 37 #include "chrome/common/extensions/chrome_extension_messages.h" | 36 #include "chrome/common/extensions/chrome_extension_messages.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 location_bar_controller_(new LocationBarController(web_contents)), | 94 location_bar_controller_(new LocationBarController(web_contents)), |
| 96 image_loader_ptr_factory_(this), | 95 image_loader_ptr_factory_(this), |
| 97 webstore_inline_installer_factory_(new WebstoreInlineInstallerFactory()) { | 96 webstore_inline_installer_factory_(new WebstoreInlineInstallerFactory()) { |
| 98 // The ActiveTabPermissionManager requires a session ID; ensure this | 97 // The ActiveTabPermissionManager requires a session ID; ensure this |
| 99 // WebContents has one. | 98 // WebContents has one. |
| 100 SessionTabHelper::CreateForWebContents(web_contents); | 99 SessionTabHelper::CreateForWebContents(web_contents); |
| 101 if (web_contents->GetRenderViewHost()) | 100 if (web_contents->GetRenderViewHost()) |
| 102 SetTabId(web_contents->GetRenderViewHost()); | 101 SetTabId(web_contents->GetRenderViewHost()); |
| 103 active_tab_permission_granter_.reset(new ActiveTabPermissionGranter( | 102 active_tab_permission_granter_.reset(new ActiveTabPermissionGranter( |
| 104 web_contents, | 103 web_contents, |
| 105 SessionID::IdForTab(web_contents), | 104 SessionTabHelper::IdForTab(web_contents), |
| 106 Profile::FromBrowserContext(web_contents->GetBrowserContext()))); | 105 Profile::FromBrowserContext(web_contents->GetBrowserContext()))); |
| 107 | 106 |
| 108 // If more classes need to listen to global content script activity, then | 107 // If more classes need to listen to global content script activity, then |
| 109 // a separate routing class with an observer interface should be written. | 108 // a separate routing class with an observer interface should be written. |
| 110 profile_ = Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 109 profile_ = Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 111 | 110 |
| 112 AddScriptExecutionObserver(ActivityLog::GetInstance(profile_)); | 111 AddScriptExecutionObserver(ActivityLog::GetInstance(profile_)); |
| 113 | 112 |
| 114 registrar_.Add(this, | 113 registrar_.Add(this, |
| 115 content::NOTIFICATION_LOAD_STOP, | 114 content::NOTIFICATION_LOAD_STOP, |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 return; | 251 return; |
| 253 | 252 |
| 254 ExtensionActionManager* extension_action_manager = | 253 ExtensionActionManager* extension_action_manager = |
| 255 ExtensionActionManager::Get(Profile::FromBrowserContext(context)); | 254 ExtensionActionManager::Get(Profile::FromBrowserContext(context)); |
| 256 for (ExtensionSet::const_iterator it = enabled_extensions.begin(); | 255 for (ExtensionSet::const_iterator it = enabled_extensions.begin(); |
| 257 it != enabled_extensions.end(); | 256 it != enabled_extensions.end(); |
| 258 ++it) { | 257 ++it) { |
| 259 ExtensionAction* browser_action = | 258 ExtensionAction* browser_action = |
| 260 extension_action_manager->GetBrowserAction(*it->get()); | 259 extension_action_manager->GetBrowserAction(*it->get()); |
| 261 if (browser_action) { | 260 if (browser_action) { |
| 262 browser_action->ClearAllValuesForTab(SessionID::IdForTab(web_contents())); | 261 browser_action->ClearAllValuesForTab( |
| 262 SessionTabHelper::IdForTab(web_contents())); |
| 263 content::NotificationService::current()->Notify( | 263 content::NotificationService::current()->Notify( |
| 264 extensions::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, | 264 extensions::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, |
| 265 content::Source<ExtensionAction>(browser_action), | 265 content::Source<ExtensionAction>(browser_action), |
| 266 content::NotificationService::NoDetails()); | 266 content::NotificationService::NoDetails()); |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 | 270 |
| 271 bool TabHelper::OnMessageReceived(const IPC::Message& message) { | 271 bool TabHelper::OnMessageReceived(const IPC::Message& message) { |
| 272 bool handled = true; | 272 bool handled = true; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 // when an interstitial page is injected (e.g. bad https certificate, | 552 // when an interstitial page is injected (e.g. bad https certificate, |
| 553 // malware site etc). When this happens, we abort the shortcut update. | 553 // malware site etc). When this happens, we abort the shortcut update. |
| 554 if (controller.GetLastCommittedEntry()) | 554 if (controller.GetLastCommittedEntry()) |
| 555 GetApplicationInfo(UPDATE_SHORTCUT); | 555 GetApplicationInfo(UPDATE_SHORTCUT); |
| 556 } | 556 } |
| 557 } | 557 } |
| 558 | 558 |
| 559 void TabHelper::SetTabId(RenderViewHost* render_view_host) { | 559 void TabHelper::SetTabId(RenderViewHost* render_view_host) { |
| 560 render_view_host->Send( | 560 render_view_host->Send( |
| 561 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), | 561 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), |
| 562 SessionID::IdForTab(web_contents()))); | 562 SessionTabHelper::IdForTab(web_contents()))); |
| 563 } | 563 } |
| 564 | 564 |
| 565 } // namespace extensions | 565 } // namespace extensions |
| OLD | NEW |