| 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_context_menu_model.h" | 5 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 10 #include "chrome/browser/extensions/extension_action.h" | 10 #include "chrome/browser/extensions/extension_action.h" |
| 11 #include "chrome/browser/extensions/extension_action_manager.h" | 11 #include "chrome/browser/extensions/extension_action_manager.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/extensions/extension_tab_util.h" | 13 #include "chrome/browser/extensions/extension_tab_util.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/chrome_pages.h" | 16 #include "chrome/browser/ui/chrome_pages.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/extensions/extension_constants.h" | 18 #include "chrome/common/extensions/extension_constants.h" |
| 19 #include "chrome/common/extensions/manifest_url_handler.h" | 19 #include "chrome/common/extensions/manifest_url_handler.h" |
| 20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "extensions/browser/extension_prefs.h" |
| 23 #include "extensions/browser/extension_system.h" | 24 #include "extensions/browser/extension_system.h" |
| 24 #include "extensions/browser/management_policy.h" | 25 #include "extensions/browser/management_policy.h" |
| 25 #include "extensions/common/extension.h" | 26 #include "extensions/common/extension.h" |
| 26 #include "grit/chromium_strings.h" | 27 #include "grit/chromium_strings.h" |
| 27 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 29 | 30 |
| 30 using content::OpenURLParams; | 31 using content::OpenURLParams; |
| 31 using content::Referrer; | 32 using content::Referrer; |
| 32 using content::WebContents; | 33 using content::WebContents; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 content::PAGE_TRANSITION_LINK, false); | 110 content::PAGE_TRANSITION_LINK, false); |
| 110 browser_->OpenURL(params); | 111 browser_->OpenURL(params); |
| 111 break; | 112 break; |
| 112 } | 113 } |
| 113 case CONFIGURE: | 114 case CONFIGURE: |
| 114 DCHECK(!extensions::ManifestURL::GetOptionsPage(extension).is_empty()); | 115 DCHECK(!extensions::ManifestURL::GetOptionsPage(extension).is_empty()); |
| 115 extensions::ExtensionTabUtil::OpenOptionsPage(extension, browser_); | 116 extensions::ExtensionTabUtil::OpenOptionsPage(extension, browser_); |
| 116 break; | 117 break; |
| 117 case HIDE: { | 118 case HIDE: { |
| 118 extensions::ExtensionActionAPI::SetBrowserActionVisibility( | 119 extensions::ExtensionActionAPI::SetBrowserActionVisibility( |
| 119 extensions::ExtensionSystem::Get(profile_)-> | 120 extensions::ExtensionPrefs::Get(profile_), extension->id(), false); |
| 120 extension_service()->extension_prefs(), | |
| 121 extension->id(), | |
| 122 false); | |
| 123 break; | 121 break; |
| 124 } | 122 } |
| 125 case UNINSTALL: { | 123 case UNINSTALL: { |
| 126 AddRef(); // Balanced in Accepted() and Canceled() | 124 AddRef(); // Balanced in Accepted() and Canceled() |
| 127 extension_uninstall_dialog_.reset( | 125 extension_uninstall_dialog_.reset( |
| 128 ExtensionUninstallDialog::Create(profile_, browser_, this)); | 126 ExtensionUninstallDialog::Create(profile_, browser_, this)); |
| 129 extension_uninstall_dialog_->ConfirmUninstall(extension); | 127 extension_uninstall_dialog_->ConfirmUninstall(extension); |
| 130 break; | 128 break; |
| 131 } | 129 } |
| 132 case MANAGE: { | 130 case MANAGE: { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON); | 176 AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON); |
| 179 AddSeparator(ui::NORMAL_SEPARATOR); | 177 AddSeparator(ui::NORMAL_SEPARATOR); |
| 180 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSION); | 178 AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSION); |
| 181 } | 179 } |
| 182 | 180 |
| 183 const Extension* ExtensionContextMenuModel::GetExtension() const { | 181 const Extension* ExtensionContextMenuModel::GetExtension() const { |
| 184 ExtensionService* extension_service = | 182 ExtensionService* extension_service = |
| 185 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 183 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 186 return extension_service->GetExtensionById(extension_id_, false); | 184 return extension_service->GetExtensionById(extension_id_, false); |
| 187 } | 185 } |
| OLD | NEW |