OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
24 #include "chrome/common/pref_service.h" | 24 #include "chrome/common/pref_service.h" |
25 | 25 |
26 #include "grit/browser_resources.h" | 26 #include "grit/browser_resources.h" |
27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
28 | 28 |
29 #include "webkit/glue/context_menu.h" | 29 #include "webkit/glue/context_menu.h" |
30 | 30 |
31 ExtensionHost::ExtensionHost(Extension* extension, SiteInstance* site_instance) | 31 ExtensionHost::ExtensionHost(Extension* extension, SiteInstance* site_instance) |
32 : extension_(extension), view_(NULL), did_stop_loading_(false) { | 32 : extension_(extension), |
| 33 #if defined(OS_WIN) |
| 34 view_(NULL), |
| 35 #endif |
| 36 did_stop_loading_(false) { |
33 render_view_host_ = new RenderViewHost( | 37 render_view_host_ = new RenderViewHost( |
34 site_instance, this, MSG_ROUTING_NONE, NULL); | 38 site_instance, this, MSG_ROUTING_NONE, NULL); |
35 render_view_host_->AllowExtensionBindings(); | 39 render_view_host_->AllowExtensionBindings(); |
36 } | 40 } |
37 | 41 |
38 ExtensionHost::~ExtensionHost() { | 42 ExtensionHost::~ExtensionHost() { |
39 render_view_host_->Shutdown(); // deletes render_view_host | 43 render_view_host_->Shutdown(); // deletes render_view_host |
40 } | 44 } |
41 | 45 |
42 SiteInstance* ExtensionHost::site_instance() const { | 46 SiteInstance* ExtensionHost::site_instance() const { |
43 return render_view_host_->site_instance(); | 47 return render_view_host_->site_instance(); |
44 } | 48 } |
45 | 49 |
46 void ExtensionHost::CreateRenderView(const GURL& url, | 50 void ExtensionHost::CreateRenderView(const GURL& url, |
47 RenderWidgetHostView* host_view) { | 51 RenderWidgetHostView* host_view) { |
48 url_ = url; | 52 url_ = url; |
49 render_view_host_->set_view(host_view); | 53 render_view_host_->set_view(host_view); |
50 render_view_host_->CreateRenderView(); | 54 render_view_host_->CreateRenderView(); |
51 render_view_host_->NavigateToURL(url); | 55 render_view_host_->NavigateToURL(url); |
52 } | 56 } |
53 | 57 |
54 void ExtensionHost::UpdatePreferredWidth(int pref_width) { | 58 void ExtensionHost::UpdatePreferredWidth(int pref_width) { |
| 59 #if defined(OS_WIN) |
55 if (view_) | 60 if (view_) |
56 view_->DidContentsPreferredWidthChange(pref_width); | 61 view_->DidContentsPreferredWidthChange(pref_width); |
| 62 #endif |
57 } | 63 } |
58 | 64 |
59 WebPreferences ExtensionHost::GetWebkitPrefs() { | 65 WebPreferences ExtensionHost::GetWebkitPrefs() { |
60 PrefService* prefs = render_view_host()->process()->profile()->GetPrefs(); | 66 PrefService* prefs = render_view_host()->process()->profile()->GetPrefs(); |
61 const bool kIsDomUI = true; | 67 const bool kIsDomUI = true; |
62 return RenderViewHostDelegateHelper::GetWebkitPrefs(prefs, kIsDomUI); | 68 return RenderViewHostDelegateHelper::GetWebkitPrefs(prefs, kIsDomUI); |
63 } | 69 } |
64 | 70 |
65 void ExtensionHost::RunJavaScriptMessage( | 71 void ExtensionHost::RunJavaScriptMessage( |
66 const std::wstring& message, | 72 const std::wstring& message, |
(...skipping 12 matching lines...) Expand all Loading... |
79 // TODO(aa): This is toolstrip-specific and should probably not be here. | 85 // TODO(aa): This is toolstrip-specific and should probably not be here. |
80 // ExtensionToolstrip in bookmark_bar_view.cc? | 86 // ExtensionToolstrip in bookmark_bar_view.cc? |
81 static const StringPiece toolstrip_css( | 87 static const StringPiece toolstrip_css( |
82 ResourceBundle::GetSharedInstance().GetRawDataResource( | 88 ResourceBundle::GetSharedInstance().GetRawDataResource( |
83 IDR_EXTENSIONS_TOOLSTRIP_CSS)); | 89 IDR_EXTENSIONS_TOOLSTRIP_CSS)); |
84 render_view_host->InsertCSSInWebFrame(L"", toolstrip_css.as_string()); | 90 render_view_host->InsertCSSInWebFrame(L"", toolstrip_css.as_string()); |
85 | 91 |
86 render_view_host->WasResized(); | 92 render_view_host->WasResized(); |
87 did_stop_loading_ = true; | 93 did_stop_loading_ = true; |
88 | 94 |
| 95 #if defined(OS_WIN) |
89 if (view_) | 96 if (view_) |
90 view_->ShowIfCompletelyLoaded(); | 97 view_->ShowIfCompletelyLoaded(); |
| 98 #endif |
91 } | 99 } |
92 | 100 |
93 ExtensionFunctionDispatcher* ExtensionHost:: | 101 ExtensionFunctionDispatcher* ExtensionHost:: |
94 CreateExtensionFunctionDispatcher(RenderViewHost *render_view_host, | 102 CreateExtensionFunctionDispatcher(RenderViewHost *render_view_host, |
95 const std::string& extension_id) { | 103 const std::string& extension_id) { |
96 return new ExtensionFunctionDispatcher(render_view_host, this, extension_id); | 104 return new ExtensionFunctionDispatcher(render_view_host, this, extension_id); |
97 } | 105 } |
98 | 106 |
99 RenderViewHostDelegate::View* ExtensionHost::GetViewDelegate() const { | 107 RenderViewHostDelegate::View* ExtensionHost::GetViewDelegate() const { |
100 // TODO(erikkay) this is unfortunate. The interface declares that this method | 108 // TODO(erikkay) this is unfortunate. The interface declares that this method |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 void ExtensionHost::UpdateDragCursor(bool is_drop_target) { | 159 void ExtensionHost::UpdateDragCursor(bool is_drop_target) { |
152 } | 160 } |
153 | 161 |
154 void ExtensionHost::TakeFocus(bool reverse) { | 162 void ExtensionHost::TakeFocus(bool reverse) { |
155 } | 163 } |
156 | 164 |
157 void ExtensionHost::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 165 void ExtensionHost::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
158 } | 166 } |
159 | 167 |
160 void ExtensionHost::HandleMouseEvent() { | 168 void ExtensionHost::HandleMouseEvent() { |
| 169 #if defined(OS_WIN) |
161 if (view_) | 170 if (view_) |
162 view_->HandleMouseEvent(); | 171 view_->HandleMouseEvent(); |
| 172 #endif |
163 } | 173 } |
164 | 174 |
165 void ExtensionHost::HandleMouseLeave() { | 175 void ExtensionHost::HandleMouseLeave() { |
| 176 #if defined(OS_WIN) |
166 if (view_) | 177 if (view_) |
167 view_->HandleMouseLeave(); | 178 view_->HandleMouseLeave(); |
| 179 #endif |
168 } | 180 } |
169 | 181 |
170 Browser* ExtensionHost::GetBrowser() { | 182 Browser* ExtensionHost::GetBrowser() { |
| 183 #if defined(OS_WIN) |
171 if (view_) | 184 if (view_) |
172 return view_->browser(); | 185 return view_->browser(); |
| 186 #endif |
173 Browser* browser = BrowserList::GetLastActiveWithProfile( | 187 Browser* browser = BrowserList::GetLastActiveWithProfile( |
174 render_view_host()->process()->profile()); | 188 render_view_host()->process()->profile()); |
175 // TODO(mpcomplete): what this verifies doesn't actually happen yet. | 189 // TODO(mpcomplete): what this verifies doesn't actually happen yet. |
176 CHECK(browser) << "ExtensionHost running in Profile with no Browser active." | 190 CHECK(browser) << "ExtensionHost running in Profile with no Browser active." |
177 " It should have been deleted."; | 191 " It should have been deleted."; |
178 return browser; | 192 return browser; |
179 } | 193 } |
OLD | NEW |