Chromium Code Reviews| 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 "base/command_line.h" | |
| 7 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/sessions/restore_tab_helper.h" | 10 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
| 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" |
| 14 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/common/chrome_switches.h" | |
| 15 #include "chrome/common/extensions/extension_action.h" | 17 #include "chrome/common/extensions/extension_action.h" |
| 16 #include "chrome/common/extensions/extension_icon_set.h" | 18 #include "chrome/common/extensions/extension_icon_set.h" |
| 17 #include "chrome/common/extensions/extension_messages.h" | 19 #include "chrome/common/extensions/extension_messages.h" |
| 18 #include "chrome/common/extensions/extension_resource.h" | 20 #include "chrome/common/extensions/extension_resource.h" |
| 19 #include "content/browser/renderer_host/render_widget_host_view.h" | 21 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 20 #include "content/browser/tab_contents/navigation_details.h" | 22 #include "content/browser/tab_contents/navigation_details.h" |
| 21 #include "content/browser/tab_contents/tab_contents.h" | 23 #include "content/browser/tab_contents/tab_contents.h" |
| 22 #include "content/common/notification_service.h" | 24 #include "content/common/notification_service.h" |
| 23 | 25 |
| 24 ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper) | 26 ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 } | 118 } |
| 117 } | 119 } |
| 118 | 120 |
| 119 bool ExtensionTabHelper::OnMessageReceived(const IPC::Message& message) { | 121 bool ExtensionTabHelper::OnMessageReceived(const IPC::Message& message) { |
| 120 bool handled = true; | 122 bool handled = true; |
| 121 IPC_BEGIN_MESSAGE_MAP(ExtensionTabHelper, message) | 123 IPC_BEGIN_MESSAGE_MAP(ExtensionTabHelper, message) |
| 122 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DidGetApplicationInfo, | 124 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DidGetApplicationInfo, |
| 123 OnDidGetApplicationInfo) | 125 OnDidGetApplicationInfo) |
| 124 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InstallApplication, | 126 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InstallApplication, |
| 125 OnInstallApplication) | 127 OnInstallApplication) |
| 128 IPC_MESSAGE_HANDLER(ExtensionHostMsg_InlineWebstoreInstall, | |
| 129 OnInlineWebstoreInstall) | |
| 126 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | 130 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
| 127 IPC_MESSAGE_UNHANDLED(handled = false) | 131 IPC_MESSAGE_UNHANDLED(handled = false) |
| 128 IPC_END_MESSAGE_MAP() | 132 IPC_END_MESSAGE_MAP() |
| 129 return handled; | 133 return handled; |
| 130 } | 134 } |
| 131 | 135 |
| 132 void ExtensionTabHelper::OnDidGetApplicationInfo( | 136 void ExtensionTabHelper::OnDidGetApplicationInfo( |
| 133 int32 page_id, const WebApplicationInfo& info) { | 137 int32 page_id, const WebApplicationInfo& info) { |
| 134 web_app_info_ = info; | 138 web_app_info_ = info; |
| 135 | 139 |
| 136 if (wrapper_->delegate()) | 140 if (wrapper_->delegate()) |
| 137 wrapper_->delegate()->OnDidGetApplicationInfo(wrapper_, page_id); | 141 wrapper_->delegate()->OnDidGetApplicationInfo(wrapper_, page_id); |
| 138 } | 142 } |
| 139 | 143 |
| 140 void ExtensionTabHelper::OnInstallApplication(const WebApplicationInfo& info) { | 144 void ExtensionTabHelper::OnInstallApplication(const WebApplicationInfo& info) { |
| 141 if (wrapper_->delegate()) | 145 if (wrapper_->delegate()) |
| 142 wrapper_->delegate()->OnInstallApplication(wrapper_, info); | 146 wrapper_->delegate()->OnInstallApplication(wrapper_, info); |
| 143 } | 147 } |
| 144 | 148 |
| 149 void ExtensionTabHelper::OnInlineWebstoreInstall( | |
| 150 const std::string& webstore_item_id) { | |
| 151 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
| 152 switches::kEnableInlineWebstoreInstall)) | |
|
Aaron Boodman
2011/08/17 04:53:03
You should use curly braces when the condition wra
Mihai Parparita -not on Chrome
2011/08/17 23:00:16
Done.
| |
| 153 return; | |
| 154 | |
| 155 // For now there is no inline installation UI, we just open the item's Web | |
| 156 // Store page in a new tab. | |
| 157 GURL webstore_item_url = | |
| 158 GURL(::Extension::ChromeStoreItemDetailURLPrefix() + webstore_item_id); | |
| 159 GetBrowser()->OpenURL(OpenURLParams( | |
| 160 webstore_item_url, | |
| 161 GetBrowser()->GetSelectedTabContents()->GetURL(), | |
| 162 NEW_FOREGROUND_TAB, | |
| 163 PageTransition::AUTO_BOOKMARK)); | |
| 164 } | |
| 165 | |
| 145 void ExtensionTabHelper::OnRequest( | 166 void ExtensionTabHelper::OnRequest( |
| 146 const ExtensionHostMsg_Request_Params& request) { | 167 const ExtensionHostMsg_Request_Params& request) { |
| 147 extension_function_dispatcher_.Dispatch(request, | 168 extension_function_dispatcher_.Dispatch(request, |
| 148 tab_contents()->render_view_host()); | 169 tab_contents()->render_view_host()); |
| 149 } | 170 } |
| 150 | 171 |
| 151 void ExtensionTabHelper::UpdateExtensionAppIcon(const Extension* extension) { | 172 void ExtensionTabHelper::UpdateExtensionAppIcon(const Extension* extension) { |
| 152 extension_app_icon_.reset(); | 173 extension_app_icon_.reset(); |
| 153 | 174 |
| 154 if (extension) { | 175 if (extension) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 if (tab_contents_delegate) | 226 if (tab_contents_delegate) |
| 206 return tab_contents_delegate->GetFrameNativeWindow(); | 227 return tab_contents_delegate->GetFrameNativeWindow(); |
| 207 else | 228 else |
| 208 return NULL; | 229 return NULL; |
| 209 } | 230 } |
| 210 | 231 |
| 211 gfx::NativeView ExtensionTabHelper::GetNativeViewOfHost() { | 232 gfx::NativeView ExtensionTabHelper::GetNativeViewOfHost() { |
| 212 RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView(); | 233 RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView(); |
| 213 return rwhv ? rwhv->GetNativeView() : NULL; | 234 return rwhv ? rwhv->GetNativeView() : NULL; |
| 214 } | 235 } |
| OLD | NEW |