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/tab_specific_content_settings.h" | 12 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
14 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 14 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
15 #include "chrome/browser/google/google_util.h" | 15 #include "chrome/browser/google/google_util.h" |
16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 18 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
19 #include "chrome/browser/tab_contents/tab_util.h" | 19 #include "chrome/browser/tab_contents/tab_util.h" |
20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
21 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
23 #include "content/browser/browser_thread.h" | 23 #include "content/browser/browser_thread.h" |
24 #include "content/browser/geolocation/geolocation_provider.h" | 24 #include "content/browser/geolocation/geolocation_provider.h" |
25 #include "content/browser/renderer_host/render_process_host.h" | 25 #include "content/browser/renderer_host/render_process_host.h" |
| 26 #include "content/common/content_notification_types.h" |
26 #include "content/common/notification_registrar.h" | 27 #include "content/common/notification_registrar.h" |
27 #include "content/common/notification_source.h" | 28 #include "content/common/notification_source.h" |
28 #include "content/common/notification_type.h" | |
29 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
30 #include "grit/locale_settings.h" | 30 #include "grit/locale_settings.h" |
31 #include "grit/theme_resources.h" | 31 #include "grit/theme_resources.h" |
32 #include "grit/theme_resources_standard.h" | 32 #include "grit/theme_resources_standard.h" |
33 #include "net/base/net_util.h" | 33 #include "net/base/net_util.h" |
34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
35 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
36 | 36 |
37 // GeolocationInfoBarQueueController ------------------------------------------ | 37 // GeolocationInfoBarQueueController ------------------------------------------ |
38 | 38 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // It'll notify and dismiss any other pending InfoBar request for the same | 74 // It'll notify and dismiss any other pending InfoBar request for the same |
75 // |requesting_frame| and embedder. | 75 // |requesting_frame| and embedder. |
76 void OnPermissionSet(int render_process_id, | 76 void OnPermissionSet(int render_process_id, |
77 int render_view_id, | 77 int render_view_id, |
78 int bridge_id, | 78 int bridge_id, |
79 const GURL& requesting_frame, | 79 const GURL& requesting_frame, |
80 const GURL& embedder, | 80 const GURL& embedder, |
81 bool allowed); | 81 bool allowed); |
82 | 82 |
83 // NotificationObserver | 83 // NotificationObserver |
84 virtual void Observe(NotificationType type, | 84 virtual void Observe(int type, |
85 const NotificationSource& source, | 85 const NotificationSource& source, |
86 const NotificationDetails& details); | 86 const NotificationDetails& details); |
87 | 87 |
88 private: | 88 private: |
89 struct PendingInfoBarRequest; | 89 struct PendingInfoBarRequest; |
90 class RequestEquals; | 90 class RequestEquals; |
91 | 91 |
92 typedef std::vector<PendingInfoBarRequest> PendingInfoBarRequests; | 92 typedef std::vector<PendingInfoBarRequest> PendingInfoBarRequests; |
93 | 93 |
94 // Shows the first pending infobar for this tab. | 94 // Shows the first pending infobar for this tab. |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 geolocation_permission_context_->NotifyPermissionSet( | 411 geolocation_permission_context_->NotifyPermissionSet( |
412 copied_request.render_process_id, copied_request.render_view_id, | 412 copied_request.render_process_id, copied_request.render_view_id, |
413 copied_request.bridge_id, copied_request.requesting_frame, allowed); | 413 copied_request.bridge_id, copied_request.requesting_frame, allowed); |
414 } else { | 414 } else { |
415 ++i; | 415 ++i; |
416 } | 416 } |
417 } | 417 } |
418 } | 418 } |
419 | 419 |
420 void GeolocationInfoBarQueueController::Observe( | 420 void GeolocationInfoBarQueueController::Observe( |
421 NotificationType type, const NotificationSource& source, | 421 int type, const NotificationSource& source, |
422 const NotificationDetails& details) { | 422 const NotificationDetails& details) { |
423 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED, | 423 registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
424 source); | 424 source); |
425 TabContents* tab_contents = Source<TabContents>(source).ptr(); | 425 TabContents* tab_contents = Source<TabContents>(source).ptr(); |
426 for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin(); | 426 for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin(); |
427 i != pending_infobar_requests_.end();) { | 427 i != pending_infobar_requests_.end();) { |
428 if (i->infobar_delegate == NULL && | 428 if (i->infobar_delegate == NULL && |
429 tab_contents == tab_util::GetTabContentsByID(i->render_process_id, | 429 tab_contents == tab_util::GetTabContentsByID(i->render_process_id, |
430 i->render_view_id)) { | 430 i->render_view_id)) { |
431 i = pending_infobar_requests_.erase(i); | 431 i = pending_infobar_requests_.erase(i); |
432 } else { | 432 } else { |
433 ++i; | 433 ++i; |
(...skipping 10 matching lines...) Expand all Loading... |
444 wrapper = TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); | 444 wrapper = TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); |
445 for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin(); | 445 for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin(); |
446 i != pending_infobar_requests_.end(); ) { | 446 i != pending_infobar_requests_.end(); ) { |
447 if (i->IsForTab(render_process_id, render_view_id)) { | 447 if (i->IsForTab(render_process_id, render_view_id)) { |
448 if (!wrapper) { | 448 if (!wrapper) { |
449 i = pending_infobar_requests_.erase(i); | 449 i = pending_infobar_requests_.erase(i); |
450 continue; | 450 continue; |
451 } | 451 } |
452 | 452 |
453 if (!i->infobar_delegate) { | 453 if (!i->infobar_delegate) { |
454 if (!registrar_.IsRegistered(this, | 454 if (!registrar_.IsRegistered( |
455 NotificationType::TAB_CONTENTS_DESTROYED, | 455 this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
456 Source<TabContents>(tab_contents))) { | 456 Source<TabContents>(tab_contents))) { |
457 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, | 457 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
458 Source<TabContents>(tab_contents)); | 458 Source<TabContents>(tab_contents)); |
459 } | 459 } |
460 i->infobar_delegate = new GeolocationConfirmInfoBarDelegate( | 460 i->infobar_delegate = new GeolocationConfirmInfoBarDelegate( |
461 tab_contents, this, render_process_id, render_view_id, i->bridge_id, | 461 tab_contents, this, render_process_id, render_view_id, i->bridge_id, |
462 i->requesting_frame, | 462 i->requesting_frame, |
463 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 463 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
464 wrapper->AddInfoBar(i->infobar_delegate); | 464 wrapper->AddInfoBar(i->infobar_delegate); |
465 } | 465 } |
466 break; | 466 break; |
467 } | 467 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 615 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
616 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( | 616 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( |
617 this, &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, | 617 this, &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, |
618 render_process_id, render_view_id, bridge_id)); | 618 render_process_id, render_view_id, bridge_id)); |
619 return; | 619 return; |
620 } | 620 } |
621 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 621 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
622 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, | 622 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, |
623 render_view_id, bridge_id); | 623 render_view_id, bridge_id); |
624 } | 624 } |
OLD | NEW |