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/tab_specific_content_settings.h" | 13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.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" |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 int render_process_id, | 379 int render_process_id, |
380 int render_view_id, | 380 int render_view_id, |
381 int bridge_id, | 381 int bridge_id, |
382 const GURL& requesting_frame, | 382 const GURL& requesting_frame, |
383 const GURL& embedder, | 383 const GURL& embedder, |
384 bool allowed) { | 384 bool allowed) { |
385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
386 | 386 |
387 ContentSetting content_setting = | 387 ContentSetting content_setting = |
388 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 388 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
389 profile_->GetGeolocationContentSettingsMap()->SetContentSetting( | 389 profile_->GetHostContentSettingsMap()->SetContentSetting( |
390 requesting_frame.GetOrigin(), embedder.GetOrigin(), content_setting); | 390 ContentSettingsPattern::FromURLNoWildcard(requesting_frame.GetOrigin()), |
| 391 ContentSettingsPattern::FromURLNoWildcard(embedder.GetOrigin()), |
| 392 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 393 std::string(), |
| 394 content_setting); |
391 | 395 |
392 for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin(); | 396 for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin(); |
393 i != pending_infobar_requests_.end(); ) { | 397 i != pending_infobar_requests_.end(); ) { |
394 if (i->IsForPair(requesting_frame, embedder)) { | 398 if (i->IsForPair(requesting_frame, embedder)) { |
395 // Cancel this request first, then notify listeners. TODO(pkasting): Why | 399 // Cancel this request first, then notify listeners. TODO(pkasting): Why |
396 // is this order important? | 400 // is this order important? |
397 // NOTE: If the pending request had an infobar, TabContents will close it | 401 // NOTE: If the pending request had an infobar, TabContents will close it |
398 // either synchronously or asynchronously, which will then pump the queue | 402 // either synchronously or asynchronously, which will then pump the queue |
399 // via OnInfoBarClosed(). | 403 // via OnInfoBarClosed(). |
400 PendingInfoBarRequest copied_request = *i; | 404 PendingInfoBarRequest copied_request = *i; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 if (!requesting_frame.is_valid() || !embedder.is_valid()) { | 555 if (!requesting_frame.is_valid() || !embedder.is_valid()) { |
552 LOG(WARNING) << "Attempt to use geolocation from an invalid URL: " | 556 LOG(WARNING) << "Attempt to use geolocation from an invalid URL: " |
553 << requesting_frame << "," << embedder | 557 << requesting_frame << "," << embedder |
554 << " (geolocation is not supported in popups)"; | 558 << " (geolocation is not supported in popups)"; |
555 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, | 559 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, |
556 requesting_frame, false); | 560 requesting_frame, false); |
557 return; | 561 return; |
558 } | 562 } |
559 | 563 |
560 ContentSetting content_setting = | 564 ContentSetting content_setting = |
561 profile_->GetGeolocationContentSettingsMap()->GetContentSetting( | 565 profile_->GetHostContentSettingsMap()->GetContentSetting( |
562 requesting_frame, embedder); | 566 requesting_frame, |
| 567 embedder, |
| 568 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 569 std::string()); |
563 if (content_setting == CONTENT_SETTING_BLOCK) { | 570 if (content_setting == CONTENT_SETTING_BLOCK) { |
564 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, | 571 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, |
565 requesting_frame, false); | 572 requesting_frame, false); |
566 } else if (content_setting == CONTENT_SETTING_ALLOW) { | 573 } else if (content_setting == CONTENT_SETTING_ALLOW) { |
567 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, | 574 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, |
568 requesting_frame, true); | 575 requesting_frame, true); |
569 } else { // setting == ask. Prompt the user. | 576 } else { // setting == ask. Prompt the user. |
570 geolocation_infobar_queue_controller_->CreateInfoBarRequest( | 577 geolocation_infobar_queue_controller_->CreateInfoBarRequest( |
571 render_process_id, render_view_id, bridge_id, requesting_frame, | 578 render_process_id, render_view_id, bridge_id, requesting_frame, |
572 embedder); | 579 embedder); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 628 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
622 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( | 629 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( |
623 this, &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, | 630 this, &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, |
624 render_process_id, render_view_id, bridge_id)); | 631 render_process_id, render_view_id, bridge_id)); |
625 return; | 632 return; |
626 } | 633 } |
627 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 634 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
628 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, | 635 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, |
629 render_view_id, bridge_id); | 636 render_view_id, bridge_id); |
630 } | 637 } |
OLD | NEW |