Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: chrome/browser/extensions/api/web_navigation/web_navigation_api.cc

Issue 10805066: Pass the render process id to the FrameNavigationState. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Implements the Chrome Extensions WebNavigation API. 5 // Implements the Chrome Extensions WebNavigation API.
6 6
7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" 7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta nts.h" 10 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta nts.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 if (!tab_observer) { 172 if (!tab_observer) {
173 // If you hit this DCHECK(), please add reproduction steps to 173 // If you hit this DCHECK(), please add reproduction steps to
174 // http://crbug.com/109464. 174 // http://crbug.com/109464.
175 DCHECK(chrome::GetViewType(details->source_web_contents) != 175 DCHECK(chrome::GetViewType(details->source_web_contents) !=
176 chrome::VIEW_TYPE_TAB_CONTENTS); 176 chrome::VIEW_TYPE_TAB_CONTENTS);
177 return; 177 return;
178 } 178 }
179 const FrameNavigationState& frame_navigation_state = 179 const FrameNavigationState& frame_navigation_state =
180 tab_observer->frame_navigation_state(); 180 tab_observer->frame_navigation_state();
181 181
182 if (!frame_navigation_state.CanSendEvents(details->source_frame_id)) 182 FrameNavigationState::FrameID frame_id(
183 details->source_frame_id,
184 details->source_web_contents->GetRenderViewHost()->GetProcess()->GetID());
185 if (!frame_navigation_state.CanSendEvents(frame_id))
183 return; 186 return;
184 187
185 // If the WebContents was created as a response to an IPC from a renderer 188 // If the WebContents was created as a response to an IPC from a renderer
186 // (and therefore doesn't yet have a TabContents), or if it isn't yet inserted 189 // (and therefore doesn't yet have a TabContents), or if it isn't yet inserted
187 // into a tab strip, we need to delay the extension event until the 190 // into a tab strip, we need to delay the extension event until the
188 // WebContents is fully initialized. 191 // WebContents is fully initialized.
189 if (TabContents::FromWebContents(details->target_web_contents) == NULL || 192 if (TabContents::FromWebContents(details->target_web_contents) == NULL ||
190 details->not_yet_in_tabstrip) { 193 details->not_yet_in_tabstrip) {
191 pending_web_contents_[details->target_web_contents] = 194 pending_web_contents_[details->target_web_contents] =
192 PendingWebContents( 195 PendingWebContents(
193 details->source_web_contents, 196 details->source_web_contents,
194 details->source_frame_id, 197 details->source_frame_id,
195 frame_navigation_state.IsMainFrame(details->source_frame_id), 198 frame_navigation_state.IsMainFrame(frame_id),
196 details->target_web_contents, 199 details->target_web_contents,
197 details->target_url); 200 details->target_url);
198 } else { 201 } else {
199 helpers::DispatchOnCreatedNavigationTarget( 202 helpers::DispatchOnCreatedNavigationTarget(
200 details->source_web_contents, 203 details->source_web_contents,
201 details->target_web_contents->GetBrowserContext(), 204 details->target_web_contents->GetBrowserContext(),
202 details->source_frame_id, 205 details->source_frame_id,
203 frame_navigation_state.IsMainFrame(details->source_frame_id), 206 frame_navigation_state.IsMainFrame(frame_id),
204 details->target_web_contents, 207 details->target_web_contents,
205 details->target_url); 208 details->target_url);
206 } 209 }
207 } 210 }
208 211
209 void WebNavigationEventRouter::TabAdded(content::WebContents* tab) { 212 void WebNavigationEventRouter::TabAdded(content::WebContents* tab) {
210 std::map<content::WebContents*, PendingWebContents>::iterator iter = 213 std::map<content::WebContents*, PendingWebContents>::iterator iter =
211 pending_web_contents_.find(tab); 214 pending_web_contents_.find(tab);
212 if (iter == pending_web_contents_.end()) 215 if (iter == pending_web_contents_.end())
213 return; 216 return;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 const content::NotificationSource& source, 263 const content::NotificationSource& source,
261 const content::NotificationDetails& details) { 264 const content::NotificationDetails& details) {
262 switch (type) { 265 switch (type) {
263 case content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: { 266 case content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: {
264 content::ResourceRedirectDetails* resource_redirect_details = 267 content::ResourceRedirectDetails* resource_redirect_details =
265 content::Details<content::ResourceRedirectDetails>(details).ptr(); 268 content::Details<content::ResourceRedirectDetails>(details).ptr();
266 ResourceType::Type resource_type = 269 ResourceType::Type resource_type =
267 resource_redirect_details->resource_type; 270 resource_redirect_details->resource_type;
268 if (resource_type == ResourceType::MAIN_FRAME || 271 if (resource_type == ResourceType::MAIN_FRAME ||
269 resource_type == ResourceType::SUB_FRAME) { 272 resource_type == ResourceType::SUB_FRAME) {
270 int64 frame_id = resource_redirect_details->frame_id; 273 FrameNavigationState::FrameID frame_id(
274 resource_redirect_details->frame_id,
275 resource_redirect_details->origin_child_id);
271 if (!navigation_state_.CanSendEvents(frame_id)) 276 if (!navigation_state_.CanSendEvents(frame_id))
272 return; 277 return;
273 navigation_state_.SetIsServerRedirected(frame_id); 278 navigation_state_.SetIsServerRedirected(frame_id);
274 } 279 }
275 break; 280 break;
276 } 281 }
277 282
278 default: 283 default:
279 NOTREACHED(); 284 NOTREACHED();
280 } 285 }
281 } 286 }
282 287
283 void WebNavigationTabObserver::AboutToNavigateRenderView( 288 void WebNavigationTabObserver::AboutToNavigateRenderView(
284 content::RenderViewHost* render_view_host) { 289 content::RenderViewHost* render_view_host) {
285 if (!render_view_host_) { 290 if (!render_view_host_) {
286 render_view_host_ = render_view_host; 291 render_view_host_ = render_view_host;
287 } else if (render_view_host != render_view_host_) { 292 } else if (render_view_host != render_view_host_) {
288 // TODO(jochen): If pending_render_view_host_ is non-NULL, send error events 293 // TODO(jochen): If pending_render_view_host_ is non-NULL, send error events
289 // for all ongoing navigations in that RVH. 294 // for all ongoing navigations in that RVH.
290 pending_render_view_host_ = render_view_host; 295 pending_render_view_host_ = render_view_host;
291 } 296 }
292 } 297 }
293 298
294 void WebNavigationTabObserver::DidStartProvisionalLoadForFrame( 299 void WebNavigationTabObserver::DidStartProvisionalLoadForFrame(
295 int64 frame_id, 300 int64 frame_num,
296 bool is_main_frame, 301 bool is_main_frame,
297 const GURL& validated_url, 302 const GURL& validated_url,
298 bool is_error_page, 303 bool is_error_page,
299 content::RenderViewHost* render_view_host) { 304 content::RenderViewHost* render_view_host) {
300 if (!render_view_host_) 305 if (!render_view_host_)
301 render_view_host_ = render_view_host; 306 render_view_host_ = render_view_host;
302 if (render_view_host != render_view_host_ && 307 if (render_view_host != render_view_host_ &&
303 render_view_host != pending_render_view_host_) 308 render_view_host != pending_render_view_host_)
304 return; 309 return;
305 310
311 FrameNavigationState::FrameID frame_id(
312 frame_num, render_view_host->GetProcess()->GetID());
313
306 navigation_state_.TrackFrame(frame_id, 314 navigation_state_.TrackFrame(frame_id,
307 validated_url, 315 validated_url,
308 is_main_frame, 316 is_main_frame,
309 is_error_page); 317 is_error_page);
310 if (!navigation_state_.CanSendEvents(frame_id)) 318 if (!navigation_state_.CanSendEvents(frame_id))
311 return; 319 return;
312 320
313 helpers::DispatchOnBeforeNavigate( 321 helpers::DispatchOnBeforeNavigate(
314 web_contents(), render_view_host->GetProcess()->GetID(), frame_id, 322 web_contents(), render_view_host->GetProcess()->GetID(), frame_num,
315 is_main_frame, validated_url); 323 is_main_frame, validated_url);
316 } 324 }
317 325
318 void WebNavigationTabObserver::DidCommitProvisionalLoadForFrame( 326 void WebNavigationTabObserver::DidCommitProvisionalLoadForFrame(
319 int64 frame_id, 327 int64 frame_num,
320 bool is_main_frame, 328 bool is_main_frame,
321 const GURL& url, 329 const GURL& url,
322 content::PageTransition transition_type, 330 content::PageTransition transition_type,
323 content::RenderViewHost* render_view_host) { 331 content::RenderViewHost* render_view_host) {
324 if (render_view_host != render_view_host_ && 332 if (render_view_host != render_view_host_ &&
325 render_view_host != pending_render_view_host_) 333 render_view_host != pending_render_view_host_)
326 return; 334 return;
327 // TODO(jochen): If we switched the RVH, send error events for all ongoing 335 // TODO(jochen): If we switched the RVH, send error events for all ongoing
328 // navigations in the old RVH. 336 // navigations in the old RVH.
329 render_view_host_ = render_view_host; 337 render_view_host_ = render_view_host;
330 pending_render_view_host_ = NULL; 338 pending_render_view_host_ = NULL;
331 339
340 FrameNavigationState::FrameID frame_id(
341 frame_num, render_view_host->GetProcess()->GetID());
332 if (!navigation_state_.CanSendEvents(frame_id)) 342 if (!navigation_state_.CanSendEvents(frame_id))
333 return; 343 return;
334 344
335 bool is_reference_fragment_navigation = 345 bool is_reference_fragment_navigation =
336 IsReferenceFragmentNavigation(frame_id, url); 346 IsReferenceFragmentNavigation(frame_id, url);
337 bool is_history_navigation = 347 bool is_history_navigation =
338 navigation_state_.GetNavigationCommitted(frame_id); 348 navigation_state_.GetNavigationCommitted(frame_id);
339 349
340 // Update the URL as it might have changed. 350 // Update the URL as it might have changed.
341 navigation_state_.UpdateFrame(frame_id, url); 351 navigation_state_.UpdateFrame(frame_id, url);
342 navigation_state_.SetNavigationCommitted(frame_id); 352 navigation_state_.SetNavigationCommitted(frame_id);
343 353
344 if (is_reference_fragment_navigation) { 354 if (is_reference_fragment_navigation) {
345 helpers::DispatchOnCommitted( 355 helpers::DispatchOnCommitted(
346 keys::kOnReferenceFragmentUpdated, 356 keys::kOnReferenceFragmentUpdated,
347 web_contents(), 357 web_contents(),
348 frame_id, 358 frame_num,
349 is_main_frame, 359 is_main_frame,
350 url, 360 url,
351 transition_type); 361 transition_type);
352 navigation_state_.SetNavigationCompleted(frame_id); 362 navigation_state_.SetNavigationCompleted(frame_id);
353 } else if (is_history_navigation) { 363 } else if (is_history_navigation) {
354 // Make the transition type match the one for reference fragment updates. 364 // Make the transition type match the one for reference fragment updates.
355 transition_type = static_cast<content::PageTransition>( 365 transition_type = static_cast<content::PageTransition>(
356 transition_type | content::PAGE_TRANSITION_CLIENT_REDIRECT); 366 transition_type | content::PAGE_TRANSITION_CLIENT_REDIRECT);
357 helpers::DispatchOnCommitted( 367 helpers::DispatchOnCommitted(
358 keys::kOnHistoryStateUpdated, 368 keys::kOnHistoryStateUpdated,
359 web_contents(), 369 web_contents(),
360 frame_id, 370 frame_num,
361 is_main_frame, 371 is_main_frame,
362 url, 372 url,
363 transition_type); 373 transition_type);
364 navigation_state_.SetNavigationCompleted(frame_id); 374 navigation_state_.SetNavigationCompleted(frame_id);
365 } else { 375 } else {
366 if (navigation_state_.GetIsServerRedirected(frame_id)) { 376 if (navigation_state_.GetIsServerRedirected(frame_id)) {
367 transition_type = static_cast<content::PageTransition>( 377 transition_type = static_cast<content::PageTransition>(
368 transition_type | content::PAGE_TRANSITION_SERVER_REDIRECT); 378 transition_type | content::PAGE_TRANSITION_SERVER_REDIRECT);
369 } 379 }
370 helpers::DispatchOnCommitted( 380 helpers::DispatchOnCommitted(
371 keys::kOnCommitted, 381 keys::kOnCommitted,
372 web_contents(), 382 web_contents(),
373 frame_id, 383 frame_num,
374 is_main_frame, 384 is_main_frame,
375 url, 385 url,
376 transition_type); 386 transition_type);
377 } 387 }
378 } 388 }
379 389
380 void WebNavigationTabObserver::DidFailProvisionalLoad( 390 void WebNavigationTabObserver::DidFailProvisionalLoad(
381 int64 frame_id, 391 int64 frame_num,
382 bool is_main_frame, 392 bool is_main_frame,
383 const GURL& validated_url, 393 const GURL& validated_url,
384 int error_code, 394 int error_code,
385 const string16& error_description, 395 const string16& error_description,
386 content::RenderViewHost* render_view_host) { 396 content::RenderViewHost* render_view_host) {
387 if (render_view_host != render_view_host_ && 397 if (render_view_host != render_view_host_ &&
388 render_view_host != pending_render_view_host_) 398 render_view_host != pending_render_view_host_)
389 return; 399 return;
390 if (render_view_host == pending_render_view_host_) 400 if (render_view_host == pending_render_view_host_)
391 pending_render_view_host_ = NULL; 401 pending_render_view_host_ = NULL;
392 402
403 FrameNavigationState::FrameID frame_id(
404 frame_num, render_view_host->GetProcess()->GetID());
393 if (!navigation_state_.CanSendEvents(frame_id)) 405 if (!navigation_state_.CanSendEvents(frame_id))
394 return; 406 return;
395 407
396 navigation_state_.SetErrorOccurredInFrame(frame_id); 408 navigation_state_.SetErrorOccurredInFrame(frame_id);
397 helpers::DispatchOnErrorOccurred( 409 helpers::DispatchOnErrorOccurred(
398 web_contents(), render_view_host->GetProcess()->GetID(), validated_url, 410 web_contents(), render_view_host->GetProcess()->GetID(), validated_url,
399 frame_id, is_main_frame, error_code); 411 frame_num, is_main_frame, error_code);
400 } 412 }
401 413
402 void WebNavigationTabObserver::DocumentLoadedInFrame( 414 void WebNavigationTabObserver::DocumentLoadedInFrame(
403 int64 frame_id, 415 int64 frame_num,
404 content::RenderViewHost* render_view_host) { 416 content::RenderViewHost* render_view_host) {
405 if (render_view_host != render_view_host_) 417 if (render_view_host != render_view_host_)
406 return; 418 return;
419 FrameNavigationState::FrameID frame_id(
420 frame_num, render_view_host->GetProcess()->GetID());
407 if (!navigation_state_.CanSendEvents(frame_id)) 421 if (!navigation_state_.CanSendEvents(frame_id))
408 return; 422 return;
409 helpers::DispatchOnDOMContentLoaded(web_contents(), 423 helpers::DispatchOnDOMContentLoaded(web_contents(),
410 navigation_state_.GetUrl(frame_id), 424 navigation_state_.GetUrl(frame_id),
411 navigation_state_.IsMainFrame(frame_id), 425 navigation_state_.IsMainFrame(frame_id),
412 frame_id); 426 frame_num);
413 } 427 }
414 428
415 void WebNavigationTabObserver::DidFinishLoad( 429 void WebNavigationTabObserver::DidFinishLoad(
416 int64 frame_id, 430 int64 frame_num,
417 const GURL& validated_url, 431 const GURL& validated_url,
418 bool is_main_frame, 432 bool is_main_frame,
419 content::RenderViewHost* render_view_host) { 433 content::RenderViewHost* render_view_host) {
420 if (render_view_host != render_view_host_) 434 if (render_view_host != render_view_host_)
421 return; 435 return;
436 FrameNavigationState::FrameID frame_id(
437 frame_num, render_view_host->GetProcess()->GetID());
422 if (!navigation_state_.CanSendEvents(frame_id)) 438 if (!navigation_state_.CanSendEvents(frame_id))
423 return; 439 return;
424 navigation_state_.SetNavigationCompleted(frame_id); 440 navigation_state_.SetNavigationCompleted(frame_id);
425 DCHECK_EQ(navigation_state_.GetUrl(frame_id), validated_url); 441 DCHECK_EQ(navigation_state_.GetUrl(frame_id), validated_url);
426 DCHECK_EQ(navigation_state_.IsMainFrame(frame_id), is_main_frame); 442 DCHECK_EQ(navigation_state_.IsMainFrame(frame_id), is_main_frame);
427 helpers::DispatchOnCompleted(web_contents(), 443 helpers::DispatchOnCompleted(web_contents(),
428 validated_url, 444 validated_url,
429 is_main_frame, 445 is_main_frame,
430 frame_id); 446 frame_num);
431 } 447 }
432 448
433 void WebNavigationTabObserver::DidFailLoad( 449 void WebNavigationTabObserver::DidFailLoad(
434 int64 frame_id, 450 int64 frame_num,
435 const GURL& validated_url, 451 const GURL& validated_url,
436 bool is_main_frame, 452 bool is_main_frame,
437 int error_code, 453 int error_code,
438 const string16& error_description, 454 const string16& error_description,
439 content::RenderViewHost* render_view_host) { 455 content::RenderViewHost* render_view_host) {
440 if (render_view_host != render_view_host_) 456 if (render_view_host != render_view_host_)
441 return; 457 return;
458 FrameNavigationState::FrameID frame_id(
459 frame_num, render_view_host->GetProcess()->GetID());
442 if (!navigation_state_.CanSendEvents(frame_id)) 460 if (!navigation_state_.CanSendEvents(frame_id))
443 return; 461 return;
444 navigation_state_.SetErrorOccurredInFrame(frame_id); 462 navigation_state_.SetErrorOccurredInFrame(frame_id);
445 helpers::DispatchOnErrorOccurred( 463 helpers::DispatchOnErrorOccurred(
446 web_contents(), render_view_host->GetProcess()->GetID(), validated_url, 464 web_contents(), render_view_host->GetProcess()->GetID(), validated_url,
447 frame_id, is_main_frame, error_code); 465 frame_num, is_main_frame, error_code);
448 } 466 }
449 467
450 void WebNavigationTabObserver::DidOpenRequestedURL( 468 void WebNavigationTabObserver::DidOpenRequestedURL(
451 content::WebContents* new_contents, 469 content::WebContents* new_contents,
452 const GURL& url, 470 const GURL& url,
453 const content::Referrer& referrer, 471 const content::Referrer& referrer,
454 WindowOpenDisposition disposition, 472 WindowOpenDisposition disposition,
455 content::PageTransition transition, 473 content::PageTransition transition,
456 int64 source_frame_id) { 474 int64 source_frame_num) {
457 if (!navigation_state_.CanSendEvents(source_frame_id)) 475 FrameNavigationState::FrameID frame_id(
476 source_frame_num, render_view_host_->GetProcess()->GetID());
477 if (!navigation_state_.CanSendEvents(frame_id))
458 return; 478 return;
459 479
460 // We only send the onCreatedNavigationTarget if we end up creating a new 480 // We only send the onCreatedNavigationTarget if we end up creating a new
461 // window. 481 // window.
462 if (disposition != SINGLETON_TAB && 482 if (disposition != SINGLETON_TAB &&
463 disposition != NEW_FOREGROUND_TAB && 483 disposition != NEW_FOREGROUND_TAB &&
464 disposition != NEW_BACKGROUND_TAB && 484 disposition != NEW_BACKGROUND_TAB &&
465 disposition != NEW_POPUP && 485 disposition != NEW_POPUP &&
466 disposition != NEW_WINDOW && 486 disposition != NEW_WINDOW &&
467 disposition != OFF_THE_RECORD) 487 disposition != OFF_THE_RECORD)
468 return; 488 return;
469 489
470 helpers::DispatchOnCreatedNavigationTarget( 490 helpers::DispatchOnCreatedNavigationTarget(
471 web_contents(), 491 web_contents(),
472 new_contents->GetBrowserContext(), 492 new_contents->GetBrowserContext(),
473 source_frame_id, 493 source_frame_num,
474 navigation_state_.IsMainFrame(source_frame_id), 494 navigation_state_.IsMainFrame(frame_id),
475 new_contents, 495 new_contents,
476 url); 496 url);
477 } 497 }
478 498
479 void WebNavigationTabObserver::WebContentsDestroyed(content::WebContents* tab) { 499 void WebNavigationTabObserver::WebContentsDestroyed(content::WebContents* tab) {
480 g_tab_observer.Get().erase(tab); 500 g_tab_observer.Get().erase(tab);
481 for (FrameNavigationState::const_iterator frame = navigation_state_.begin(); 501 for (FrameNavigationState::const_iterator frame = navigation_state_.begin();
482 frame != navigation_state_.end(); ++frame) { 502 frame != navigation_state_.end(); ++frame) {
483 if (!navigation_state_.GetNavigationCompleted(*frame) && 503 if (!navigation_state_.GetNavigationCompleted(*frame) &&
484 navigation_state_.CanSendEvents(*frame)) { 504 navigation_state_.CanSendEvents(*frame)) {
485 helpers::DispatchOnErrorOccurred( 505 helpers::DispatchOnErrorOccurred(
486 tab, 506 tab,
487 tab->GetRenderViewHost()->GetProcess()->GetID(), 507 frame->render_process_id,
488 navigation_state_.GetUrl(*frame), 508 navigation_state_.GetUrl(*frame),
489 *frame, 509 frame->frame_num,
490 navigation_state_.IsMainFrame(*frame), 510 navigation_state_.IsMainFrame(*frame),
491 net::ERR_ABORTED); 511 net::ERR_ABORTED);
492 } 512 }
493 } 513 }
494 } 514 }
495 515
496 // See also NavigationController::IsURLInPageNavigation. 516 // See also NavigationController::IsURLInPageNavigation.
497 bool WebNavigationTabObserver::IsReferenceFragmentNavigation( 517 bool WebNavigationTabObserver::IsReferenceFragmentNavigation(
498 int64 frame_id, 518 FrameNavigationState::FrameID frame_id,
499 const GURL& url) { 519 const GURL& url) {
500 GURL existing_url = navigation_state_.GetUrl(frame_id); 520 GURL existing_url = navigation_state_.GetUrl(frame_id);
501 if (existing_url == url) 521 if (existing_url == url)
502 return false; 522 return false;
503 523
504 url_canon::Replacements<char> replacements; 524 url_canon::Replacements<char> replacements;
505 replacements.ClearRef(); 525 replacements.ClearRef();
506 return existing_url.ReplaceComponents(replacements) == 526 return existing_url.ReplaceComponents(replacements) ==
507 url.ReplaceComponents(replacements); 527 url.ReplaceComponents(replacements);
508 } 528 }
509 529
510 bool GetFrameFunction::RunImpl() { 530 bool GetFrameFunction::RunImpl() {
511 scoped_ptr<GetFrame::Params> params(GetFrame::Params::Create(*args_)); 531 scoped_ptr<GetFrame::Params> params(GetFrame::Params::Create(*args_));
512 EXTENSION_FUNCTION_VALIDATE(params.get()); 532 EXTENSION_FUNCTION_VALIDATE(params.get());
513 int tab_id = params->details.tab_id; 533 int tab_id = params->details.tab_id;
514 int frame_id = params->details.frame_id; 534 int frame_id = params->details.frame_id;
535 int process_id = params->details.process_id;
515 536
516 SetResult(Value::CreateNullValue()); 537 SetResult(Value::CreateNullValue());
517 538
518 TabContents* tab_contents; 539 TabContents* tab_contents;
519 if (!ExtensionTabUtil::GetTabById(tab_id, 540 if (!ExtensionTabUtil::GetTabById(tab_id,
520 profile(), 541 profile(),
521 include_incognito(), 542 include_incognito(),
522 NULL, NULL, 543 NULL, NULL,
523 &tab_contents, 544 &tab_contents,
524 NULL) || 545 NULL) ||
525 !tab_contents) { 546 !tab_contents) {
526 return true; 547 return true;
527 } 548 }
528 549
529 content::WebContents* web_contents = tab_contents->web_contents(); 550 content::WebContents* web_contents = tab_contents->web_contents();
530 WebNavigationTabObserver* observer = 551 WebNavigationTabObserver* observer =
531 WebNavigationTabObserver::Get(web_contents); 552 WebNavigationTabObserver::Get(web_contents);
532 DCHECK(observer); 553 DCHECK(observer);
533 554
534 const FrameNavigationState& frame_navigation_state = 555 const FrameNavigationState& frame_navigation_state =
535 observer->frame_navigation_state(); 556 observer->frame_navigation_state();
536 557
537 if (frame_id == 0) 558 if (frame_id == 0)
538 frame_id = frame_navigation_state.GetMainFrameID(); 559 frame_id = frame_navigation_state.GetMainFrameID().frame_num;
539 if (!frame_navigation_state.IsValidFrame(frame_id)) 560
561 FrameNavigationState::FrameID internal_frame_id(frame_id, process_id);
562 if (!frame_navigation_state.IsValidFrame(internal_frame_id))
540 return true; 563 return true;
541 564
542 GURL frame_url = frame_navigation_state.GetUrl(frame_id); 565 GURL frame_url = frame_navigation_state.GetUrl(internal_frame_id);
543 if (!frame_navigation_state.IsValidUrl(frame_url)) 566 if (!frame_navigation_state.IsValidUrl(frame_url))
544 return true; 567 return true;
545 568
546 GetFrame::Results::Details frame_details; 569 GetFrame::Results::Details frame_details;
547 frame_details.url = frame_url.spec(); 570 frame_details.url = frame_url.spec();
548 frame_details.error_occurred = 571 frame_details.error_occurred =
549 frame_navigation_state.GetErrorOccurredInFrame(frame_id); 572 frame_navigation_state.GetErrorOccurredInFrame(internal_frame_id);
550 results_ = GetFrame::Results::Create(frame_details); 573 results_ = GetFrame::Results::Create(frame_details);
551 return true; 574 return true;
552 } 575 }
553 576
554 bool GetAllFramesFunction::RunImpl() { 577 bool GetAllFramesFunction::RunImpl() {
555 scoped_ptr<GetAllFrames::Params> params(GetAllFrames::Params::Create(*args_)); 578 scoped_ptr<GetAllFrames::Params> params(GetAllFrames::Params::Create(*args_));
556 EXTENSION_FUNCTION_VALIDATE(params.get()); 579 EXTENSION_FUNCTION_VALIDATE(params.get());
557 int tab_id = params->details.tab_id; 580 int tab_id = params->details.tab_id;
558 581
559 SetResult(Value::CreateNullValue()); 582 SetResult(Value::CreateNullValue());
(...skipping 13 matching lines...) Expand all
573 WebNavigationTabObserver* observer = 596 WebNavigationTabObserver* observer =
574 WebNavigationTabObserver::Get(web_contents); 597 WebNavigationTabObserver::Get(web_contents);
575 DCHECK(observer); 598 DCHECK(observer);
576 599
577 const FrameNavigationState& navigation_state = 600 const FrameNavigationState& navigation_state =
578 observer->frame_navigation_state(); 601 observer->frame_navigation_state();
579 602
580 std::vector<linked_ptr<GetAllFrames::Results::DetailsElement> > result_list; 603 std::vector<linked_ptr<GetAllFrames::Results::DetailsElement> > result_list;
581 for (FrameNavigationState::const_iterator it = navigation_state.begin(); 604 for (FrameNavigationState::const_iterator it = navigation_state.begin();
582 it != navigation_state.end(); ++it) { 605 it != navigation_state.end(); ++it) {
583 int64 frame_id = *it; 606 FrameNavigationState::FrameID frame_id = *it;
584 GURL frame_url = navigation_state.GetUrl(frame_id); 607 GURL frame_url = navigation_state.GetUrl(frame_id);
585 if (!navigation_state.IsValidUrl(frame_url)) 608 if (!navigation_state.IsValidUrl(frame_url))
586 continue; 609 continue;
587 linked_ptr<GetAllFrames::Results::DetailsElement> frame( 610 linked_ptr<GetAllFrames::Results::DetailsElement> frame(
588 new GetAllFrames::Results::DetailsElement()); 611 new GetAllFrames::Results::DetailsElement());
589 frame->url = frame_url.spec(); 612 frame->url = frame_url.spec();
590 frame->frame_id = helpers::GetFrameId( 613 frame->frame_id = helpers::GetFrameId(
591 navigation_state.IsMainFrame(frame_id), frame_id); 614 navigation_state.IsMainFrame(frame_id), frame_id.frame_num);
615 frame->process_id = frame_id.render_process_id;
592 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); 616 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id);
593 result_list.push_back(frame); 617 result_list.push_back(frame);
594 } 618 }
595 results_ = GetAllFrames::Results::Create(result_list); 619 results_ = GetAllFrames::Results::Create(result_list);
596 return true; 620 return true;
597 } 621 }
598 622
599 } // namespace extensions 623 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698