| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/webui/plugins_ui.h" | 5 #include "chrome/browser/ui/webui/plugins_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // the security model. | 107 // the security model. |
| 108 void HandleShowTermsOfServiceMessage(const ListValue* args); | 108 void HandleShowTermsOfServiceMessage(const ListValue* args); |
| 109 | 109 |
| 110 // Callback for the "saveShowDetailsToPrefs" message. | 110 // Callback for the "saveShowDetailsToPrefs" message. |
| 111 void HandleSaveShowDetailsToPrefs(const ListValue* args); | 111 void HandleSaveShowDetailsToPrefs(const ListValue* args); |
| 112 | 112 |
| 113 // Calback for the "getShowDetails" message. | 113 // Calback for the "getShowDetails" message. |
| 114 void HandleGetShowDetails(const ListValue* args); | 114 void HandleGetShowDetails(const ListValue* args); |
| 115 | 115 |
| 116 // NotificationObserver method overrides | 116 // NotificationObserver method overrides |
| 117 void Observe(NotificationType type, | 117 void Observe(int type, |
| 118 const NotificationSource& source, | 118 const NotificationSource& source, |
| 119 const NotificationDetails& details); | 119 const NotificationDetails& details); |
| 120 | 120 |
| 121 private: | 121 private: |
| 122 // This extra wrapper is used to ensure we don't leak the ListValue* pointer | 122 // This extra wrapper is used to ensure we don't leak the ListValue* pointer |
| 123 // if the PluginsDOMHandler object goes away before the task on the UI thread | 123 // if the PluginsDOMHandler object goes away before the task on the UI thread |
| 124 // to give it the plugin list runs. | 124 // to give it the plugin list runs. |
| 125 struct ListWrapper { | 125 struct ListWrapper { |
| 126 ListValue* list; | 126 ListValue* list; |
| 127 }; | 127 }; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 144 // This pref guards the value whether about:plugins is in the details mode or | 144 // This pref guards the value whether about:plugins is in the details mode or |
| 145 // not. | 145 // not. |
| 146 BooleanPrefMember show_details_; | 146 BooleanPrefMember show_details_; |
| 147 | 147 |
| 148 DISALLOW_COPY_AND_ASSIGN(PluginsDOMHandler); | 148 DISALLOW_COPY_AND_ASSIGN(PluginsDOMHandler); |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 PluginsDOMHandler::PluginsDOMHandler() | 151 PluginsDOMHandler::PluginsDOMHandler() |
| 152 : ALLOW_THIS_IN_INITIALIZER_LIST(get_plugins_factory_(this)) { | 152 : ALLOW_THIS_IN_INITIALIZER_LIST(get_plugins_factory_(this)) { |
| 153 registrar_.Add(this, | 153 registrar_.Add(this, |
| 154 NotificationType::PLUGIN_ENABLE_STATUS_CHANGED, | 154 content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, |
| 155 NotificationService::AllSources()); | 155 NotificationService::AllSources()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 WebUIMessageHandler* PluginsDOMHandler::Attach(WebUI* web_ui) { | 158 WebUIMessageHandler* PluginsDOMHandler::Attach(WebUI* web_ui) { |
| 159 PrefService* prefs = web_ui->GetProfile()->GetPrefs(); | 159 PrefService* prefs = web_ui->GetProfile()->GetPrefs(); |
| 160 | 160 |
| 161 show_details_.Init(prefs::kPluginsShowDetails, prefs, this); | 161 show_details_.Init(prefs::kPluginsShowDetails, prefs, this); |
| 162 | 162 |
| 163 return WebUIMessageHandler::Attach(web_ui); | 163 return WebUIMessageHandler::Attach(web_ui); |
| 164 } | 164 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 return; | 240 return; |
| 241 } | 241 } |
| 242 show_details_.SetValue(details_mode == "true"); | 242 show_details_.SetValue(details_mode == "true"); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void PluginsDOMHandler::HandleGetShowDetails(const ListValue* args) { | 245 void PluginsDOMHandler::HandleGetShowDetails(const ListValue* args) { |
| 246 FundamentalValue show_details(show_details_.GetValue()); | 246 FundamentalValue show_details(show_details_.GetValue()); |
| 247 web_ui_->CallJavascriptFunction("loadShowDetailsFromPrefs", show_details); | 247 web_ui_->CallJavascriptFunction("loadShowDetailsFromPrefs", show_details); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void PluginsDOMHandler::Observe(NotificationType type, | 250 void PluginsDOMHandler::Observe(int type, |
| 251 const NotificationSource& source, | 251 const NotificationSource& source, |
| 252 const NotificationDetails& details) { | 252 const NotificationDetails& details) { |
| 253 DCHECK_EQ(NotificationType::PLUGIN_ENABLE_STATUS_CHANGED, type.value); | 253 DCHECK_EQ(content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, type); |
| 254 LoadPlugins(); | 254 LoadPlugins(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void PluginsDOMHandler::LoadPluginsOnFileThread(ListWrapper* wrapper, | 257 void PluginsDOMHandler::LoadPluginsOnFileThread(ListWrapper* wrapper, |
| 258 Task* task) { | 258 Task* task) { |
| 259 wrapper->list = PluginUpdater::GetInstance()->GetPluginGroupsData(); | 259 wrapper->list = PluginUpdater::GetInstance()->GetPluginGroupsData(); |
| 260 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, task); | 260 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, task); |
| 261 BrowserThread::PostTask( | 261 BrowserThread::PostTask( |
| 262 BrowserThread::UI, | 262 BrowserThread::UI, |
| 263 FROM_HERE, | 263 FROM_HERE, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 prefs->RegisterBooleanPref(prefs::kPluginsEnabledInternalPDF, | 322 prefs->RegisterBooleanPref(prefs::kPluginsEnabledInternalPDF, |
| 323 false, | 323 false, |
| 324 PrefService::UNSYNCABLE_PREF); | 324 PrefService::UNSYNCABLE_PREF); |
| 325 prefs->RegisterBooleanPref(prefs::kPluginsShowDetails, | 325 prefs->RegisterBooleanPref(prefs::kPluginsShowDetails, |
| 326 false, | 326 false, |
| 327 PrefService::UNSYNCABLE_PREF); | 327 PrefService::UNSYNCABLE_PREF); |
| 328 prefs->RegisterBooleanPref(prefs::kPluginsShowSetReaderDefaultInfobar, | 328 prefs->RegisterBooleanPref(prefs::kPluginsShowSetReaderDefaultInfobar, |
| 329 true, | 329 true, |
| 330 PrefService::UNSYNCABLE_PREF); | 330 PrefService::UNSYNCABLE_PREF); |
| 331 } | 331 } |
| OLD | NEW |