| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/extension_system.h" | 16 #include "chrome/browser/extensions/extension_system.h" |
| 17 #include "chrome/browser/extensions/suggest_permission_util.h" | 17 #include "chrome/browser/extensions/suggest_permission_util.h" |
| 18 #include "chrome/browser/geolocation/geolocation_infobar_queue_controller.h" | 18 #include "chrome/browser/geolocation/geolocation_infobar_queue_controller.h" |
| 19 #include "chrome/browser/geolocation/geolocation_permission_request_id.h" | 19 #include "chrome/browser/geolocation/geolocation_permission_request_id.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/tab_contents/tab_util.h" | 21 #include "chrome/browser/tab_contents/tab_util.h" |
| 22 #include "chrome/browser/view_type_utils.h" | |
| 23 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
| 24 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
| 26 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "extensions/browser/view_type_utils.h" |
| 27 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 27 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 29 | 29 |
| 30 using extensions::APIPermission; | 30 using extensions::APIPermission; |
| 31 | 31 |
| 32 ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext( | 32 ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext( |
| 33 Profile* profile) | 33 Profile* profile) |
| 34 : profile_(profile), | 34 : profile_(profile), |
| 35 shutting_down_(false) { | 35 shutting_down_(false) { |
| 36 } | 36 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 profile_)) { | 79 profile_)) { |
| 80 // Make sure the extension is in the calling process. | 80 // Make sure the extension is in the calling process. |
| 81 if (extension_service->process_map()->Contains(extension->id(), | 81 if (extension_service->process_map()->Contains(extension->id(), |
| 82 id.render_process_id())) { | 82 id.render_process_id())) { |
| 83 NotifyPermissionSet(id, requesting_frame, callback, true); | 83 NotifyPermissionSet(id, requesting_frame, callback, true); |
| 84 return; | 84 return; |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 if (chrome::GetViewType(web_contents) != chrome::VIEW_TYPE_TAB_CONTENTS) { | 89 if (extensions::GetViewType(web_contents) != |
| 90 extensions::VIEW_TYPE_TAB_CONTENTS) { |
| 90 // The tab may have gone away, or the request may not be from a tab at all. | 91 // The tab may have gone away, or the request may not be from a tab at all. |
| 91 // TODO(mpcomplete): the request could be from a background page or | 92 // TODO(mpcomplete): the request could be from a background page or |
| 92 // extension popup (web_contents will have a different ViewType). But why do | 93 // extension popup (web_contents will have a different ViewType). But why do |
| 93 // we care? Shouldn't we still put an infobar up in the current tab? | 94 // we care? Shouldn't we still put an infobar up in the current tab? |
| 94 LOG(WARNING) << "Attempt to use geolocation tabless renderer: " | 95 LOG(WARNING) << "Attempt to use geolocation tabless renderer: " |
| 95 << id.ToString() | 96 << id.ToString() |
| 96 << " (can't prompt user without a visible tab)"; | 97 << " (can't prompt user without a visible tab)"; |
| 97 NotifyPermissionSet(id, requesting_frame, callback, false); | 98 NotifyPermissionSet(id, requesting_frame, callback, false); |
| 98 return; | 99 return; |
| 99 } | 100 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 base::Bind( | 204 base::Bind( |
| 204 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, | 205 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, |
| 205 this, id)); | 206 this, id)); |
| 206 return; | 207 return; |
| 207 } | 208 } |
| 208 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 209 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 209 if (shutting_down_) | 210 if (shutting_down_) |
| 210 return; | 211 return; |
| 211 QueueController()->CancelInfoBarRequest(id); | 212 QueueController()->CancelInfoBarRequest(id); |
| 212 } | 213 } |
| OLD | NEW |