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" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 extension.GetBasicInfo(enabled, info); | 76 extension.GetBasicInfo(enabled, info); |
77 | 77 |
78 const extensions::ManagementPolicy* policy = ExtensionSystem::Get( | 78 const extensions::ManagementPolicy* policy = 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 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()); |
89 const char* reason = permissions_escalated ? | 89 const char* reason = permissions_escalated ? |
90 keys::kDisabledReasonPermissionsIncrease : keys::kDisabledReasonUnknown; | 90 keys::kDisabledReasonPermissionsIncrease : keys::kDisabledReasonUnknown; |
91 info->SetString(keys::kDisabledReasonKey, reason); | 91 info->SetString(keys::kDisabledReasonKey, reason); |
92 } | 92 } |
93 | 93 |
94 if (!extension.update_url().is_empty()) | 94 if (!extension.update_url().is_empty()) |
95 info->SetString(keys::kUpdateUrlKey, | 95 info->SetString(keys::kUpdateUrlKey, |
96 extension.update_url().possibly_invalid_spec()); | 96 extension.update_url().possibly_invalid_spec()); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNotAnAppError, | 354 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNotAnAppError, |
355 extension_id); | 355 extension_id); |
356 return false; | 356 return false; |
357 } | 357 } |
358 | 358 |
359 // Look at prefs to find the right launch container. | 359 // Look at prefs to find the right launch container. |
360 // |default_pref_value| is set to LAUNCH_REGULAR so that if | 360 // |default_pref_value| is set to LAUNCH_REGULAR so that if |
361 // the user has not set a preference, we open the app in a tab. | 361 // the user has not set a preference, we open the app in a tab. |
362 extension_misc::LaunchContainer launch_container = | 362 extension_misc::LaunchContainer launch_container = |
363 service()->extension_prefs()->GetLaunchContainer( | 363 service()->extension_prefs()->GetLaunchContainer( |
364 extension, ExtensionPrefs::LAUNCH_DEFAULT); | 364 extension, extensions::ExtensionPrefs::LAUNCH_DEFAULT); |
365 application_launch::OpenApplication(profile(), extension, launch_container, | 365 application_launch::OpenApplication(profile(), extension, launch_container, |
366 GURL(), NEW_FOREGROUND_TAB, NULL); | 366 GURL(), NEW_FOREGROUND_TAB, NULL); |
367 #if !defined(OS_ANDROID) | 367 #if !defined(OS_ANDROID) |
368 AppLauncherHandler::RecordAppLaunchType( | 368 AppLauncherHandler::RecordAppLaunchType( |
369 extension_misc::APP_LAUNCH_EXTENSION_API); | 369 extension_misc::APP_LAUNCH_EXTENSION_API); |
370 #endif | 370 #endif |
371 | 371 |
372 return true; | 372 return true; |
373 } | 373 } |
374 | 374 |
(...skipping 19 matching lines...) Expand all Loading... |
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) { |
404 ExtensionPrefs* prefs = service()->extension_prefs(); | 404 extensions::ExtensionPrefs* prefs = service()->extension_prefs(); |
405 if (prefs->DidExtensionEscalatePermissions(extension_id_)) { | 405 if (prefs->DidExtensionEscalatePermissions(extension_id_)) { |
406 if (!user_gesture()) { | 406 if (!user_gesture()) { |
407 error_ = keys::kGestureNeededForEscalationError; | 407 error_ = keys::kGestureNeededForEscalationError; |
408 return false; | 408 return false; |
409 } | 409 } |
410 AddRef(); // Matched in InstallUIProceed/InstallUIAbort | 410 AddRef(); // Matched in InstallUIProceed/InstallUIAbort |
411 install_prompt_.reset( | 411 install_prompt_.reset( |
412 chrome::CreateExtensionInstallPromptWithBrowser(GetCurrentBrowser())); | 412 chrome::CreateExtensionInstallPromptWithBrowser(GetCurrentBrowser())); |
413 install_prompt_->ConfirmReEnable(this, extension); | 413 install_prompt_->ConfirmReEnable(this, extension); |
414 return true; | 414 return true; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |