Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_RENDERER_HOST_PEPPER_FLASH_LSO_SETTINGS_HELPER_H_ | |
| 6 #define CHROME_BROWSER_RENDERER_HOST_PEPPER_FLASH_LSO_SETTINGS_HELPER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/callback.h" | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "content/public/browser/notification_observer.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 #include "ppapi/c/private/ppb_flash.h" | |
| 15 | |
| 16 class GURL; | |
| 17 class Profile; | |
| 18 | |
| 19 namespace content { | |
| 20 class ResourceContext; | |
| 21 } | |
| 22 | |
| 23 namespace chrome { | |
| 24 | |
| 25 // This class aids in getting the Flash LSO Settings. | |
| 26 class FlashLSOSettingsHelper | |
| 27 : public base::RefCountedThreadSafe<FlashLSOSettingsHelper>, | |
| 28 public content::NotificationObserver { | |
| 29 public: | |
| 30 explicit FlashLSOSettingsHelper(int render_process_id); | |
| 31 | |
| 32 // Get the Flash local data restrictions for the given document/plugin URLs. | |
|
yzshen1
2012/12/29 02:04:05
Get->Gets (and some other places in this file).
raymes
2012/12/29 03:21:57
Done.
| |
| 33 // Should only be called from the IO thread. |callback| will be run with the | |
| 34 // data restriction settings on the IO thread. It may be run synchronously or | |
| 35 // asynchronously. | |
| 36 void GetLocalDataRestrictions( | |
| 37 const GURL& document_url, | |
| 38 const GURL& plugin_url, | |
| 39 base::Callback<void(PP_FlashLSORestrictions)> callback); | |
|
yzshen1
2012/12/29 02:04:05
Usually we pass const & for callback, right?
raymes
2012/12/29 03:21:57
Done.
| |
| 40 | |
| 41 private: | |
| 42 virtual ~FlashLSOSettingsHelper(); | |
| 43 friend class base::RefCountedThreadSafe<FlashLSOSettingsHelper>; | |
| 44 | |
| 45 // Run |callback| with the local data restrictions for the given resource | |
| 46 // context. The resource context is cached locally. | |
| 47 void GetLocalDataRestrictionsHelper( | |
| 48 const GURL& document_url, | |
| 49 const GURL& plugin_url, | |
| 50 base::Callback<void(PP_FlashLSORestrictions)> callback, | |
|
yzshen1
2012/12/29 02:04:05
ditto.
raymes
2012/12/29 03:21:57
Done.
| |
| 51 content::ResourceContext* resource_context); | |
| 52 | |
| 53 // Gets the resource context for the given render process ID. The resource | |
| 54 // context belongs to the Profile which lives on the UI thread so this should | |
| 55 // be run on the UI thread. This also registers this class for a notification | |
| 56 // on profile destruction so that the resource context is not accessed after | |
| 57 // that point. | |
| 58 content::ResourceContext* GetResourceContext(int render_process_id); | |
| 59 | |
| 60 // content::NotificationObserver implementation. | |
| 61 virtual void Observe(int type, | |
| 62 const content::NotificationSource& source, | |
| 63 const content::NotificationDetails& details) OVERRIDE; | |
| 64 | |
| 65 // Clear |resource_context_| on the IO thread when the profile is destroyed. | |
| 66 void ClearResourceContext(); | |
| 67 | |
| 68 // The render process ID of the renderer process to get LSO settings for. | |
| 69 // Should only be accessed on the IO thread. | |
| 70 int render_process_id_; | |
| 71 | |
| 72 // Whether the |resource_context_| has been initialized yet. Should only be | |
| 73 // accessed from the IO thread. | |
| 74 bool initialized_; | |
| 75 | |
| 76 // For fetching the Flash LSO settings. Should only be accessed from the IO | |
| 77 // thread. | |
| 78 content::ResourceContext* resource_context_; | |
| 79 | |
| 80 // Registrar for receiving profile destruction notifications. Should only be | |
| 81 // accessed from the UI thread. | |
| 82 scoped_ptr<content::NotificationRegistrar> registrar_; | |
| 83 | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(FlashLSOSettingsHelper); | |
| 86 }; | |
| 87 | |
| 88 } // namespace chrome | |
| 89 | |
| 90 #endif // CHROME_BROWSER_RENDERER_HOST_PEPPER_FLASH_LSO_SETTINGS_HELPER_H_ | |
| OLD | NEW |