| 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/extensions/api/management/management_api.h" | 5 #include "chrome/browser/extensions/api/management/management_api.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
| 23 #include "chrome/browser/extensions/api/management/management_api_constants.h" | 23 #include "chrome/browser/extensions/api/management/management_api_constants.h" |
| 24 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
| 25 #include "chrome/browser/extensions/extension_system.h" | 25 #include "chrome/browser/extensions/extension_system.h" |
| 26 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 26 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 27 #include "chrome/browser/extensions/launch_util.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/ui/extensions/application_launch.h" | 29 #include "chrome/browser/ui/extensions/application_launch.h" |
| 29 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 30 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 30 #include "chrome/common/chrome_utility_messages.h" | 31 #include "chrome/common/chrome_utility_messages.h" |
| 31 #include "chrome/common/extensions/api/management.h" | 32 #include "chrome/common/extensions/api/management.h" |
| 32 #include "chrome/common/extensions/extension_icon_set.h" | 33 #include "chrome/common/extensions/extension_icon_set.h" |
| 33 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 34 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 34 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" | 35 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
| 35 #include "chrome/common/extensions/manifest_url_handler.h" | 36 #include "chrome/common/extensions/manifest_url_handler.h" |
| 36 #include "content/public/browser/notification_details.h" | 37 #include "content/public/browser/notification_details.h" |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 if (!extension->is_app()) { | 429 if (!extension->is_app()) { |
| 429 error_ = ErrorUtils::FormatErrorMessage(keys::kNotAnAppError, | 430 error_ = ErrorUtils::FormatErrorMessage(keys::kNotAnAppError, |
| 430 params->id); | 431 params->id); |
| 431 return false; | 432 return false; |
| 432 } | 433 } |
| 433 | 434 |
| 434 // Look at prefs to find the right launch container. | 435 // Look at prefs to find the right launch container. |
| 435 // If the user has not set a preference, the default launch value will be | 436 // If the user has not set a preference, the default launch value will be |
| 436 // returned. | 437 // returned. |
| 437 LaunchContainer launch_container = | 438 LaunchContainer launch_container = |
| 438 service()->extension_prefs()->GetLaunchContainer(extension); | 439 GetLaunchContainer(service()->extension_prefs(), extension); |
| 439 OpenApplication(AppLaunchParams( | 440 OpenApplication(AppLaunchParams( |
| 440 GetProfile(), extension, launch_container, NEW_FOREGROUND_TAB)); | 441 GetProfile(), extension, launch_container, NEW_FOREGROUND_TAB)); |
| 441 #if !defined(OS_ANDROID) | 442 #if !defined(OS_ANDROID) |
| 442 CoreAppLauncherHandler::RecordAppLaunchType( | 443 CoreAppLauncherHandler::RecordAppLaunchType( |
| 443 extension_misc::APP_LAUNCH_EXTENSION_API, | 444 extension_misc::APP_LAUNCH_EXTENSION_API, |
| 444 extension->GetType()); | 445 extension->GetType()); |
| 445 #endif | 446 #endif |
| 446 | 447 |
| 447 return true; | 448 return true; |
| 448 } | 449 } |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 ProfileKeyedAPIFactory<ManagementAPI>* ManagementAPI::GetFactoryInstance() { | 724 ProfileKeyedAPIFactory<ManagementAPI>* ManagementAPI::GetFactoryInstance() { |
| 724 return &g_factory.Get(); | 725 return &g_factory.Get(); |
| 725 } | 726 } |
| 726 | 727 |
| 727 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { | 728 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 728 management_event_router_.reset(new ManagementEventRouter(profile_)); | 729 management_event_router_.reset(new ManagementEventRouter(profile_)); |
| 729 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 730 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
| 730 } | 731 } |
| 731 | 732 |
| 732 } // namespace extensions | 733 } // namespace extensions |
| OLD | NEW |