| 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/ui/app_list/extension_app_item.h" | 5 #include "chrome/browser/ui/app_list/extension_app_item.h" |
| 6 | 6 |
| 7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/extensions/context_menu_matcher.h" | 8 #include "chrome/browser/extensions/context_menu_matcher.h" |
| 9 #include "chrome/browser/extensions/extension_prefs.h" | 9 #include "chrome/browser/extensions/extension_prefs.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/extensions/extension_sorting.h" | 11 #include "chrome/browser/extensions/extension_sorting.h" |
| 12 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
| 13 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 13 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 14 #include "chrome/browser/extensions/management_policy.h" | 14 #include "chrome/browser/extensions/management_policy.h" |
| 15 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 15 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/app_list/app_list_controller.h" | 18 #include "chrome/browser/ui/app_list/app_list_controller.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_navigator.h" | 20 #include "chrome/browser/ui/browser_navigator.h" |
| 21 #include "chrome/browser/ui/browser_tabstrip.h" | 21 #include "chrome/browser/ui/browser_tabstrip.h" |
| 22 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 23 #include "chrome/common/extensions/api/extension_urls/extension_urls_handler.h" |
| 23 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 24 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
| 25 #include "chrome/common/extensions/extension_icon_set.h" | 26 #include "chrome/common/extensions/extension_icon_set.h" |
| 26 #include "content/public/common/context_menu_params.h" | 27 #include "content/public/common/context_menu_params.h" |
| 27 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| 28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 29 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 31 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 32 #include "ui/gfx/canvas.h" | 33 #include "ui/gfx/canvas.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 icon_canvas.DrawImageInt(icon, kIconOffset, kIconOffset + kVerticalAdjust); | 262 icon_canvas.DrawImageInt(icon, kIconOffset, kIconOffset + kVerticalAdjust); |
| 262 SetIcon(gfx::ImageSkia(icon_canvas.ExtractImageRep())); | 263 SetIcon(gfx::ImageSkia(icon_canvas.ExtractImageRep())); |
| 263 } | 264 } |
| 264 | 265 |
| 265 void ExtensionAppItem::ShowExtensionOptions() { | 266 void ExtensionAppItem::ShowExtensionOptions() { |
| 266 const Extension* extension = GetExtension(); | 267 const Extension* extension = GetExtension(); |
| 267 if (!extension) | 268 if (!extension) |
| 268 return; | 269 return; |
| 269 | 270 |
| 270 chrome::NavigateParams params(profile_, | 271 chrome::NavigateParams params(profile_, |
| 271 extension->options_url(), | 272 ExtensionURL::GetOptionsURL(extension), |
| 272 content::PAGE_TRANSITION_LINK); | 273 content::PAGE_TRANSITION_LINK); |
| 273 chrome::Navigate(¶ms); | 274 chrome::Navigate(¶ms); |
| 274 } | 275 } |
| 275 | 276 |
| 276 void ExtensionAppItem::ShowExtensionDetails() { | 277 void ExtensionAppItem::ShowExtensionDetails() { |
| 277 const Extension* extension = GetExtension(); | 278 const Extension* extension = GetExtension(); |
| 278 if (!extension) | 279 if (!extension) |
| 279 return; | 280 return; |
| 280 | 281 |
| 281 chrome::NavigateParams params(profile_, | 282 chrome::NavigateParams params(profile_, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 } | 331 } |
| 331 return false; | 332 return false; |
| 332 } | 333 } |
| 333 | 334 |
| 334 bool ExtensionAppItem::IsCommandIdEnabled(int command_id) const { | 335 bool ExtensionAppItem::IsCommandIdEnabled(int command_id) const { |
| 335 if (command_id == TOGGLE_PIN) { | 336 if (command_id == TOGGLE_PIN) { |
| 336 return controller_->CanPin(); | 337 return controller_->CanPin(); |
| 337 } else if (command_id == OPTIONS) { | 338 } else if (command_id == OPTIONS) { |
| 338 const Extension* extension = GetExtension(); | 339 const Extension* extension = GetExtension(); |
| 339 return IsExtensionEnabled(profile_, extension_id_) && extension && | 340 return IsExtensionEnabled(profile_, extension_id_) && extension && |
| 340 !extension->options_url().is_empty(); | 341 !ExtensionURL::GetOptionsURL(extension).is_empty(); |
| 341 } else if (command_id == UNINSTALL) { | 342 } else if (command_id == UNINSTALL) { |
| 342 const Extension* extension = GetExtension(); | 343 const Extension* extension = GetExtension(); |
| 343 const extensions::ManagementPolicy* policy = | 344 const extensions::ManagementPolicy* policy = |
| 344 extensions::ExtensionSystem::Get(profile_)->management_policy(); | 345 extensions::ExtensionSystem::Get(profile_)->management_policy(); |
| 345 return extension && | 346 return extension && |
| 346 policy->UserMayModifySettings(extension, NULL); | 347 policy->UserMayModifySettings(extension, NULL); |
| 347 } else if (command_id == DETAILS) { | 348 } else if (command_id == DETAILS) { |
| 348 const Extension* extension = GetExtension(); | 349 const Extension* extension = GetExtension(); |
| 349 return extension && extension->from_webstore(); | 350 return extension && extension->from_webstore(); |
| 350 } else if (command_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && | 351 } else if (command_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 } | 497 } |
| 497 | 498 |
| 498 context_menu_model_->AddItemWithStringId(UNINSTALL, | 499 context_menu_model_->AddItemWithStringId(UNINSTALL, |
| 499 extension->is_platform_app() ? | 500 extension->is_platform_app() ? |
| 500 IDS_APP_LIST_UNINSTALL_ITEM : | 501 IDS_APP_LIST_UNINSTALL_ITEM : |
| 501 IDS_EXTENSIONS_UNINSTALL); | 502 IDS_EXTENSIONS_UNINSTALL); |
| 502 } | 503 } |
| 503 | 504 |
| 504 return context_menu_model_.get(); | 505 return context_menu_model_.get(); |
| 505 } | 506 } |
| OLD | NEW |