OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/sidebar/sidebar_container.h" | 5 #include "chrome/browser/sidebar/sidebar_container.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/renderer_host/browser_render_process_host.h" |
9 #include "chrome/common/bindings_policy.h" | 10 #include "chrome/common/bindings_policy.h" |
10 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
11 #include "chrome/common/extensions/extension_resource.h" | 12 #include "chrome/common/extensions/extension_resource.h" |
12 #include "chrome/common/extensions/extension_sidebar_defaults.h" | 13 #include "chrome/common/extensions/extension_sidebar_defaults.h" |
13 #include "chrome/common/extensions/extension_sidebar_utils.h" | 14 #include "chrome/common/extensions/extension_sidebar_utils.h" |
14 #include "content/browser/renderer_host/render_view_host.h" | 15 #include "content/browser/renderer_host/render_view_host.h" |
15 #include "content/browser/tab_contents/navigation_controller.h" | 16 #include "content/browser/tab_contents/navigation_controller.h" |
16 #include "content/browser/tab_contents/navigation_entry.h" | 17 #include "content/browser/tab_contents/navigation_entry.h" |
17 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
18 #include "content/browser/tab_contents/tab_contents_view.h" | 19 #include "content/browser/tab_contents/tab_contents_view.h" |
19 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
20 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
21 | 22 |
22 SidebarContainer::SidebarContainer(TabContents* tab, | 23 SidebarContainer::SidebarContainer(TabContents* tab, |
23 const std::string& content_id, | 24 const std::string& content_id, |
24 Delegate* delegate) | 25 Delegate* delegate) |
25 : tab_(tab), | 26 : tab_(tab), |
26 content_id_(content_id), | 27 content_id_(content_id), |
27 delegate_(delegate), | 28 delegate_(delegate), |
28 icon_(new SkBitmap), | 29 icon_(new SkBitmap), |
29 navigate_to_default_page_on_expand_(true), | 30 navigate_to_default_page_on_expand_(true), |
30 use_default_icon_(true) { | 31 use_default_icon_(true) { |
31 // Create TabContents for sidebar. | 32 // Create TabContents for sidebar. |
32 sidebar_contents_.reset( | 33 sidebar_contents_.reset( |
33 new TabContents(tab->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL)); | 34 new TabContents(tab->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL)); |
34 sidebar_contents_->render_view_host()->set_is_extension_process(true); | 35 sidebar_contents_->render_view_host()->set_is_extension_process(true); |
| 36 const Extension* extension = GetExtension(); |
| 37 if (extension && extension->is_app()) { |
| 38 BrowserRenderProcessHost* process = static_cast<BrowserRenderProcessHost*>( |
| 39 sidebar_contents_->render_view_host()->process()); |
| 40 process->set_installed_app(extension); |
| 41 } |
35 sidebar_contents_->render_view_host()->AllowBindings( | 42 sidebar_contents_->render_view_host()->AllowBindings( |
36 BindingsPolicy::EXTENSION); | 43 BindingsPolicy::EXTENSION); |
37 sidebar_contents_->set_delegate(this); | 44 sidebar_contents_->set_delegate(this); |
38 } | 45 } |
39 | 46 |
40 SidebarContainer::~SidebarContainer() { | 47 SidebarContainer::~SidebarContainer() { |
41 } | 48 } |
42 | 49 |
43 void SidebarContainer::SidebarClosing() { | 50 void SidebarContainer::SidebarClosing() { |
44 delegate_->UpdateSidebar(this); | 51 delegate_->UpdateSidebar(this); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 128 } |
122 | 129 |
123 const Extension* SidebarContainer::GetExtension() const { | 130 const Extension* SidebarContainer::GetExtension() const { |
124 ExtensionService* service = | 131 ExtensionService* service = |
125 sidebar_contents_->profile()->GetExtensionService(); | 132 sidebar_contents_->profile()->GetExtensionService(); |
126 if (!service) | 133 if (!service) |
127 return NULL; | 134 return NULL; |
128 return service->GetExtensionById( | 135 return service->GetExtensionById( |
129 extension_sidebar_utils::GetExtensionIdByContentId(content_id_), false); | 136 extension_sidebar_utils::GetExtensionIdByContentId(content_id_), false); |
130 } | 137 } |
OLD | NEW |