| 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/extensions/suggest_permission_util.h" | 5 #include "chrome/browser/extensions/suggest_permission_util.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_process_manager.h" | |
| 8 #include "chrome/browser/extensions/extension_system.h" | 7 #include "chrome/browser/extensions/extension_system.h" |
| 9 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
| 10 #include "chrome/common/extensions/extension_messages.h" | 9 #include "chrome/common/extensions/extension_messages.h" |
| 11 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
| 12 #include "content/public/common/console_message_level.h" | 11 #include "content/public/common/console_message_level.h" |
| 12 #include "extensions/browser/process_manager.h" |
| 13 #include "extensions/common/permissions/permissions_info.h" | 13 #include "extensions/common/permissions/permissions_info.h" |
| 14 | 14 |
| 15 using content::CONSOLE_MESSAGE_LEVEL_WARNING; | 15 using content::CONSOLE_MESSAGE_LEVEL_WARNING; |
| 16 using content::RenderViewHost; | 16 using content::RenderViewHost; |
| 17 | 17 |
| 18 const char kPermissionsHelpURLForExtensions[] = | 18 const char kPermissionsHelpURLForExtensions[] = |
| 19 "http://developer.chrome.com/extensions/manifest.html#permissions"; | 19 "http://developer.chrome.com/extensions/manifest.html#permissions"; |
| 20 const char kPermissionsHelpURLForApps[] = | 20 const char kPermissionsHelpURLForApps[] = |
| 21 "http://developer.chrome.com/apps/declare_permissions.html"; | 21 "http://developer.chrome.com/apps/declare_permissions.html"; |
| 22 | 22 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 40 extension->is_platform_app() ? | 40 extension->is_platform_app() ? |
| 41 kPermissionsHelpURLForApps : kPermissionsHelpURLForExtensions); | 41 kPermissionsHelpURLForApps : kPermissionsHelpURLForExtensions); |
| 42 | 42 |
| 43 host->Send(new ExtensionMsg_AddMessageToConsole( | 43 host->Send(new ExtensionMsg_AddMessageToConsole( |
| 44 host->GetRoutingID(), CONSOLE_MESSAGE_LEVEL_WARNING, message)); | 44 host->GetRoutingID(), CONSOLE_MESSAGE_LEVEL_WARNING, message)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void SuggestAPIPermissionInDevToolsConsole(APIPermission::ID permission, | 47 void SuggestAPIPermissionInDevToolsConsole(APIPermission::ID permission, |
| 48 const Extension* extension, | 48 const Extension* extension, |
| 49 Profile* profile) { | 49 Profile* profile) { |
| 50 ExtensionProcessManager* process_manager = | 50 extensions::ProcessManager* process_manager = |
| 51 extensions::ExtensionSystem::Get(profile)->process_manager(); | 51 extensions::ExtensionSystem::Get(profile)->process_manager(); |
| 52 | 52 |
| 53 std::set<content::RenderViewHost*> views = | 53 std::set<content::RenderViewHost*> views = |
| 54 process_manager->GetRenderViewHostsForExtension(extension->id()); | 54 process_manager->GetRenderViewHostsForExtension(extension->id()); |
| 55 | 55 |
| 56 for (std::set<RenderViewHost*>::const_iterator iter = views.begin(); | 56 for (std::set<RenderViewHost*>::const_iterator iter = views.begin(); |
| 57 iter != views.end(); ++iter) { | 57 iter != views.end(); ++iter) { |
| 58 RenderViewHost* host = *iter; | 58 RenderViewHost* host = *iter; |
| 59 SuggestAPIPermissionInDevToolsConsole(permission, extension, host); | 59 SuggestAPIPermissionInDevToolsConsole(permission, extension, host); |
| 60 } | 60 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 80 if (extension && extension->HasAPIPermission(permission)) | 80 if (extension && extension->HasAPIPermission(permission)) |
| 81 return true; | 81 return true; |
| 82 | 82 |
| 83 if (extension) | 83 if (extension) |
| 84 SuggestAPIPermissionInDevToolsConsole(permission, extension, profile); | 84 SuggestAPIPermissionInDevToolsConsole(permission, extension, profile); |
| 85 | 85 |
| 86 return false; | 86 return false; |
| 87 } | 87 } |
| 88 | 88 |
| 89 } // namespace extensions | 89 } // namespace extensions |
| OLD | NEW |