Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/geolocation/chrome_geolocation_permission_context.h" | 5 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
| 6 | 6 |
| 7 #include <functional> | 7 #include <functional> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/content_settings/host_content_settings_map.h" | 12 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/google/google_util.h" | 15 #include "chrome/browser/google/google_util.h" |
| 16 #include "chrome/browser/infobars/infobar_tab_helper.h" | |
| 16 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 19 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 19 #include "chrome/browser/tab_contents/tab_util.h" | 20 #include "chrome/browser/tab_contents/tab_util.h" |
| 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 21 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
| 22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 23 #include "content/browser/browser_thread.h" | 24 #include "content/browser/browser_thread.h" |
| 24 #include "content/browser/geolocation/geolocation_provider.h" | 25 #include "content/browser/geolocation/geolocation_provider.h" |
| 25 #include "content/browser/renderer_host/render_view_host.h" | 26 #include "content/browser/renderer_host/render_view_host.h" |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 } else { | 437 } else { |
| 437 ++i; | 438 ++i; |
| 438 } | 439 } |
| 439 } | 440 } |
| 440 } | 441 } |
| 441 | 442 |
| 442 void GeolocationInfoBarQueueController::ShowQueuedInfoBar(int render_process_id, | 443 void GeolocationInfoBarQueueController::ShowQueuedInfoBar(int render_process_id, |
| 443 int render_view_id) { | 444 int render_view_id) { |
| 444 TabContents* tab_contents = | 445 TabContents* tab_contents = |
| 445 tab_util::GetTabContentsByID(render_process_id, render_view_id); | 446 tab_util::GetTabContentsByID(render_process_id, render_view_id); |
| 446 TabContentsWrapper* wrapper = NULL; | 447 TabContentsWrapper* wrapper = NULL; |
|
Peter Kasting
2011/08/31 18:47:32
Nit: Convert this TCW* temp into an InfoBarTabHelp
Avi (use Gerrit)
2011/08/31 21:18:54
Why? It's used once.
Peter Kasting
2011/08/31 21:24:55
nm, I misread the code.
| |
| 447 if (tab_contents) | 448 if (tab_contents) |
| 448 wrapper = TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); | 449 wrapper = TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); |
| 449 for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin(); | 450 for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin(); |
| 450 i != pending_infobar_requests_.end(); ) { | 451 i != pending_infobar_requests_.end(); ) { |
| 451 if (i->IsForTab(render_process_id, render_view_id)) { | 452 if (i->IsForTab(render_process_id, render_view_id)) { |
| 452 if (!wrapper) { | 453 if (!wrapper) { |
| 453 i = pending_infobar_requests_.erase(i); | 454 i = pending_infobar_requests_.erase(i); |
| 454 continue; | 455 continue; |
| 455 } | 456 } |
| 456 | 457 |
| 457 if (!i->infobar_delegate) { | 458 if (!i->infobar_delegate) { |
| 458 if (!registrar_.IsRegistered( | 459 if (!registrar_.IsRegistered( |
| 459 this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, | 460 this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
| 460 Source<TabContents>(tab_contents))) { | 461 Source<TabContents>(tab_contents))) { |
| 461 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, | 462 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
| 462 Source<TabContents>(tab_contents)); | 463 Source<TabContents>(tab_contents)); |
| 463 } | 464 } |
| 464 i->infobar_delegate = new GeolocationConfirmInfoBarDelegate( | 465 i->infobar_delegate = new GeolocationConfirmInfoBarDelegate( |
| 465 tab_contents, this, render_process_id, render_view_id, i->bridge_id, | 466 tab_contents, this, render_process_id, render_view_id, i->bridge_id, |
| 466 i->requesting_frame, | 467 i->requesting_frame, |
| 467 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 468 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
| 468 wrapper->AddInfoBar(i->infobar_delegate); | 469 wrapper->infobar_tab_helper()->AddInfoBar(i->infobar_delegate); |
| 469 } | 470 } |
| 470 break; | 471 break; |
| 471 } | 472 } |
| 472 ++i; | 473 ++i; |
| 473 } | 474 } |
| 474 } | 475 } |
| 475 | 476 |
| 476 GeolocationInfoBarQueueController::PendingInfoBarRequests::iterator | 477 GeolocationInfoBarQueueController::PendingInfoBarRequests::iterator |
| 477 GeolocationInfoBarQueueController::CancelInfoBarRequestInternal( | 478 GeolocationInfoBarQueueController::CancelInfoBarRequestInternal( |
| 478 PendingInfoBarRequests::iterator i) { | 479 PendingInfoBarRequests::iterator i) { |
| 479 InfoBarDelegate* delegate = i->infobar_delegate; | 480 InfoBarDelegate* delegate = i->infobar_delegate; |
| 480 if (!delegate) | 481 if (!delegate) |
| 481 return pending_infobar_requests_.erase(i); | 482 return pending_infobar_requests_.erase(i); |
| 482 | 483 |
| 483 TabContents* tab_contents = | 484 TabContents* tab_contents = |
| 484 tab_util::GetTabContentsByID(i->render_process_id, i->render_view_id); | 485 tab_util::GetTabContentsByID(i->render_process_id, i->render_view_id); |
| 485 if (!tab_contents) | 486 if (!tab_contents) |
| 486 return pending_infobar_requests_.erase(i); | 487 return pending_infobar_requests_.erase(i); |
| 487 | 488 |
| 488 // TabContents will destroy the InfoBar, which will remove from our vector | 489 // TabContents will destroy the InfoBar, which will remove from our vector |
| 489 // asynchronously. | 490 // asynchronously. |
| 490 TabContentsWrapper* wrapper = | 491 TabContentsWrapper* wrapper = |
|
Peter Kasting
2011/08/31 18:47:32
Nit: Just combine these two lines
| |
| 491 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); | 492 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); |
| 492 wrapper->RemoveInfoBar(i->infobar_delegate); | 493 wrapper->infobar_tab_helper()->RemoveInfoBar(i->infobar_delegate); |
| 493 return ++i; | 494 return ++i; |
| 494 } | 495 } |
| 495 | 496 |
| 496 | 497 |
| 497 // GeolocationPermissionContext ----------------------------------------------- | 498 // GeolocationPermissionContext ----------------------------------------------- |
| 498 | 499 |
| 499 ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext( | 500 ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext( |
| 500 Profile* profile) | 501 Profile* profile) |
| 501 : profile_(profile), | 502 : profile_(profile), |
| 502 ALLOW_THIS_IN_INITIALIZER_LIST(geolocation_infobar_queue_controller_( | 503 ALLOW_THIS_IN_INITIALIZER_LIST(geolocation_infobar_queue_controller_( |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 629 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 629 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( | 630 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( |
| 630 this, &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, | 631 this, &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, |
| 631 render_process_id, render_view_id, bridge_id)); | 632 render_process_id, render_view_id, bridge_id)); |
| 632 return; | 633 return; |
| 633 } | 634 } |
| 634 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 635 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 635 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, | 636 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, |
| 636 render_view_id, bridge_id); | 637 render_view_id, bridge_id); |
| 637 } | 638 } |
| OLD | NEW |