Index: chrome/browser/ui/webui/nacl_ui.cc |
diff --git a/chrome/browser/ui/webui/nacl_ui.cc b/chrome/browser/ui/webui/nacl_ui.cc |
index 0c59cc69d240beb6d3d5898b1f9c92ad38d48884..e6f218d7f7f6b4a32feaaec13d92320e0a89c6d3 100644 |
--- a/chrome/browser/ui/webui/nacl_ui.cc |
+++ b/chrome/browser/ui/webui/nacl_ui.cc |
@@ -63,46 +63,44 @@ content::WebUIDataSource* CreateNaClUIHTMLSource() { |
//////////////////////////////////////////////////////////////////////////////// |
// |
-// NaClDOMHandler |
+// NaClDomHandler |
// |
//////////////////////////////////////////////////////////////////////////////// |
-class NaClDOMHandler; |
+class NaClDomHandler; |
// This class performs a check that the PNaCl path which was returned by |
-// PathService is valid. One class instance is created per NaClDOMHandler |
+// PathService is valid. One class instance is created per NaClDomHandler |
// and it is destroyed after the check is completed. |
-class NaClDOMHandlerProxy : public |
- base::RefCountedThreadSafe<NaClDOMHandlerProxy> { |
+class NaClDomHandlerProxy |
+ : public base::RefCountedThreadSafe<NaClDomHandlerProxy> { |
public: |
- explicit NaClDOMHandlerProxy(NaClDOMHandler* handler); |
+ explicit NaClDomHandlerProxy(NaClDomHandler* handler); |
// A helper to check if PNaCl path exists. |
void ValidatePnaclPath(); |
- void set_handler(NaClDOMHandler* handler) { |
- handler_ = handler; |
- } |
+ void set_handler(NaClDomHandler* handler) { handler_ = handler; } |
private: |
+ friend class base::RefCountedThreadSafe<NaClDomHandlerProxy>; |
+ virtual ~NaClDomHandlerProxy() {} |
+ |
// A helper callback that receives the result of checking if PNaCl path |
// exists. |
void ValidatePnaclPathCallback(bool is_valid); |
- virtual ~NaClDOMHandlerProxy() {} |
- friend class base::RefCountedThreadSafe<NaClDOMHandlerProxy>; |
- |
// The handler that requested checking PNaCl file path. |
- NaClDOMHandler* handler_; |
+ NaClDomHandler* handler_; // weak |
- DISALLOW_COPY_AND_ASSIGN(NaClDOMHandlerProxy); |
+ DISALLOW_COPY_AND_ASSIGN(NaClDomHandlerProxy); |
}; |
// The handler for JavaScript messages for the about:flags page. |
-class NaClDOMHandler : public WebUIMessageHandler { |
+class NaClDomHandler : public WebUIMessageHandler { |
public: |
- NaClDOMHandler(); |
- virtual ~NaClDOMHandler(); |
+ NaClDomHandler(); |
+ virtual ~NaClDomHandler(); |
// WebUIMessageHandler implementation. |
virtual void RegisterMessages() OVERRIDE; |
@@ -114,7 +112,7 @@ class NaClDOMHandler : public WebUIMessageHandler { |
void OnGotPlugins(const std::vector<webkit::WebPluginInfo>& plugins); |
// A helper callback that receives the result of checking if PNaCl path |
- // exists. is_valid is true if the PNaCl path that was returned by |
+ // exists. |is_valid| is true if the PNaCl path that was returned by |
// PathService is valid, and false otherwise. |
void DidValidatePnaclPath(bool is_valid); |
@@ -127,7 +125,7 @@ class NaClDOMHandler : public WebUIMessageHandler { |
void PopulatePageInformation(DictionaryValue* naclInfo); |
// Factory for the creating refs in callbacks. |
- base::WeakPtrFactory<NaClDOMHandler> weak_ptr_factory_; |
+ base::WeakPtrFactory<NaClDomHandler> weak_ptr_factory_; |
// Whether the page has requested data. |
bool page_has_requested_data_; |
@@ -141,40 +139,37 @@ class NaClDOMHandler : public WebUIMessageHandler { |
bool pnacl_path_exists_; |
// A proxy for handling cross threads messages. |
- scoped_refptr<NaClDOMHandlerProxy> proxy_; |
+ scoped_refptr<NaClDomHandlerProxy> proxy_; |
- DISALLOW_COPY_AND_ASSIGN(NaClDOMHandler); |
+ DISALLOW_COPY_AND_ASSIGN(NaClDomHandler); |
}; |
-NaClDOMHandlerProxy::NaClDOMHandlerProxy(NaClDOMHandler* handler) |
+NaClDomHandlerProxy::NaClDomHandlerProxy(NaClDomHandler* handler) |
: handler_(handler) { |
} |
-void NaClDOMHandlerProxy::ValidatePnaclPath() { |
+void NaClDomHandlerProxy::ValidatePnaclPath() { |
if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { |
BrowserThread::PostTask( |
BrowserThread::FILE, FROM_HERE, |
- base::Bind(&NaClDOMHandlerProxy::ValidatePnaclPath, this)); |
+ base::Bind(&NaClDomHandlerProxy::ValidatePnaclPath, this)); |
return; |
} |
- bool is_valid = true; |
base::FilePath pnacl_path; |
bool got_path = PathService::Get(chrome::DIR_PNACL_COMPONENT, &pnacl_path); |
// The PathService may return an empty string if PNaCl is not yet installed. |
// However, do not trust that the path returned by the PathService exists. |
// Check for existence here. |
- if (!got_path || pnacl_path.empty() || !file_util::PathExists(pnacl_path)) { |
- is_valid = false; |
- } |
- ValidatePnaclPathCallback(is_valid); |
+ ValidatePnaclPathCallback( |
+ got_path && !pnacl_path.empty() && file_util::PathExists(pnacl_path)); |
} |
-void NaClDOMHandlerProxy::ValidatePnaclPathCallback(bool is_valid) { |
+void NaClDomHandlerProxy::ValidatePnaclPathCallback(bool is_valid) { |
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
BrowserThread::PostTask( |
BrowserThread::UI, FROM_HERE, |
- base::Bind(&NaClDOMHandlerProxy::ValidatePnaclPathCallback, |
+ base::Bind(&NaClDomHandlerProxy::ValidatePnaclPathCallback, |
this, is_valid)); |
return; |
} |
@@ -185,26 +180,26 @@ void NaClDOMHandlerProxy::ValidatePnaclPathCallback(bool is_valid) { |
handler_->DidValidatePnaclPath(is_valid); |
} |
-NaClDOMHandler::NaClDOMHandler() |
+NaClDomHandler::NaClDomHandler() |
: weak_ptr_factory_(this), |
page_has_requested_data_(false), |
has_plugin_info_(false), |
pnacl_path_validated_(false), |
pnacl_path_exists_(false), |
- proxy_(new NaClDOMHandlerProxy(this)) { |
+ proxy_(new NaClDomHandlerProxy(this)) { |
PluginService::GetInstance()->GetPlugins(base::Bind( |
- &NaClDOMHandler::OnGotPlugins, weak_ptr_factory_.GetWeakPtr())); |
+ &NaClDomHandler::OnGotPlugins, weak_ptr_factory_.GetWeakPtr())); |
} |
-NaClDOMHandler::~NaClDOMHandler() { |
+NaClDomHandler::~NaClDomHandler() { |
if (proxy_) |
proxy_->set_handler(NULL); |
} |
-void NaClDOMHandler::RegisterMessages() { |
+void NaClDomHandler::RegisterMessages() { |
web_ui()->RegisterMessageCallback( |
"requestNaClInfo", |
- base::Bind(&NaClDOMHandler::HandleRequestNaClInfo, |
+ base::Bind(&NaClDomHandler::HandleRequestNaClInfo, |
base::Unretained(this))); |
} |
@@ -231,18 +226,18 @@ void ListFlagStatus(ListValue* list, const std::string& flag_label, |
AddPair(list, ASCIIToUTF16(flag_label), ASCIIToUTF16("Off")); |
} |
-void NaClDOMHandler::HandleRequestNaClInfo(const ListValue* args) { |
+void NaClDomHandler::HandleRequestNaClInfo(const ListValue* args) { |
page_has_requested_data_ = true; |
MaybeRespondToPage(); |
} |
-void NaClDOMHandler::OnGotPlugins( |
+void NaClDomHandler::OnGotPlugins( |
const std::vector<webkit::WebPluginInfo>& plugins) { |
has_plugin_info_ = true; |
MaybeRespondToPage(); |
} |
-void NaClDOMHandler::PopulatePageInformation(DictionaryValue* naclInfo) { |
+void NaClDomHandler::PopulatePageInformation(DictionaryValue* naclInfo) { |
DCHECK(pnacl_path_validated_); |
// Store Key-Value pairs of about-information. |
scoped_ptr<ListValue> list(new ListValue()); |
@@ -341,13 +336,13 @@ void NaClDOMHandler::PopulatePageInformation(DictionaryValue* naclInfo) { |
naclInfo->Set("naclInfo", list.release()); |
} |
-void NaClDOMHandler::DidValidatePnaclPath(bool is_valid) { |
+void NaClDomHandler::DidValidatePnaclPath(bool is_valid) { |
pnacl_path_validated_ = true; |
pnacl_path_exists_ = is_valid; |
MaybeRespondToPage(); |
} |
-void NaClDOMHandler::MaybeRespondToPage() { |
+void NaClDomHandler::MaybeRespondToPage() { |
// Don't reply until everything is ready. The page will show a 'loading' |
// message until then. |
if (!page_has_requested_data_ || !has_plugin_info_) |
@@ -375,7 +370,7 @@ void NaClDOMHandler::MaybeRespondToPage() { |
NaClUI::NaClUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
content::RecordAction(UserMetricsAction("ViewAboutNaCl")); |
- web_ui->AddMessageHandler(new NaClDOMHandler()); |
+ web_ui->AddMessageHandler(new NaClDomHandler()); |
// Set up the about:nacl source. |
Profile* profile = Profile::FromWebUI(web_ui); |