Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: chrome/browser/extensions/extension_management_api.cc

Issue 10626007: Move ExtensionSystem into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Master merge; moved class declaration Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/extensions/extension_management_api.h" 5 #include "chrome/browser/extensions/extension_management_api.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 ExtensionService* AsyncExtensionManagementFunction::service() { 68 ExtensionService* AsyncExtensionManagementFunction::service() {
69 return profile()->GetExtensionService(); 69 return profile()->GetExtensionService();
70 } 70 }
71 71
72 static DictionaryValue* CreateExtensionInfo(const Extension& extension, 72 static DictionaryValue* CreateExtensionInfo(const Extension& extension,
73 ExtensionService* service) { 73 ExtensionService* service) {
74 DictionaryValue* info = new DictionaryValue(); 74 DictionaryValue* info = new DictionaryValue();
75 bool enabled = service->IsExtensionEnabled(extension.id()); 75 bool enabled = service->IsExtensionEnabled(extension.id());
76 extension.GetBasicInfo(enabled, info); 76 extension.GetBasicInfo(enabled, info);
77 77
78 const extensions::ManagementPolicy* policy = ExtensionSystem::Get( 78 const extensions::ManagementPolicy* policy = extensions::ExtensionSystem::Get(
79 service->profile())->management_policy(); 79 service->profile())->management_policy();
80 info->SetBoolean(keys::kMayDisableKey, 80 info->SetBoolean(keys::kMayDisableKey,
81 policy->UserMayModifySettings(&extension, NULL)); 81 policy->UserMayModifySettings(&extension, NULL));
82 82
83 info->SetBoolean(keys::kIsAppKey, extension.is_app()); 83 info->SetBoolean(keys::kIsAppKey, extension.is_app());
84 84
85 if (!enabled) { 85 if (!enabled) {
86 extensions::ExtensionPrefs* prefs = service->extension_prefs(); 86 extensions::ExtensionPrefs* prefs = service->extension_prefs();
87 bool permissions_escalated = 87 bool permissions_escalated =
88 prefs->DidExtensionEscalatePermissions(extension.id()); 88 prefs->DidExtensionEscalatePermissions(extension.id());
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &extension_id_)); 383 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &extension_id_));
384 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &enable)); 384 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &enable));
385 385
386 const Extension* extension = service()->GetExtensionById(extension_id_, true); 386 const Extension* extension = service()->GetExtensionById(extension_id_, true);
387 if (!extension) { 387 if (!extension) {
388 error_ = ExtensionErrorUtils::FormatErrorMessage( 388 error_ = ExtensionErrorUtils::FormatErrorMessage(
389 keys::kNoExtensionError, extension_id_); 389 keys::kNoExtensionError, extension_id_);
390 return false; 390 return false;
391 } 391 }
392 392
393 const extensions::ManagementPolicy* policy = ExtensionSystem::Get( 393 const extensions::ManagementPolicy* policy = extensions::ExtensionSystem::Get(
394 profile())->management_policy(); 394 profile())->management_policy();
395 if (!policy->UserMayModifySettings(extension, NULL)) { 395 if (!policy->UserMayModifySettings(extension, NULL)) {
396 error_ = ExtensionErrorUtils::FormatErrorMessage( 396 error_ = ExtensionErrorUtils::FormatErrorMessage(
397 keys::kUserCantModifyError, extension_id_); 397 keys::kUserCantModifyError, extension_id_);
398 return false; 398 return false;
399 } 399 }
400 400
401 bool currently_enabled = service()->IsExtensionEnabled(extension_id_); 401 bool currently_enabled = service()->IsExtensionEnabled(extension_id_);
402 402
403 if (!currently_enabled && enable) { 403 if (!currently_enabled && enable) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 459 }
460 } 460 }
461 461
462 const Extension* extension = service()->GetExtensionById(extension_id_, true); 462 const Extension* extension = service()->GetExtensionById(extension_id_, true);
463 if (!extension) { 463 if (!extension) {
464 error_ = ExtensionErrorUtils::FormatErrorMessage( 464 error_ = ExtensionErrorUtils::FormatErrorMessage(
465 keys::kNoExtensionError, extension_id_); 465 keys::kNoExtensionError, extension_id_);
466 return false; 466 return false;
467 } 467 }
468 468
469 if (!ExtensionSystem::Get( 469 if (!extensions::ExtensionSystem::Get(
470 profile())->management_policy()->UserMayModifySettings(extension, NULL)) { 470 profile())->management_policy()->UserMayModifySettings(extension, NULL)) {
471 error_ = ExtensionErrorUtils::FormatErrorMessage( 471 error_ = ExtensionErrorUtils::FormatErrorMessage(
472 keys::kUserCantModifyError, extension_id_); 472 keys::kUserCantModifyError, extension_id_);
473 return false; 473 return false;
474 } 474 }
475 475
476 if (auto_confirm_for_test == DO_NOT_SKIP) { 476 if (auto_confirm_for_test == DO_NOT_SKIP) {
477 if (show_confirm_dialog) { 477 if (show_confirm_dialog) {
478 AddRef(); // Balanced in ExtensionUninstallAccepted/Canceled 478 AddRef(); // Balanced in ExtensionUninstallAccepted/Canceled
479 extension_uninstall_dialog_.reset(ExtensionUninstallDialog::Create( 479 extension_uninstall_dialog_.reset(ExtensionUninstallDialog::Create(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 ExtensionService* service = profile->GetExtensionService(); 585 ExtensionService* service = profile->GetExtensionService();
586 args.Append(CreateExtensionInfo(*extension, service)); 586 args.Append(CreateExtensionInfo(*extension, service));
587 } 587 }
588 588
589 std::string args_json; 589 std::string args_json;
590 base::JSONWriter::Write(&args, &args_json); 590 base::JSONWriter::Write(&args, &args_json);
591 591
592 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 592 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
593 event_name, args_json, NULL, GURL(), extensions::EventFilteringInfo()); 593 event_name, args_json, NULL, GURL(), extensions::EventFilteringInfo());
594 } 594 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_host.cc ('k') | chrome/browser/extensions/extension_management_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698