| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_tab_helper.h" | 5 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/sessions/restore_tab_helper.h" | 9 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_list.h" | 11 #include "chrome/browser/ui/browser_list.h" |
| 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" |
| 14 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "chrome/common/extensions/extension_action.h" | 15 #include "chrome/common/extensions/extension_action.h" |
| 15 #include "chrome/common/extensions/extension_icon_set.h" | 16 #include "chrome/common/extensions/extension_icon_set.h" |
| 16 #include "chrome/common/extensions/extension_messages.h" | 17 #include "chrome/common/extensions/extension_messages.h" |
| 17 #include "chrome/common/extensions/extension_resource.h" | 18 #include "chrome/common/extensions/extension_resource.h" |
| 18 #include "content/browser/renderer_host/render_widget_host_view.h" | 19 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 19 #include "content/browser/tab_contents/navigation_details.h" | 20 #include "content/browser/tab_contents/navigation_details.h" |
| 20 #include "content/browser/tab_contents/tab_contents.h" | 21 #include "content/browser/tab_contents/tab_contents.h" |
| 21 #include "content/common/notification_service.h" | 22 #include "content/common/notification_service.h" |
| 22 | 23 |
| 23 ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper) | 24 ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 45 Send(new ExtensionMsg_GetApplicationInfo(routing_id(), page_id)); | 46 Send(new ExtensionMsg_GetApplicationInfo(routing_id(), page_id)); |
| 46 } | 47 } |
| 47 | 48 |
| 48 void ExtensionTabHelper::SetExtensionApp(const Extension* extension) { | 49 void ExtensionTabHelper::SetExtensionApp(const Extension* extension) { |
| 49 DCHECK(!extension || extension->GetFullLaunchURL().is_valid()); | 50 DCHECK(!extension || extension->GetFullLaunchURL().is_valid()); |
| 50 extension_app_ = extension; | 51 extension_app_ = extension; |
| 51 | 52 |
| 52 UpdateExtensionAppIcon(extension_app_); | 53 UpdateExtensionAppIcon(extension_app_); |
| 53 | 54 |
| 54 NotificationService::current()->Notify( | 55 NotificationService::current()->Notify( |
| 55 NotificationType::TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED, | 56 chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED, |
| 56 Source<ExtensionTabHelper>(this), | 57 Source<ExtensionTabHelper>(this), |
| 57 NotificationService::NoDetails()); | 58 NotificationService::NoDetails()); |
| 58 } | 59 } |
| 59 | 60 |
| 60 void ExtensionTabHelper::SetExtensionAppById( | 61 void ExtensionTabHelper::SetExtensionAppById( |
| 61 const std::string& extension_app_id) { | 62 const std::string& extension_app_id) { |
| 62 if (extension_app_id.empty()) | 63 if (extension_app_id.empty()) |
| 63 return; | 64 return; |
| 64 | 65 |
| 65 ExtensionService* extension_service = | 66 ExtensionService* extension_service = |
| (...skipping 24 matching lines...) Expand all Loading... |
| 90 if (!service) | 91 if (!service) |
| 91 return; | 92 return; |
| 92 | 93 |
| 93 for (size_t i = 0; i < service->extensions()->size(); ++i) { | 94 for (size_t i = 0; i < service->extensions()->size(); ++i) { |
| 94 ExtensionAction* browser_action = | 95 ExtensionAction* browser_action = |
| 95 service->extensions()->at(i)->browser_action(); | 96 service->extensions()->at(i)->browser_action(); |
| 96 if (browser_action) { | 97 if (browser_action) { |
| 97 browser_action->ClearAllValuesForTab( | 98 browser_action->ClearAllValuesForTab( |
| 98 wrapper_->restore_tab_helper()->session_id().id()); | 99 wrapper_->restore_tab_helper()->session_id().id()); |
| 99 NotificationService::current()->Notify( | 100 NotificationService::current()->Notify( |
| 100 NotificationType::EXTENSION_BROWSER_ACTION_UPDATED, | 101 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, |
| 101 Source<ExtensionAction>(browser_action), | 102 Source<ExtensionAction>(browser_action), |
| 102 NotificationService::NoDetails()); | 103 NotificationService::NoDetails()); |
| 103 } | 104 } |
| 104 | 105 |
| 105 ExtensionAction* page_action = | 106 ExtensionAction* page_action = |
| 106 service->extensions()->at(i)->page_action(); | 107 service->extensions()->at(i)->page_action(); |
| 107 if (page_action) { | 108 if (page_action) { |
| 108 page_action->ClearAllValuesForTab( | 109 page_action->ClearAllValuesForTab( |
| 109 wrapper_->restore_tab_helper()->session_id().id()); | 110 wrapper_->restore_tab_helper()->session_id().id()); |
| 110 PageActionStateChanged(); | 111 PageActionStateChanged(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 if (tab_contents_delegate) | 202 if (tab_contents_delegate) |
| 202 return tab_contents_delegate->GetFrameNativeWindow(); | 203 return tab_contents_delegate->GetFrameNativeWindow(); |
| 203 else | 204 else |
| 204 return NULL; | 205 return NULL; |
| 205 } | 206 } |
| 206 | 207 |
| 207 gfx::NativeView ExtensionTabHelper::GetNativeViewOfHost() { | 208 gfx::NativeView ExtensionTabHelper::GetNativeViewOfHost() { |
| 208 RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView(); | 209 RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView(); |
| 209 return rwhv ? rwhv->GetNativeView() : NULL; | 210 return rwhv ? rwhv->GetNativeView() : NULL; |
| 210 } | 211 } |
| OLD | NEW |