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/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" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "chrome/browser/extensions/extension_event_names.h" | 16 #include "chrome/browser/extensions/extension_event_names.h" |
17 #include "chrome/browser/extensions/extension_event_router.h" | 17 #include "chrome/browser/extensions/extension_event_router.h" |
18 #include "chrome/browser/extensions/extension_management_api_constants.h" | 18 #include "chrome/browser/extensions/extension_management_api_constants.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 22 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
23 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | |
24 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
25 #include "chrome/common/chrome_utility_messages.h" | 24 #include "chrome/common/chrome_utility_messages.h" |
26 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
27 #include "chrome/common/extensions/extension_constants.h" | 26 #include "chrome/common/extensions/extension_constants.h" |
28 #include "chrome/common/extensions/extension_error_utils.h" | 27 #include "chrome/common/extensions/extension_error_utils.h" |
29 #include "chrome/common/extensions/extension_icon_set.h" | 28 #include "chrome/common/extensions/extension_icon_set.h" |
30 #include "chrome/common/extensions/url_pattern.h" | 29 #include "chrome/common/extensions/url_pattern.h" |
31 #include "content/public/browser/notification_details.h" | 30 #include "content/public/browser/notification_details.h" |
32 #include "content/public/browser/notification_source.h" | 31 #include "content/public/browser/notification_source.h" |
33 #include "content/public/browser/utility_process_host.h" | 32 #include "content/public/browser/utility_process_host.h" |
34 #include "content/public/browser/utility_process_host_client.h" | 33 #include "content/public/browser/utility_process_host_client.h" |
35 | 34 |
| 35 #if !defined(OS_ANDROID) |
| 36 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
| 37 #endif |
| 38 |
36 using base::IntToString; | 39 using base::IntToString; |
37 using content::BrowserThread; | 40 using content::BrowserThread; |
38 using content::UtilityProcessHost; | 41 using content::UtilityProcessHost; |
39 using content::UtilityProcessHostClient; | 42 using content::UtilityProcessHostClient; |
40 | 43 |
41 namespace events = extension_event_names; | 44 namespace events = extension_event_names; |
42 namespace keys = extension_management_api_constants; | 45 namespace keys = extension_management_api_constants; |
43 | 46 |
44 ExtensionService* ExtensionManagementFunction::service() { | 47 ExtensionService* ExtensionManagementFunction::service() { |
45 return profile()->GetExtensionService(); | 48 return profile()->GetExtensionService(); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 334 } |
332 | 335 |
333 // Look at prefs to find the right launch container. | 336 // Look at prefs to find the right launch container. |
334 // |default_pref_value| is set to LAUNCH_REGULAR so that if | 337 // |default_pref_value| is set to LAUNCH_REGULAR so that if |
335 // the user has not set a preference, we open the app in a tab. | 338 // the user has not set a preference, we open the app in a tab. |
336 extension_misc::LaunchContainer launch_container = | 339 extension_misc::LaunchContainer launch_container = |
337 service()->extension_prefs()->GetLaunchContainer( | 340 service()->extension_prefs()->GetLaunchContainer( |
338 extension, ExtensionPrefs::LAUNCH_DEFAULT); | 341 extension, ExtensionPrefs::LAUNCH_DEFAULT); |
339 Browser::OpenApplication(profile(), extension, launch_container, GURL(), | 342 Browser::OpenApplication(profile(), extension, launch_container, GURL(), |
340 NEW_FOREGROUND_TAB); | 343 NEW_FOREGROUND_TAB); |
| 344 #if !defined(OS_ANDROID) |
341 AppLauncherHandler::RecordAppLaunchType( | 345 AppLauncherHandler::RecordAppLaunchType( |
342 extension_misc::APP_LAUNCH_EXTENSION_API); | 346 extension_misc::APP_LAUNCH_EXTENSION_API); |
| 347 #endif |
343 | 348 |
344 return true; | 349 return true; |
345 } | 350 } |
346 | 351 |
347 SetEnabledFunction::SetEnabledFunction() {} | 352 SetEnabledFunction::SetEnabledFunction() {} |
348 | 353 |
349 SetEnabledFunction::~SetEnabledFunction() {} | 354 SetEnabledFunction::~SetEnabledFunction() {} |
350 | 355 |
351 bool SetEnabledFunction::RunImpl() { | 356 bool SetEnabledFunction::RunImpl() { |
352 bool enable; | 357 bool enable; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 ExtensionService* service = profile->GetExtensionService(); | 497 ExtensionService* service = profile->GetExtensionService(); |
493 args.Append(CreateExtensionInfo(*extension, service)); | 498 args.Append(CreateExtensionInfo(*extension, service)); |
494 } | 499 } |
495 | 500 |
496 std::string args_json; | 501 std::string args_json; |
497 base::JSONWriter::Write(&args, &args_json); | 502 base::JSONWriter::Write(&args, &args_json); |
498 | 503 |
499 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 504 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
500 event_name, args_json, NULL, GURL()); | 505 event_name, args_json, NULL, GURL()); |
501 } | 506 } |
OLD | NEW |