| 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/ui/webui/options/extension_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/extension_settings_handler.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 extension != extensions->end(); ++extension) { | 172 extension != extensions->end(); ++extension) { |
| 173 if (ShouldShowExtension(*extension)) { | 173 if (ShouldShowExtension(*extension)) { |
| 174 extensions_list->Append(CreateExtensionDetailValue( | 174 extensions_list->Append(CreateExtensionDetailValue( |
| 175 extension_service_, | 175 extension_service_, |
| 176 *extension, | 176 *extension, |
| 177 GetActivePagesForExtension(*extension), | 177 GetActivePagesForExtension(*extension), |
| 178 warnings, | 178 warnings, |
| 179 false, false)); // enabled, terminated | 179 false, false)); // enabled, terminated |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 extensions = extension_service_->terminated_extensions(); | |
| 183 std::vector<ExtensionPage> empty_pages; | |
| 184 for (ExtensionSet::const_iterator extension = extensions->begin(); | |
| 185 extension != extensions->end(); ++extension) { | |
| 186 if (ShouldShowExtension(*extension)) { | |
| 187 extensions_list->Append(CreateExtensionDetailValue( | |
| 188 extension_service_, | |
| 189 *extension, | |
| 190 empty_pages, // Terminated process has no active pages. | |
| 191 warnings, | |
| 192 false, true)); // enabled, terminated | |
| 193 } | |
| 194 } | |
| 195 results.Set("extensions", extensions_list); | 182 results.Set("extensions", extensions_list); |
| 196 | 183 |
| 197 Profile* profile = Profile::FromWebUI(web_ui()); | 184 Profile* profile = Profile::FromWebUI(web_ui()); |
| 198 bool developer_mode = | 185 bool developer_mode = |
| 199 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode); | 186 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode); |
| 200 results.SetBoolean("developerMode", developer_mode); | 187 results.SetBoolean("developerMode", developer_mode); |
| 201 | 188 |
| 202 web_ui()->CallJavascriptFunction("ExtensionSettings.returnExtensionsData", | 189 web_ui()->CallJavascriptFunction("ExtensionSettings.returnExtensionsData", |
| 203 results); | 190 results); |
| 204 | 191 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 347 |
| 361 extension_service_->SetAllowFileAccess(extension, allow_str == "true"); | 348 extension_service_->SetAllowFileAccess(extension, allow_str == "true"); |
| 362 } | 349 } |
| 363 | 350 |
| 364 void ExtensionSettingsHandler::HandleUninstallMessage(const ListValue* args) { | 351 void ExtensionSettingsHandler::HandleUninstallMessage(const ListValue* args) { |
| 365 std::string extension_id = UTF16ToUTF8(ExtractStringValue(args)); | 352 std::string extension_id = UTF16ToUTF8(ExtractStringValue(args)); |
| 366 CHECK(!extension_id.empty()); | 353 CHECK(!extension_id.empty()); |
| 367 const Extension* extension = | 354 const Extension* extension = |
| 368 extension_service_->GetExtensionById(extension_id, true); | 355 extension_service_->GetExtensionById(extension_id, true); |
| 369 if (!extension) | 356 if (!extension) |
| 370 extension = extension_service_->GetTerminatedExtension(extension_id); | |
| 371 if (!extension) | |
| 372 return; | 357 return; |
| 373 | 358 |
| 374 if (!Extension::UserMayDisable(extension->location())) { | 359 if (!Extension::UserMayDisable(extension->location())) { |
| 375 LOG(ERROR) << "Attempt to uninstall an extension that is non-usermanagable " | 360 LOG(ERROR) << "Attempt to uninstall an extension that is non-usermanagable " |
| 376 << "was made. Extension id : " << extension->id(); | 361 << "was made. Extension id : " << extension->id(); |
| 377 return; | 362 return; |
| 378 } | 363 } |
| 379 | 364 |
| 380 if (!extension_id_prompting_.empty()) | 365 if (!extension_id_prompting_.empty()) |
| 381 return; // Only one prompt at a time. | 366 return; // Only one prompt at a time. |
| 382 | 367 |
| 383 extension_id_prompting_ = extension_id; | 368 extension_id_prompting_ = extension_id; |
| 384 | 369 |
| 385 GetExtensionUninstallDialog()->ConfirmUninstall(extension); | 370 GetExtensionUninstallDialog()->ConfirmUninstall(extension); |
| 386 } | 371 } |
| 387 | 372 |
| 388 void ExtensionSettingsHandler::ExtensionUninstallAccepted() { | 373 void ExtensionSettingsHandler::ExtensionUninstallAccepted() { |
| 389 DCHECK(!extension_id_prompting_.empty()); | 374 DCHECK(!extension_id_prompting_.empty()); |
| 390 | 375 |
| 391 bool was_terminated = false; | |
| 392 | |
| 393 // The extension can be uninstalled in another window while the UI was | 376 // The extension can be uninstalled in another window while the UI was |
| 394 // showing. Do nothing in that case. | 377 // showing. Do nothing in that case. |
| 395 const Extension* extension = | 378 const Extension* extension = |
| 396 extension_service_->GetExtensionById(extension_id_prompting_, true); | 379 extension_service_->GetExtensionById(extension_id_prompting_, true); |
| 397 if (!extension) { | |
| 398 extension = extension_service_->GetTerminatedExtension( | |
| 399 extension_id_prompting_); | |
| 400 was_terminated = true; | |
| 401 } | |
| 402 if (!extension) | 380 if (!extension) |
| 403 return; | 381 return; |
| 404 | 382 |
| 405 extension_service_->UninstallExtension(extension_id_prompting_, | 383 extension_service_->UninstallExtension(extension_id_prompting_, |
| 406 false, // External uninstall. | 384 false, // External uninstall. |
| 407 NULL); // Error. | 385 NULL); // Error. |
| 408 extension_id_prompting_ = ""; | 386 extension_id_prompting_ = ""; |
| 409 | |
| 410 // There will be no EXTENSION_UNLOADED notification for terminated | |
| 411 // extensions as they were already unloaded. | |
| 412 if (was_terminated) | |
| 413 HandleRequestExtensionsData(NULL); | |
| 414 } | 387 } |
| 415 | 388 |
| 416 void ExtensionSettingsHandler::ExtensionUninstallCanceled() { | 389 void ExtensionSettingsHandler::ExtensionUninstallCanceled() { |
| 417 extension_id_prompting_ = ""; | 390 extension_id_prompting_ = ""; |
| 418 } | 391 } |
| 419 | 392 |
| 420 void ExtensionSettingsHandler::HandleOptionsMessage(const ListValue* args) { | 393 void ExtensionSettingsHandler::HandleOptionsMessage(const ListValue* args) { |
| 421 const Extension* extension = GetExtension(args); | 394 const Extension* extension = GetExtension(args); |
| 422 if (!extension || extension->options_url().is_empty()) | 395 if (!extension || extension->options_url().is_empty()) |
| 423 return; | 396 return; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 } | 611 } |
| 639 | 612 |
| 640 void ExtensionSettingsHandler::MaybeUpdateAfterNotification() { | 613 void ExtensionSettingsHandler::MaybeUpdateAfterNotification() { |
| 641 WebContents* contents = web_ui()->GetWebContents(); | 614 WebContents* contents = web_ui()->GetWebContents(); |
| 642 if (!ignore_notifications_ && contents && contents->GetRenderViewHost()) | 615 if (!ignore_notifications_ && contents && contents->GetRenderViewHost()) |
| 643 HandleRequestExtensionsData(NULL); | 616 HandleRequestExtensionsData(NULL); |
| 644 deleting_rvh_ = NULL; | 617 deleting_rvh_ = NULL; |
| 645 } | 618 } |
| 646 | 619 |
| 647 // Static | 620 // Static |
| 621 // TODO(aa): Remove |terminated| param. Doesn't seem to be in use. |
| 648 DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue( | 622 DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue( |
| 649 ExtensionService* service, const Extension* extension, | 623 ExtensionService* service, const Extension* extension, |
| 650 const std::vector<ExtensionPage>& pages, | 624 const std::vector<ExtensionPage>& pages, |
| 651 const ExtensionWarningSet* warnings_set, | 625 const ExtensionWarningSet* warnings_set, |
| 652 bool enabled, bool terminated) { | 626 bool enabled, bool terminated) { |
| 653 DictionaryValue* extension_data = new DictionaryValue(); | 627 DictionaryValue* extension_data = new DictionaryValue(); |
| 654 GURL icon = | 628 GURL icon = |
| 655 ExtensionIconSource::GetIconURL(extension, | 629 ExtensionIconSource::GetIconURL(extension, |
| 656 Extension::EXTENSION_ICON_MEDIUM, | 630 Extension::EXTENSION_ICON_MEDIUM, |
| 657 ExtensionIconSet::MATCH_BIGGER, | 631 ExtensionIconSet::MATCH_BIGGER, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 chrome::VIEW_TYPE_EXTENSION_DIALOG == host_type) | 746 chrome::VIEW_TYPE_EXTENSION_DIALOG == host_type) |
| 773 continue; | 747 continue; |
| 774 | 748 |
| 775 GURL url = host->delegate()->GetURL(); | 749 GURL url = host->delegate()->GetURL(); |
| 776 content::RenderProcessHost* process = host->process(); | 750 content::RenderProcessHost* process = host->process(); |
| 777 result->push_back( | 751 result->push_back( |
| 778 ExtensionPage(url, process->GetID(), host->routing_id(), | 752 ExtensionPage(url, process->GetID(), host->routing_id(), |
| 779 process->GetBrowserContext()->IsOffTheRecord())); | 753 process->GetBrowserContext()->IsOffTheRecord())); |
| 780 } | 754 } |
| 781 } | 755 } |
| OLD | NEW |