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/extensions/webstore_inline_installer.h" | 8 #include "chrome/browser/extensions/webstore_inline_installer.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/sessions/restore_tab_helper.h" | 10 #include "chrome/browser/sessions/restore_tab_helper.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" |
15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/common/extensions/extension_action.h" | 16 #include "chrome/common/extensions/extension_action.h" |
17 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
18 #include "chrome/common/extensions/extension_icon_set.h" | 18 #include "chrome/common/extensions/extension_icon_set.h" |
19 #include "chrome/common/extensions/extension_messages.h" | 19 #include "chrome/common/extensions/extension_messages.h" |
20 #include "chrome/common/extensions/extension_resource.h" | 20 #include "chrome/common/extensions/extension_resource.h" |
21 #include "content/browser/renderer_host/render_view_host.h" | 21 #include "content/browser/renderer_host/render_view_host.h" |
22 #include "content/browser/renderer_host/render_widget_host_view.h" | 22 #include "content/browser/renderer_host/render_widget_host_view.h" |
23 #include "content/browser/tab_contents/navigation_details.h" | 23 #include "content/browser/tab_contents/navigation_details.h" |
24 #include "content/browser/tab_contents/tab_contents.h" | 24 #include "content/browser/tab_contents/tab_contents.h" |
25 #include "content/common/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
26 | 26 |
27 ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper) | 27 ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper) |
28 : TabContentsObserver(wrapper->tab_contents()), | 28 : TabContentsObserver(wrapper->tab_contents()), |
29 extension_app_(NULL), | 29 extension_app_(NULL), |
30 ALLOW_THIS_IN_INITIALIZER_LIST( | 30 ALLOW_THIS_IN_INITIALIZER_LIST( |
31 extension_function_dispatcher_(wrapper->profile(), this)), | 31 extension_function_dispatcher_(wrapper->profile(), this)), |
32 wrapper_(wrapper) { | 32 wrapper_(wrapper) { |
33 } | 33 } |
34 | 34 |
35 ExtensionTabHelper::~ExtensionTabHelper() { | 35 ExtensionTabHelper::~ExtensionTabHelper() { |
(...skipping 12 matching lines...) Expand all Loading... |
48 void ExtensionTabHelper::GetApplicationInfo(int32 page_id) { | 48 void ExtensionTabHelper::GetApplicationInfo(int32 page_id) { |
49 Send(new ExtensionMsg_GetApplicationInfo(routing_id(), page_id)); | 49 Send(new ExtensionMsg_GetApplicationInfo(routing_id(), page_id)); |
50 } | 50 } |
51 | 51 |
52 void ExtensionTabHelper::SetExtensionApp(const Extension* extension) { | 52 void ExtensionTabHelper::SetExtensionApp(const Extension* extension) { |
53 DCHECK(!extension || extension->GetFullLaunchURL().is_valid()); | 53 DCHECK(!extension || extension->GetFullLaunchURL().is_valid()); |
54 extension_app_ = extension; | 54 extension_app_ = extension; |
55 | 55 |
56 UpdateExtensionAppIcon(extension_app_); | 56 UpdateExtensionAppIcon(extension_app_); |
57 | 57 |
58 NotificationService::current()->Notify( | 58 content::NotificationService::current()->Notify( |
59 chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED, | 59 chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED, |
60 content::Source<ExtensionTabHelper>(this), | 60 content::Source<ExtensionTabHelper>(this), |
61 NotificationService::NoDetails()); | 61 content::NotificationService::NoDetails()); |
62 } | 62 } |
63 | 63 |
64 void ExtensionTabHelper::SetExtensionAppById( | 64 void ExtensionTabHelper::SetExtensionAppById( |
65 const std::string& extension_app_id) { | 65 const std::string& extension_app_id) { |
66 if (extension_app_id.empty()) | 66 if (extension_app_id.empty()) |
67 return; | 67 return; |
68 | 68 |
69 Profile* profile = | 69 Profile* profile = |
70 Profile::FromBrowserContext(tab_contents()->browser_context()); | 70 Profile::FromBrowserContext(tab_contents()->browser_context()); |
71 ExtensionService* extension_service = profile->GetExtensionService(); | 71 ExtensionService* extension_service = profile->GetExtensionService(); |
(...skipping 24 matching lines...) Expand all Loading... |
96 ExtensionService* service = profile->GetExtensionService(); | 96 ExtensionService* service = profile->GetExtensionService(); |
97 if (!service) | 97 if (!service) |
98 return; | 98 return; |
99 | 99 |
100 for (size_t i = 0; i < service->extensions()->size(); ++i) { | 100 for (size_t i = 0; i < service->extensions()->size(); ++i) { |
101 ExtensionAction* browser_action = | 101 ExtensionAction* browser_action = |
102 service->extensions()->at(i)->browser_action(); | 102 service->extensions()->at(i)->browser_action(); |
103 if (browser_action) { | 103 if (browser_action) { |
104 browser_action->ClearAllValuesForTab( | 104 browser_action->ClearAllValuesForTab( |
105 wrapper_->restore_tab_helper()->session_id().id()); | 105 wrapper_->restore_tab_helper()->session_id().id()); |
106 NotificationService::current()->Notify( | 106 content::NotificationService::current()->Notify( |
107 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, | 107 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, |
108 content::Source<ExtensionAction>(browser_action), | 108 content::Source<ExtensionAction>(browser_action), |
109 NotificationService::NoDetails()); | 109 content::NotificationService::NoDetails()); |
110 } | 110 } |
111 | 111 |
112 ExtensionAction* page_action = | 112 ExtensionAction* page_action = |
113 service->extensions()->at(i)->page_action(); | 113 service->extensions()->at(i)->page_action(); |
114 if (page_action) { | 114 if (page_action) { |
115 page_action->ClearAllValuesForTab( | 115 page_action->ClearAllValuesForTab( |
116 wrapper_->restore_tab_helper()->session_id().id()); | 116 wrapper_->restore_tab_helper()->session_id().id()); |
117 PageActionStateChanged(); | 117 PageActionStateChanged(); |
118 } | 118 } |
119 } | 119 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 } | 264 } |
265 | 265 |
266 TabContents* ExtensionTabHelper::GetAssociatedTabContents() const { | 266 TabContents* ExtensionTabHelper::GetAssociatedTabContents() const { |
267 return tab_contents(); | 267 return tab_contents(); |
268 } | 268 } |
269 | 269 |
270 gfx::NativeView ExtensionTabHelper::GetNativeViewOfHost() { | 270 gfx::NativeView ExtensionTabHelper::GetNativeViewOfHost() { |
271 RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView(); | 271 RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView(); |
272 return rwhv ? rwhv->GetNativeView() : NULL; | 272 return rwhv ? rwhv->GetNativeView() : NULL; |
273 } | 273 } |
OLD | NEW |