| 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" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 url_ = params.url; | 212 url_ = params.url; |
| 213 if (!url_.SchemeIs(chrome::kExtensionScheme)) { | 213 if (!url_.SchemeIs(chrome::kExtensionScheme)) { |
| 214 extension_function_dispatcher_.reset(NULL); | 214 extension_function_dispatcher_.reset(NULL); |
| 215 return; | 215 return; |
| 216 } | 216 } |
| 217 extension_function_dispatcher_.reset( | 217 extension_function_dispatcher_.reset( |
| 218 new ExtensionFunctionDispatcher(render_view_host_, this, url_)); | 218 new ExtensionFunctionDispatcher(render_view_host_, this, url_)); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void ExtensionHost::DidStopLoading(RenderViewHost* render_view_host) { | 221 void ExtensionHost::DidStopLoading(RenderViewHost* render_view_host) { |
| 222 static const StringPiece toolstrip_css( |
| 223 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 224 IDR_EXTENSIONS_TOOLSTRIP_CSS)); |
| 222 #if defined(TOOLKIT_VIEWS) | 225 #if defined(TOOLKIT_VIEWS) |
| 223 ExtensionView* view = view_.get(); | 226 ExtensionView* view = view_.get(); |
| 224 if (view) { | 227 if (view) { |
| 225 // TODO(erikkay) this injection should really happen in the renderer. | 228 // TODO(erikkay) this injection should really happen in the renderer. |
| 226 // When the Jerry's view type change lands, investigate moving this there. | 229 // When the Jerry's view type change lands, investigate moving this there. |
| 227 | 230 |
| 228 // As a toolstrip, inject our toolstrip CSS to make it easier for toolstrips | 231 // As a toolstrip, inject our toolstrip CSS to make it easier for toolstrips |
| 229 // to blend in with the chrome UI. | 232 // to blend in with the chrome UI. |
| 230 if (view->is_toolstrip()) { | 233 if (view->is_toolstrip()) { |
| 231 static const StringPiece toolstrip_css( | |
| 232 ResourceBundle::GetSharedInstance().GetRawDataResource( | |
| 233 IDR_EXTENSIONS_TOOLSTRIP_CSS)); | |
| 234 render_view_host->InsertCSSInWebFrame(L"", toolstrip_css.as_string()); | 234 render_view_host->InsertCSSInWebFrame(L"", toolstrip_css.as_string()); |
| 235 } else { | 235 } else { |
| 236 // No CSS injecting currently, but call SetDidInsertCSS to tell the view | 236 // No CSS injecting currently, but call SetDidInsertCSS to tell the view |
| 237 // that it's OK to display. | 237 // that it's OK to display. |
| 238 view->SetDidInsertCSS(true); | 238 view->SetDidInsertCSS(true); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 #elif defined(OS_LINUX) |
| 242 ExtensionViewGtk* view = view_.get(); |
| 243 if (view && view->is_toolstrip()) { |
| 244 render_view_host->InsertCSSInWebFrame(L"", toolstrip_css.as_string()); |
| 245 } |
| 241 #endif | 246 #endif |
| 242 | 247 |
| 243 did_stop_loading_ = true; | 248 did_stop_loading_ = true; |
| 244 } | 249 } |
| 245 | 250 |
| 246 void ExtensionHost::DocumentAvailableInMainFrame(RenderViewHost* rvh) { | 251 void ExtensionHost::DocumentAvailableInMainFrame(RenderViewHost* rvh) { |
| 247 document_element_available_ = true; | 252 document_element_available_ = true; |
| 248 if (is_background_page()) | 253 if (is_background_page()) |
| 249 extension_->SetBackgroundPageReady(); | 254 extension_->SetBackgroundPageReady(); |
| 250 } | 255 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 // a toolstrip or background_page onload chrome.tabs api call can make it | 380 // a toolstrip or background_page onload chrome.tabs api call can make it |
| 376 // into here before the browser is sufficiently initialized to return here. | 381 // into here before the browser is sufficiently initialized to return here. |
| 377 // A similar situation may arise during shutdown. | 382 // A similar situation may arise during shutdown. |
| 378 // TODO(rafaelw): Delay creation of background_page until the browser | 383 // TODO(rafaelw): Delay creation of background_page until the browser |
| 379 // is available. http://code.google.com/p/chromium/issues/detail?id=13284 | 384 // is available. http://code.google.com/p/chromium/issues/detail?id=13284 |
| 380 return browser; | 385 return browser; |
| 381 } | 386 } |
| 382 | 387 |
| 383 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { | 388 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { |
| 384 } | 389 } |
| OLD | NEW |