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

Side by Side Diff: chrome/browser/extensions/api/management/management_api.cc

Issue 398083002: Add "UninstallReason" parameter to ExtensionRegistryObserver::OnExtensionUninstalled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix header file. Created 6 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/api/management/management_api.h" 5 #include "chrome/browser/extensions/api/management/management_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 26 matching lines...) Expand all
37 #include "chrome/common/extensions/extension_constants.h" 37 #include "chrome/common/extensions/extension_constants.h"
38 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 38 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
39 #include "chrome/common/extensions/manifest_url_handler.h" 39 #include "chrome/common/extensions/manifest_url_handler.h"
40 #include "content/public/browser/utility_process_host.h" 40 #include "content/public/browser/utility_process_host.h"
41 #include "content/public/browser/utility_process_host_client.h" 41 #include "content/public/browser/utility_process_host_client.h"
42 #include "extensions/browser/event_router.h" 42 #include "extensions/browser/event_router.h"
43 #include "extensions/browser/extension_prefs.h" 43 #include "extensions/browser/extension_prefs.h"
44 #include "extensions/browser/extension_registry.h" 44 #include "extensions/browser/extension_registry.h"
45 #include "extensions/browser/extension_system.h" 45 #include "extensions/browser/extension_system.h"
46 #include "extensions/browser/management_policy.h" 46 #include "extensions/browser/management_policy.h"
47 #include "extensions/browser/uninstall_reason.h"
47 #include "extensions/common/constants.h" 48 #include "extensions/common/constants.h"
48 #include "extensions/common/error_utils.h" 49 #include "extensions/common/error_utils.h"
49 #include "extensions/common/extension.h" 50 #include "extensions/common/extension.h"
50 #include "extensions/common/extension_icon_set.h" 51 #include "extensions/common/extension_icon_set.h"
51 #include "extensions/common/manifest_handlers/icons_handler.h" 52 #include "extensions/common/manifest_handlers/icons_handler.h"
52 #include "extensions/common/manifest_handlers/offline_enabled_info.h" 53 #include "extensions/common/manifest_handlers/offline_enabled_info.h"
53 #include "extensions/common/permissions/permission_set.h" 54 #include "extensions/common/permissions/permission_set.h"
54 #include "extensions/common/permissions/permissions_data.h" 55 #include "extensions/common/permissions/permissions_data.h"
55 #include "extensions/common/url_pattern.h" 56 #include "extensions/common/url_pattern.h"
56 57
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 // showing. Do nothing in that case. 641 // showing. Do nothing in that case.
641 ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile()); 642 ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile());
642 const Extension* extension = registry->GetExtensionById( 643 const Extension* extension = registry->GetExtensionById(
643 extension_id_, ExtensionRegistry::EVERYTHING); 644 extension_id_, ExtensionRegistry::EVERYTHING);
644 if (!extension) { 645 if (!extension) {
645 error_ = ErrorUtils::FormatErrorMessage(keys::kNoExtensionError, 646 error_ = ErrorUtils::FormatErrorMessage(keys::kNoExtensionError,
646 extension_id_); 647 extension_id_);
647 SendResponse(false); 648 SendResponse(false);
648 } else { 649 } else {
649 bool success = service()->UninstallExtension( 650 bool success = service()->UninstallExtension(
650 extension_id_, 651 extension_id_, extensions::UNINSTALL_REASON_MANAGEMENT_API, NULL);
651 ExtensionService::UNINSTALL_REASON_MANAGEMENT_API,
652 NULL);
653 652
654 // TODO set error_ if !success 653 // TODO set error_ if !success
655 SendResponse(success); 654 SendResponse(success);
656 } 655 }
657 } else { 656 } else {
658 error_ = ErrorUtils::FormatErrorMessage( 657 error_ = ErrorUtils::FormatErrorMessage(
659 keys::kUninstallCanceledError, extension_id_); 658 keys::kUninstallCanceledError, extension_id_);
660 SendResponse(false); 659 SendResponse(false);
661 } 660 }
662 } 661 }
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 946
948 void ManagementEventRouter::OnExtensionInstalled( 947 void ManagementEventRouter::OnExtensionInstalled(
949 content::BrowserContext* browser_context, 948 content::BrowserContext* browser_context,
950 const Extension* extension, 949 const Extension* extension,
951 bool is_update) { 950 bool is_update) {
952 BroadcastEvent(extension, management::OnInstalled::kEventName); 951 BroadcastEvent(extension, management::OnInstalled::kEventName);
953 } 952 }
954 953
955 void ManagementEventRouter::OnExtensionUninstalled( 954 void ManagementEventRouter::OnExtensionUninstalled(
956 content::BrowserContext* browser_context, 955 content::BrowserContext* browser_context,
957 const Extension* extension) { 956 const Extension* extension,
957 extensions::UninstallReason reason) {
958 BroadcastEvent(extension, management::OnUninstalled::kEventName); 958 BroadcastEvent(extension, management::OnUninstalled::kEventName);
959 } 959 }
960 960
961 void ManagementEventRouter::BroadcastEvent(const Extension* extension, 961 void ManagementEventRouter::BroadcastEvent(const Extension* extension,
962 const char* event_name) { 962 const char* event_name) {
963 if (ui_util::ShouldNotBeVisible(extension, browser_context_)) 963 if (ui_util::ShouldNotBeVisible(extension, browser_context_))
964 return; // Don't dispatch events for built-in extenions. 964 return; // Don't dispatch events for built-in extenions.
965 scoped_ptr<base::ListValue> args(new base::ListValue()); 965 scoped_ptr<base::ListValue> args(new base::ListValue());
966 if (event_name == management::OnUninstalled::kEventName) { 966 if (event_name == management::OnUninstalled::kEventName) {
967 args->Append(new base::StringValue(extension->id())); 967 args->Append(new base::StringValue(extension->id()));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 ManagementAPI::GetFactoryInstance() { 999 ManagementAPI::GetFactoryInstance() {
1000 return g_factory.Pointer(); 1000 return g_factory.Pointer();
1001 } 1001 }
1002 1002
1003 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { 1003 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) {
1004 management_event_router_.reset(new ManagementEventRouter(browser_context_)); 1004 management_event_router_.reset(new ManagementEventRouter(browser_context_));
1005 EventRouter::Get(browser_context_)->UnregisterObserver(this); 1005 EventRouter::Get(browser_context_)->UnregisterObserver(this);
1006 } 1006 }
1007 1007
1008 } // namespace extensions 1008 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698