OLD | NEW |
1 // Copyright (c) 2010 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_host.h" | 5 #include "chrome/browser/extensions/extension_host.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/singleton.h" | 11 #include "base/singleton.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 205 |
206 void ExtensionHost::CreateRenderViewNow() { | 206 void ExtensionHost::CreateRenderViewNow() { |
207 render_view_host_->CreateRenderView(string16()); | 207 render_view_host_->CreateRenderView(string16()); |
208 NavigateToURL(url_); | 208 NavigateToURL(url_); |
209 DCHECK(IsRenderViewLive()); | 209 DCHECK(IsRenderViewLive()); |
210 if (is_background_page()) | 210 if (is_background_page()) |
211 profile_->GetExtensionService()->DidCreateRenderViewForBackgroundPage( | 211 profile_->GetExtensionService()->DidCreateRenderViewForBackgroundPage( |
212 this); | 212 this); |
213 } | 213 } |
214 | 214 |
215 Browser* ExtensionHost::GetBrowser() const { | 215 const Browser* ExtensionHost::GetBrowser() const { |
| 216 return view() ? view()->browser() : NULL; |
| 217 } |
| 218 |
| 219 Browser* ExtensionHost::GetBrowser() { |
216 return view() ? view()->browser() : NULL; | 220 return view() ? view()->browser() : NULL; |
217 } | 221 } |
218 | 222 |
219 gfx::NativeView ExtensionHost::GetNativeViewOfHost() { | 223 gfx::NativeView ExtensionHost::GetNativeViewOfHost() { |
220 return view() ? view()->native_view() : NULL; | 224 return view() ? view()->native_view() : NULL; |
221 } | 225 } |
222 | 226 |
223 void ExtensionHost::NavigateToURL(const GURL& url) { | 227 void ExtensionHost::NavigateToURL(const GURL& url) { |
224 // Prevent explicit navigation to another extension id's pages. | 228 // Prevent explicit navigation to another extension id's pages. |
225 // This method is only called by some APIs, so we still need to protect | 229 // This method is only called by some APIs, so we still need to protect |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 | 788 |
785 int ExtensionHost::GetBrowserWindowID() const { | 789 int ExtensionHost::GetBrowserWindowID() const { |
786 // Hosts not attached to any browser window have an id of -1. This includes | 790 // Hosts not attached to any browser window have an id of -1. This includes |
787 // those mentioned below, and background pages. | 791 // those mentioned below, and background pages. |
788 int window_id = extension_misc::kUnknownWindowId; | 792 int window_id = extension_misc::kUnknownWindowId; |
789 if (extension_host_type_ == ViewType::EXTENSION_POPUP || | 793 if (extension_host_type_ == ViewType::EXTENSION_POPUP || |
790 extension_host_type_ == ViewType::EXTENSION_INFOBAR) { | 794 extension_host_type_ == ViewType::EXTENSION_INFOBAR) { |
791 // If the host is bound to a browser, then extract its window id. | 795 // If the host is bound to a browser, then extract its window id. |
792 // Extensions hosted in ExternalTabContainer objects may not have | 796 // Extensions hosted in ExternalTabContainer objects may not have |
793 // an associated browser. | 797 // an associated browser. |
794 Browser* browser = GetBrowser(); | 798 const Browser* browser = GetBrowser(); |
795 if (browser) | 799 if (browser) |
796 window_id = ExtensionTabUtil::GetWindowId(browser); | 800 window_id = ExtensionTabUtil::GetWindowId(browser); |
797 } else if (extension_host_type_ != ViewType::EXTENSION_BACKGROUND_PAGE) { | 801 } else if (extension_host_type_ != ViewType::EXTENSION_BACKGROUND_PAGE) { |
798 NOTREACHED(); | 802 NOTREACHED(); |
799 } | 803 } |
800 return window_id; | 804 return window_id; |
801 } | 805 } |
OLD | NEW |