| 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/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/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "chrome/common/extensions/extension_action.h" | 15 #include "chrome/common/extensions/extension_action.h" |
| 16 #include "chrome/common/extensions/extension_icon_set.h" | 16 #include "chrome/common/extensions/extension_icon_set.h" |
| 17 #include "chrome/common/extensions/extension_messages.h" | 17 #include "chrome/common/extensions/extension_messages.h" |
| 18 #include "chrome/common/extensions/extension_resource.h" | 18 #include "chrome/common/extensions/extension_resource.h" |
| 19 #include "content/browser/renderer_host/render_view_host.h" | 19 #include "content/browser/renderer_host/render_view_host.h" |
| 20 #include "content/public/browser/invalidate_type.h" | 20 #include "content/public/browser/invalidate_type.h" |
| 21 #include "content/public/browser/navigation_details.h" | 21 #include "content/public/browser/navigation_details.h" |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
| 24 #include "content/public/browser/render_widget_host_view.h" | 24 #include "content/public/browser/render_widget_host_view.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "ui/gfx/image/image.h" |
| 26 | 27 |
| 27 using content::WebContents; | 28 using content::WebContents; |
| 28 | 29 |
| 29 ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper) | 30 ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper) |
| 30 : content::WebContentsObserver(wrapper->web_contents()), | 31 : content::WebContentsObserver(wrapper->web_contents()), |
| 31 delegate_(NULL), | 32 delegate_(NULL), |
| 32 extension_app_(NULL), | 33 extension_app_(NULL), |
| 33 ALLOW_THIS_IN_INITIALIZER_LIST( | 34 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 34 extension_function_dispatcher_(wrapper->profile(), this)), | 35 extension_function_dispatcher_(wrapper->profile(), this)), |
| 35 wrapper_(wrapper) { | 36 wrapper_(wrapper) { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } else { | 250 } else { |
| 250 extension_app_image_loader_.reset(NULL); | 251 extension_app_image_loader_.reset(NULL); |
| 251 } | 252 } |
| 252 } | 253 } |
| 253 | 254 |
| 254 void ExtensionTabHelper::SetAppIcon(const SkBitmap& app_icon) { | 255 void ExtensionTabHelper::SetAppIcon(const SkBitmap& app_icon) { |
| 255 extension_app_icon_ = app_icon; | 256 extension_app_icon_ = app_icon; |
| 256 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE); | 257 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE); |
| 257 } | 258 } |
| 258 | 259 |
| 259 void ExtensionTabHelper::OnImageLoaded(SkBitmap* image, | 260 void ExtensionTabHelper::OnImageLoaded(const gfx::Image* image, |
| 260 const ExtensionResource& resource, | 261 const std::string& extension_id, |
| 261 int index) { | 262 int index) { |
| 262 if (image) { | 263 if (image) { |
| 263 extension_app_icon_ = *image; | 264 extension_app_icon_ = *image->ToSkBitmap(); |
| 264 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); | 265 web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); |
| 265 } | 266 } |
| 266 } | 267 } |
| 267 | 268 |
| 268 Browser* ExtensionTabHelper::GetBrowser() { | 269 Browser* ExtensionTabHelper::GetBrowser() { |
| 269 content::WebContents* contents = web_contents(); | 270 content::WebContents* contents = web_contents(); |
| 270 TabContentsIterator tab_iterator; | 271 TabContentsIterator tab_iterator; |
| 271 for (; !tab_iterator.done(); ++tab_iterator) { | 272 for (; !tab_iterator.done(); ++tab_iterator) { |
| 272 if (contents == (*tab_iterator)->web_contents()) | 273 if (contents == (*tab_iterator)->web_contents()) |
| 273 return tab_iterator.browser(); | 274 return tab_iterator.browser(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 285 void ExtensionTabHelper::OnInlineInstallFailure(int install_id, | 286 void ExtensionTabHelper::OnInlineInstallFailure(int install_id, |
| 286 int return_route_id, | 287 int return_route_id, |
| 287 const std::string& error) { | 288 const std::string& error) { |
| 288 Send(new ExtensionMsg_InlineWebstoreInstallResponse( | 289 Send(new ExtensionMsg_InlineWebstoreInstallResponse( |
| 289 return_route_id, install_id, false, error)); | 290 return_route_id, install_id, false, error)); |
| 290 } | 291 } |
| 291 | 292 |
| 292 WebContents* ExtensionTabHelper::GetAssociatedWebContents() const { | 293 WebContents* ExtensionTabHelper::GetAssociatedWebContents() const { |
| 293 return web_contents(); | 294 return web_contents(); |
| 294 } | 295 } |
| OLD | NEW |