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

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

Issue 9030032: Get rid of a bunch of tab_contents.h includes from chrome. These are all trivial changes to use W... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros Created 8 years, 11 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/bind.h" 11 #include "base/bind.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/content_settings/host_content_settings_map.h" 13 #include "chrome/browser/content_settings/host_content_settings_map.h"
14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/google/google_util.h" 16 #include "chrome/browser/google/google_util.h"
17 #include "chrome/browser/infobars/infobar_tab_helper.h" 17 #include "chrome/browser/infobars/infobar_tab_helper.h"
18 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 20 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
21 #include "chrome/browser/tab_contents/tab_util.h" 21 #include "chrome/browser/tab_contents/tab_util.h"
22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
23 #include "chrome/common/extensions/extension.h" 23 #include "chrome/common/extensions/extension.h"
24 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
25 #include "content/browser/geolocation/geolocation_provider.h" 25 #include "content/browser/geolocation/geolocation_provider.h"
26 #include "content/browser/renderer_host/render_view_host.h" 26 #include "content/browser/renderer_host/render_view_host.h"
27 #include "content/browser/tab_contents/tab_contents.h"
28 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/navigation_details.h" 28 #include "content/public/browser/navigation_details.h"
30 #include "content/public/browser/navigation_entry.h" 29 #include "content/public/browser/navigation_entry.h"
31 #include "content/public/browser/notification_registrar.h" 30 #include "content/public/browser/notification_registrar.h"
32 #include "content/public/browser/notification_source.h" 31 #include "content/public/browser/notification_source.h"
33 #include "content/public/browser/notification_types.h" 32 #include "content/public/browser/notification_types.h"
33 #include "content/public/browser/web_contents.h"
34 #include "grit/generated_resources.h" 34 #include "grit/generated_resources.h"
35 #include "grit/locale_settings.h" 35 #include "grit/locale_settings.h"
36 #include "grit/theme_resources.h" 36 #include "grit/theme_resources.h"
37 #include "grit/theme_resources_standard.h" 37 #include "grit/theme_resources_standard.h"
38 #include "net/base/net_util.h" 38 #include "net/base/net_util.h"
39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
40 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
41 #include "ui/base/resource/resource_bundle.h" 41 #include "ui/base/resource/resource_bundle.h"
42 42
43 using WebKit::WebSecurityOrigin; 43 using WebKit::WebSecurityOrigin;
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 464
465 void GeolocationInfoBarQueueController::Observe( 465 void GeolocationInfoBarQueueController::Observe(
466 int type, const content::NotificationSource& source, 466 int type, const content::NotificationSource& source,
467 const content::NotificationDetails& details) { 467 const content::NotificationDetails& details) {
468 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 468 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
469 source); 469 source);
470 WebContents* web_contents = content::Source<WebContents>(source).ptr(); 470 WebContents* web_contents = content::Source<WebContents>(source).ptr();
471 for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin(); 471 for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin();
472 i != pending_infobar_requests_.end();) { 472 i != pending_infobar_requests_.end();) {
473 if (i->infobar_delegate == NULL && 473 if (i->infobar_delegate == NULL &&
474 web_contents == tab_util::GetTabContentsByID(i->render_process_id, 474 web_contents == tab_util::GetWebContentsByID(i->render_process_id,
475 i->render_view_id)) { 475 i->render_view_id)) {
476 i = pending_infobar_requests_.erase(i); 476 i = pending_infobar_requests_.erase(i);
477 } else { 477 } else {
478 ++i; 478 ++i;
479 } 479 }
480 } 480 }
481 } 481 }
482 482
483 void GeolocationInfoBarQueueController::ShowQueuedInfoBar(int render_process_id, 483 void GeolocationInfoBarQueueController::ShowQueuedInfoBar(int render_process_id,
484 int render_view_id) { 484 int render_view_id) {
485 TabContents* tab_contents = 485 WebContents* tab_contents =
486 tab_util::GetTabContentsByID(render_process_id, render_view_id); 486 tab_util::GetWebContentsByID(render_process_id, render_view_id);
487 TabContentsWrapper* wrapper = NULL; 487 TabContentsWrapper* wrapper = NULL;
488 if (tab_contents) 488 if (tab_contents)
489 wrapper = TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); 489 wrapper = TabContentsWrapper::GetCurrentWrapperForContents(tab_contents);
490 for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin(); 490 for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin();
491 i != pending_infobar_requests_.end(); ) { 491 i != pending_infobar_requests_.end(); ) {
492 if (i->IsForTab(render_process_id, render_view_id)) { 492 if (i->IsForTab(render_process_id, render_view_id)) {
493 if (!wrapper) { 493 if (!wrapper) {
494 i = pending_infobar_requests_.erase(i); 494 i = pending_infobar_requests_.erase(i);
495 continue; 495 continue;
496 } 496 }
(...skipping 17 matching lines...) Expand all
514 } 514 }
515 } 515 }
516 516
517 GeolocationInfoBarQueueController::PendingInfoBarRequests::iterator 517 GeolocationInfoBarQueueController::PendingInfoBarRequests::iterator
518 GeolocationInfoBarQueueController::CancelInfoBarRequestInternal( 518 GeolocationInfoBarQueueController::CancelInfoBarRequestInternal(
519 PendingInfoBarRequests::iterator i) { 519 PendingInfoBarRequests::iterator i) {
520 InfoBarDelegate* delegate = i->infobar_delegate; 520 InfoBarDelegate* delegate = i->infobar_delegate;
521 if (!delegate) 521 if (!delegate)
522 return pending_infobar_requests_.erase(i); 522 return pending_infobar_requests_.erase(i);
523 523
524 TabContents* tab_contents = 524 WebContents* web_contents =
525 tab_util::GetTabContentsByID(i->render_process_id, i->render_view_id); 525 tab_util::GetWebContentsByID(i->render_process_id, i->render_view_id);
526 if (!tab_contents) 526 if (!web_contents)
527 return pending_infobar_requests_.erase(i); 527 return pending_infobar_requests_.erase(i);
528 528
529 // TabContents will destroy the InfoBar, which will remove from our vector 529 // WebContents will destroy the InfoBar, which will remove from our vector
530 // asynchronously. 530 // asynchronously.
531 TabContentsWrapper* wrapper = 531 TabContentsWrapper* wrapper =
532 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); 532 TabContentsWrapper::GetCurrentWrapperForContents(web_contents);
533 wrapper->infobar_tab_helper()->RemoveInfoBar(i->infobar_delegate); 533 wrapper->infobar_tab_helper()->RemoveInfoBar(i->infobar_delegate);
534 return ++i; 534 return ++i;
535 } 535 }
536 536
537 537
538 // GeolocationPermissionContext ----------------------------------------------- 538 // GeolocationPermissionContext -----------------------------------------------
539 539
540 ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext( 540 ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext(
541 Profile* profile) 541 Profile* profile)
542 : profile_(profile), 542 : profile_(profile),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 // Make sure the extension is in the calling process. 574 // Make sure the extension is in the calling process.
575 if (extension_service->process_map()->Contains( 575 if (extension_service->process_map()->Contains(
576 extension->id(), render_process_id)) { 576 extension->id(), render_process_id)) {
577 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, 577 NotifyPermissionSet(render_process_id, render_view_id, bridge_id,
578 requesting_frame, callback, true); 578 requesting_frame, callback, true);
579 return; 579 return;
580 } 580 }
581 } 581 }
582 } 582 }
583 583
584 TabContents* tab_contents = 584 WebContents* web_contents =
585 tab_util::GetTabContentsByID(render_process_id, render_view_id); 585 tab_util::GetWebContentsByID(render_process_id, render_view_id);
586 if (!tab_contents || tab_contents->GetViewType() != 586 if (!web_contents || web_contents->GetViewType() !=
587 content::VIEW_TYPE_TAB_CONTENTS) { 587 content::VIEW_TYPE_TAB_CONTENTS) {
588 // The tab may have gone away, or the request may not be from a tab at all. 588 // The tab may have gone away, or the request may not be from a tab at all.
589 // TODO(mpcomplete): the request could be from a background page or 589 // TODO(mpcomplete): the request could be from a background page or
590 // extension popup (tab_contents will have a different ViewType). But why do 590 // extension popup (tab_contents will have a different ViewType). But why do
591 // we care? Shouldn't we still put an infobar up in the current tab? 591 // we care? Shouldn't we still put an infobar up in the current tab?
592 LOG(WARNING) << "Attempt to use geolocation tabless renderer: " 592 LOG(WARNING) << "Attempt to use geolocation tabless renderer: "
593 << render_process_id << "," << render_view_id << "," 593 << render_process_id << "," << render_view_id << ","
594 << bridge_id << " (can't prompt user without a visible tab)"; 594 << bridge_id << " (can't prompt user without a visible tab)";
595 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, 595 NotifyPermissionSet(render_process_id, render_view_id, bridge_id,
596 requesting_frame, callback, false); 596 requesting_frame, callback, false);
597 return; 597 return;
598 } 598 }
599 599
600 GURL embedder = tab_contents->GetURL(); 600 GURL embedder = web_contents->GetURL();
601 if (!requesting_frame.is_valid() || !embedder.is_valid()) { 601 if (!requesting_frame.is_valid() || !embedder.is_valid()) {
602 LOG(WARNING) << "Attempt to use geolocation from an invalid URL: " 602 LOG(WARNING) << "Attempt to use geolocation from an invalid URL: "
603 << requesting_frame << "," << embedder 603 << requesting_frame << "," << embedder
604 << " (geolocation is not supported in popups)"; 604 << " (geolocation is not supported in popups)";
605 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, 605 NotifyPermissionSet(render_process_id, render_view_id, bridge_id,
606 requesting_frame, callback, false); 606 requesting_frame, callback, false);
607 return; 607 return;
608 } 608 }
609 609
610 ContentSetting content_setting = 610 ContentSetting content_setting =
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 BrowserThread::UI, FROM_HERE, 677 BrowserThread::UI, FROM_HERE,
678 base::Bind( 678 base::Bind(
679 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, 679 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest,
680 this, render_process_id, render_view_id, bridge_id)); 680 this, render_process_id, render_view_id, bridge_id));
681 return; 681 return;
682 } 682 }
683 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 683 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
684 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, 684 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id,
685 render_view_id, bridge_id); 685 render_view_id, bridge_id);
686 } 686 }
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_tab_helper.cc ('k') | chrome/browser/history/history_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698