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

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

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

Powered by Google App Engine
This is Rietveld 408576698