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/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
11 #include "chrome/browser/browser_list.h" | 11 #include "chrome/browser/browser_list.h" |
12 #include "chrome/browser/debugger/devtools_manager.h" | 12 #include "chrome/browser/debugger/devtools_manager.h" |
13 #include "chrome/browser/extensions/extension_message_service.h" | 13 #include "chrome/browser/extensions/extension_message_service.h" |
14 #include "chrome/browser/profile.h" | 14 #include "chrome/browser/profile.h" |
15 #include "chrome/browser/renderer_host/render_view_host.h" | 15 #include "chrome/browser/renderer_host/render_view_host.h" |
16 #include "chrome/browser/renderer_host/render_process_host.h" | 16 #include "chrome/browser/renderer_host/render_process_host.h" |
17 #include "chrome/browser/renderer_host/render_widget_host.h" | 17 #include "chrome/browser/renderer_host/render_widget_host.h" |
18 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 18 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
19 #include "chrome/browser/renderer_host/site_instance.h" | 19 #include "chrome/browser/renderer_host/site_instance.h" |
20 #include "chrome/browser/tab_contents/infobar_delegate.h" | 20 #include "chrome/browser/tab_contents/infobar_delegate.h" |
21 #include "chrome/browser/tab_contents/tab_contents.h" | 21 #include "chrome/browser/tab_contents/tab_contents.h" |
22 #include "chrome/browser/tab_contents/tab_contents_view.h" | 22 #include "chrome/browser/tab_contents/tab_contents_view.h" |
23 #include "chrome/common/bindings_policy.h" | 23 #include "chrome/common/bindings_policy.h" |
24 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
25 #include "chrome/common/notification_service.h" | 25 #include "chrome/common/notification_service.h" |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "chrome/common/pref_service.h" | 27 #include "chrome/common/pref_service.h" |
28 #include "chrome/common/render_messages.h" | 28 #include "chrome/common/render_messages.h" |
| 29 #include "chrome/common/url_constants.h" |
29 | 30 |
30 #include "grit/browser_resources.h" | 31 #include "grit/browser_resources.h" |
31 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
32 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
33 | 34 |
34 #include "webkit/glue/context_menu.h" | 35 #include "webkit/glue/context_menu.h" |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 class CrashedExtensionInfobarDelegate : public ConfirmInfoBarDelegate { | 39 class CrashedExtensionInfobarDelegate : public ConfirmInfoBarDelegate { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 void ExtensionHost::DidNavigate(RenderViewHost* render_view_host, | 187 void ExtensionHost::DidNavigate(RenderViewHost* render_view_host, |
187 const ViewHostMsg_FrameNavigate_Params& params) { | 188 const ViewHostMsg_FrameNavigate_Params& params) { |
188 // We only care when the outer frame changes. | 189 // We only care when the outer frame changes. |
189 switch (params.transition) { | 190 switch (params.transition) { |
190 case PageTransition::AUTO_SUBFRAME: | 191 case PageTransition::AUTO_SUBFRAME: |
191 case PageTransition::MANUAL_SUBFRAME: | 192 case PageTransition::MANUAL_SUBFRAME: |
192 return; | 193 return; |
193 } | 194 } |
194 | 195 |
195 url_ = params.url; | 196 url_ = params.url; |
| 197 if (!url_.SchemeIs(chrome::kExtensionScheme)) { |
| 198 extension_function_dispatcher_.reset(NULL); |
| 199 return; |
| 200 } |
196 extension_function_dispatcher_.reset( | 201 extension_function_dispatcher_.reset( |
197 new ExtensionFunctionDispatcher(render_view_host_, this, url_)); | 202 new ExtensionFunctionDispatcher(render_view_host_, this, url_)); |
198 } | 203 } |
199 | 204 |
200 void ExtensionHost::DidStopLoading(RenderViewHost* render_view_host) { | 205 void ExtensionHost::DidStopLoading(RenderViewHost* render_view_host) { |
201 #if defined(TOOLKIT_VIEWS) | 206 #if defined(TOOLKIT_VIEWS) |
202 ExtensionView* view = view_.get(); | 207 ExtensionView* view = view_.get(); |
203 if (view) { | 208 if (view) { |
204 // TODO(erikkay) this injection should really happen in the renderer. | 209 // TODO(erikkay) this injection should really happen in the renderer. |
205 // When the Jerry's view type change lands, investigate moving this there. | 210 // When the Jerry's view type change lands, investigate moving this there. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 WebPreferences ExtensionHost::GetWebkitPrefs() { | 242 WebPreferences ExtensionHost::GetWebkitPrefs() { |
238 PrefService* prefs = render_view_host()->process()->profile()->GetPrefs(); | 243 PrefService* prefs = render_view_host()->process()->profile()->GetPrefs(); |
239 const bool kIsDomUI = true; | 244 const bool kIsDomUI = true; |
240 return RenderViewHostDelegateHelper::GetWebkitPrefs(prefs, kIsDomUI); | 245 return RenderViewHostDelegateHelper::GetWebkitPrefs(prefs, kIsDomUI); |
241 } | 246 } |
242 | 247 |
243 void ExtensionHost::ProcessDOMUIMessage(const std::string& message, | 248 void ExtensionHost::ProcessDOMUIMessage(const std::string& message, |
244 const std::string& content, | 249 const std::string& content, |
245 int request_id, | 250 int request_id, |
246 bool has_callback) { | 251 bool has_callback) { |
247 extension_function_dispatcher_->HandleRequest(message, content, request_id, | 252 if (extension_function_dispatcher_.get()) { |
248 has_callback); | 253 extension_function_dispatcher_->HandleRequest(message, content, request_id, |
| 254 has_callback); |
| 255 } |
249 } | 256 } |
250 | 257 |
251 void ExtensionHost::DidInsertCSS() { | 258 void ExtensionHost::DidInsertCSS() { |
252 #if defined(TOOLKIT_VIEWS) | 259 #if defined(TOOLKIT_VIEWS) |
253 if (view_.get()) | 260 if (view_.get()) |
254 view_->SetDidInsertCSS(true); | 261 view_->SetDidInsertCSS(true); |
255 #endif | 262 #endif |
256 } | 263 } |
257 | 264 |
258 RenderViewHostDelegate::View* ExtensionHost::GetViewDelegate() { | 265 RenderViewHostDelegate::View* ExtensionHost::GetViewDelegate() { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 // a toolstrip or background_page onload chrome.tabs api call can make it | 353 // a toolstrip or background_page onload chrome.tabs api call can make it |
347 // into here before the browser is sufficiently initialized to return here. | 354 // into here before the browser is sufficiently initialized to return here. |
348 // A similar situation may arise during shutdown. | 355 // A similar situation may arise during shutdown. |
349 // TODO(rafaelw): Delay creation of background_page until the browser | 356 // TODO(rafaelw): Delay creation of background_page until the browser |
350 // is available. http://code.google.com/p/chromium/issues/detail?id=13284 | 357 // is available. http://code.google.com/p/chromium/issues/detail?id=13284 |
351 return browser; | 358 return browser; |
352 } | 359 } |
353 | 360 |
354 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { | 361 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { |
355 } | 362 } |
OLD | NEW |