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

Side by Side Diff: chrome/browser/geolocation/chrome_geolocation_permission_context.cc

Issue 7810002: Move infobar handling to a tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 9 years, 3 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) 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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 =
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698