OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.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/file_version_info.h" | 9 #include "base/file_version_info.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 last_search_prepopulate_text_(NULL), | 252 last_search_prepopulate_text_(NULL), |
253 last_search_result_(), | 253 last_search_result_(), |
254 capturing_contents_(false), | 254 capturing_contents_(false), |
255 is_being_destroyed_(false), | 255 is_being_destroyed_(false), |
256 notify_disconnection_(false), | 256 notify_disconnection_(false), |
257 history_requests_(), | 257 history_requests_(), |
258 #if defined(OS_WIN) | 258 #if defined(OS_WIN) |
259 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), | 259 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), |
260 #endif | 260 #endif |
261 last_javascript_message_dismissal_(), | 261 last_javascript_message_dismissal_(), |
262 suppress_javascript_messages_(false) { | 262 suppress_javascript_messages_(false), |
| 263 opener_dom_ui_type_(DOMUIFactory::kNoDOMUI) { |
263 pending_install_.page_id = 0; | 264 pending_install_.page_id = 0; |
264 pending_install_.callback_functor = NULL; | 265 pending_install_.callback_functor = NULL; |
265 | 266 |
266 #if defined(OS_CHROMEOS) | 267 #if defined(OS_CHROMEOS) |
267 // Make sure the thumbnailer is started before starting the render manager. | 268 // Make sure the thumbnailer is started before starting the render manager. |
268 // The thumbnailer will want to listen for RVH creations, one of which will | 269 // The thumbnailer will want to listen for RVH creations, one of which will |
269 // happen in RVHManager::Init. | 270 // happen in RVHManager::Init. |
270 ThumbnailGenerator* generator = g_browser_process->GetThumbnailGenerator(); | 271 ThumbnailGenerator* generator = g_browser_process->GetThumbnailGenerator(); |
271 if (generator) | 272 if (generator) |
272 generator->StartThumbnailing(); | 273 generator->StartThumbnailing(); |
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 if (controller_.pending_entry() && | 1262 if (controller_.pending_entry() && |
1262 (controller_.GetLastCommittedEntry() || | 1263 (controller_.GetLastCommittedEntry() || |
1263 render_manager_.pending_dom_ui())) | 1264 render_manager_.pending_dom_ui())) |
1264 return render_manager_.pending_dom_ui(); | 1265 return render_manager_.pending_dom_ui(); |
1265 return render_manager_.dom_ui(); | 1266 return render_manager_.dom_ui(); |
1266 } | 1267 } |
1267 | 1268 |
1268 void TabContents::DidNavigateMainFramePostCommit( | 1269 void TabContents::DidNavigateMainFramePostCommit( |
1269 const NavigationController::LoadCommittedDetails& details, | 1270 const NavigationController::LoadCommittedDetails& details, |
1270 const ViewHostMsg_FrameNavigate_Params& params) { | 1271 const ViewHostMsg_FrameNavigate_Params& params) { |
| 1272 if (opener_dom_ui_type_ != DOMUIFactory::kNoDOMUI) { |
| 1273 // If this is a window.open navigation, use the same DOMUI as the renderer |
| 1274 // that opened the window, as long as both renderers have the same |
| 1275 // privileges. |
| 1276 if (opener_dom_ui_type_ == DOMUIFactory::GetDOMUIType(GetURL())) { |
| 1277 DOMUI* dom_ui = DOMUIFactory::CreateDOMUIForURL(this, GetURL()); |
| 1278 // dom_ui might be NULL if the URL refers to a non-existent extension. |
| 1279 if (dom_ui) { |
| 1280 render_manager_.SetDOMUIPostCommit(dom_ui); |
| 1281 dom_ui->RenderViewCreated(render_view_host()); |
| 1282 } |
| 1283 } |
| 1284 opener_dom_ui_type_ = DOMUIFactory::kNoDOMUI; |
| 1285 } |
| 1286 |
1271 if (details.is_user_initiated_main_frame_load()) { | 1287 if (details.is_user_initiated_main_frame_load()) { |
1272 // Clear the status bubble. This is a workaround for a bug where WebKit | 1288 // Clear the status bubble. This is a workaround for a bug where WebKit |
1273 // doesn't let us know that the cursor left an element during a | 1289 // doesn't let us know that the cursor left an element during a |
1274 // transition (this is also why the mouse cursor remains as a hand after | 1290 // transition (this is also why the mouse cursor remains as a hand after |
1275 // clicking on a link); see bugs 1184641 and 980803. We don't want to | 1291 // clicking on a link); see bugs 1184641 and 980803. We don't want to |
1276 // clear the bubble when a user navigates to a named anchor in the same | 1292 // clear the bubble when a user navigates to a named anchor in the same |
1277 // page. | 1293 // page. |
1278 UpdateTargetURL(details.entry->page_id(), GURL()); | 1294 UpdateTargetURL(details.entry->page_id(), GURL()); |
1279 | 1295 |
1280 // UpdateHelpersForDidNavigate will handle the case where the password_form | 1296 // UpdateHelpersForDidNavigate will handle the case where the password_form |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2101 | 2117 |
2102 void TabContents::DomOperationResponse(const std::string& json_string, | 2118 void TabContents::DomOperationResponse(const std::string& json_string, |
2103 int automation_id) { | 2119 int automation_id) { |
2104 } | 2120 } |
2105 | 2121 |
2106 void TabContents::ProcessDOMUIMessage(const std::string& message, | 2122 void TabContents::ProcessDOMUIMessage(const std::string& message, |
2107 const std::string& content, | 2123 const std::string& content, |
2108 int request_id, | 2124 int request_id, |
2109 bool has_callback) { | 2125 bool has_callback) { |
2110 if (!render_manager_.dom_ui()) { | 2126 if (!render_manager_.dom_ui()) { |
2111 // We shouldn't get a DOM UI message when we haven't enabled the DOM UI. | 2127 // This can happen if someone uses window.open() to open an extension URL |
2112 // Because the renderer might be owned and sending random messages, we need | 2128 // from a non-extension context. |
2113 // to ignore these inproper ones. | 2129 render_view_host()->BlockExtensionRequest(request_id); |
2114 NOTREACHED(); | |
2115 return; | 2130 return; |
2116 } | 2131 } |
2117 render_manager_.dom_ui()->ProcessDOMUIMessage(message, content, request_id, | 2132 render_manager_.dom_ui()->ProcessDOMUIMessage(message, content, request_id, |
2118 has_callback); | 2133 has_callback); |
2119 } | 2134 } |
2120 | 2135 |
2121 void TabContents::ProcessExternalHostMessage(const std::string& message, | 2136 void TabContents::ProcessExternalHostMessage(const std::string& message, |
2122 const std::string& origin, | 2137 const std::string& origin, |
2123 const std::string& target) { | 2138 const std::string& target) { |
2124 if (delegate()) | 2139 if (delegate()) |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2466 | 2481 |
2467 default: | 2482 default: |
2468 NOTREACHED(); | 2483 NOTREACHED(); |
2469 } | 2484 } |
2470 } | 2485 } |
2471 | 2486 |
2472 void TabContents::set_encoding(const std::wstring& encoding) { | 2487 void TabContents::set_encoding(const std::wstring& encoding) { |
2473 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); | 2488 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); |
2474 } | 2489 } |
2475 | 2490 |
OLD | NEW |