Hide WebContentPreferences::GetWebContentsFromProcessID from public

This commit is contained in:
Cheng Zhao 2018-03-08 16:45:37 +09:00
parent 3d47a8a2fd
commit 001275339b
2 changed files with 10 additions and 8 deletions

View file

@ -6,6 +6,7 @@
#include <vector> #include <vector>
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/web_contents_preferences.h" #include "atom/browser/web_contents_preferences.h"
#include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/permission_type.h" #include "content/public/browser/permission_type.h"
@ -19,11 +20,12 @@ namespace atom {
namespace { namespace {
bool WebContentsDestroyed(int process_id) { bool WebContentsDestroyed(int process_id) {
auto contents = content::WebContents* web_contents =
WebContentsPreferences::GetWebContentsFromProcessID(process_id); static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->
if (!contents) GetWebContentsFromProcessID(process_id);
if (!web_contents)
return true; return true;
return contents->IsBeingDestroyed(); return web_contents->IsBeingDestroyed();
} }
void PermissionRequestResponseCallbackWrapper( void PermissionRequestResponseCallbackWrapper(

View file

@ -29,10 +29,6 @@ namespace atom {
class WebContentsPreferences class WebContentsPreferences
: public content::WebContentsUserData<WebContentsPreferences> { : public content::WebContentsUserData<WebContentsPreferences> {
public: public:
// Get WebContents according to process ID.
// FIXME(zcbenz): This method does not belong here.
static content::WebContents* GetWebContentsFromProcessID(int process_id);
// Get self from WebContents. // Get self from WebContents.
static WebContentsPreferences* From(content::WebContents* web_contents); static WebContentsPreferences* From(content::WebContents* web_contents);
// Get self from procese ID. // Get self from procese ID.
@ -63,6 +59,10 @@ class WebContentsPreferences
private: private:
friend class content::WebContentsUserData<WebContentsPreferences>; friend class content::WebContentsUserData<WebContentsPreferences>;
friend class AtomBrowserClient;
// Get WebContents according to process ID.
static content::WebContents* GetWebContentsFromProcessID(int process_id);
// Set preference value to given bool if user did not provide value // Set preference value to given bool if user did not provide value
bool SetDefaultBoolIfUndefined(const base::StringPiece& key, bool val); bool SetDefaultBoolIfUndefined(const base::StringPiece& key, bool val);