Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(772)

Side by Side Diff: chrome/browser/extensions/api/management/chrome_management_api_delegate.cc

Issue 1225693009: Show extension uninstall dialog in browser window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chrome_management_api_delegat e.h" 5 #include "chrome/browser/extensions/api/management/chrome_management_api_delegat e.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/extensions/bookmark_app_helper.h" 8 #include "chrome/browser/extensions/bookmark_app_helper.h"
9 #include "chrome/browser/extensions/chrome_requirements_checker.h" 9 #include "chrome/browser/extensions/chrome_requirements_checker.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 23 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
24 #include "chrome/common/web_application_info.h" 24 #include "chrome/common/web_application_info.h"
25 #include "components/favicon/core/favicon_service.h" 25 #include "components/favicon/core/favicon_service.h"
26 #include "components/safe_json/safe_json_parser.h" 26 #include "components/safe_json/safe_json_parser.h"
27 #include "content/public/browser/browser_context.h" 27 #include "content/public/browser/browser_context.h"
28 #include "content/public/browser/utility_process_host.h" 28 #include "content/public/browser/utility_process_host.h"
29 #include "content/public/browser/utility_process_host_client.h" 29 #include "content/public/browser/utility_process_host_client.h"
30 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 #include "extensions/browser/api/management/management_api.h" 31 #include "extensions/browser/api/management/management_api.h"
32 #include "extensions/browser/api/management/management_api_constants.h" 32 #include "extensions/browser/api/management/management_api_constants.h"
33 #include "extensions/browser/extension_host.h"
33 #include "extensions/browser/extension_prefs.h" 34 #include "extensions/browser/extension_prefs.h"
34 #include "extensions/browser/extension_registry.h" 35 #include "extensions/browser/extension_registry.h"
35 #include "extensions/browser/extension_system.h" 36 #include "extensions/browser/extension_system.h"
36 #include "extensions/common/constants.h" 37 #include "extensions/common/constants.h"
37 #include "extensions/common/extension.h" 38 #include "extensions/common/extension.h"
39 #include "extensions/common/manifest_handlers/background_info.h"
38 40
39 namespace { 41 namespace {
40 42
41 class ManagementSetEnabledFunctionInstallPromptDelegate 43 class ManagementSetEnabledFunctionInstallPromptDelegate
42 : public ExtensionInstallPrompt::Delegate, 44 : public ExtensionInstallPrompt::Delegate,
43 public extensions::InstallPromptDelegate { 45 public extensions::InstallPromptDelegate {
44 public: 46 public:
45 ManagementSetEnabledFunctionInstallPromptDelegate( 47 ManagementSetEnabledFunctionInstallPromptDelegate(
46 extensions::ManagementSetEnabledFunction* function, 48 extensions::ManagementSetEnabledFunction* function,
47 const extensions::Extension* extension) 49 const extensions::Extension* extension)
(...skipping 22 matching lines...) Expand all
70 72
71 class ManagementUninstallFunctionUninstallDialogDelegate 73 class ManagementUninstallFunctionUninstallDialogDelegate
72 : public extensions::ExtensionUninstallDialog::Delegate, 74 : public extensions::ExtensionUninstallDialog::Delegate,
73 public extensions::UninstallDialogDelegate { 75 public extensions::UninstallDialogDelegate {
74 public: 76 public:
75 ManagementUninstallFunctionUninstallDialogDelegate( 77 ManagementUninstallFunctionUninstallDialogDelegate(
76 extensions::ManagementUninstallFunctionBase* function, 78 extensions::ManagementUninstallFunctionBase* function,
77 const extensions::Extension* target_extension, 79 const extensions::Extension* target_extension,
78 bool show_programmatic_uninstall_ui) 80 bool show_programmatic_uninstall_ui)
79 : function_(function) { 81 : function_(function) {
82 Profile* profile = Profile::FromBrowserContext(function->browser_context());
80 content::WebContents* web_contents = function->GetSenderWebContents(); 83 content::WebContents* web_contents = function->GetSenderWebContents();
84 const extensions::Extension* extension = function->extension();
85 gfx::NativeWindow window =
86 web_contents ? web_contents->GetTopLevelNativeWindow() : nullptr;
87
88 if (extension && extensions::BackgroundInfo::HasBackgroundPage(extension)) {
89 extensions::ExtensionHost* background_host =
90 extensions::ProcessManager::Get(function->browser_context())
91 ->GetBackgroundHostForExtension(extension->id());
92 // Do not use the window of the background page.
93 if (background_host && background_host->host_contents() == web_contents)
94 window = nullptr;
95 }
not at google - send to devlin 2015/07/08 23:10:04 Is this entire block of code necessary? I would ha
wjywbs 2015/07/09 00:27:12 No, GetTopLevelNativeWindow() does not return null
not at google - send to devlin 2015/07/09 16:30:42 ok, could you check for a null root window then?
wjywbs 2015/07/09 16:54:25 The window->GetRootWindow() function is only defin
not at google - send to devlin 2015/07/09 17:13:39 ahhh damn it. Alright! This all finally reminded m
wjywbs 2015/07/10 02:34:43 Done.
96
97 if (!window) {
98 Browser* browser =
99 chrome::FindBrowserWithProfile(profile, chrome::GetActiveDesktop());
100 window = browser->window()->GetNativeWindow();
101 }
81 extension_uninstall_dialog_.reset( 102 extension_uninstall_dialog_.reset(
82 extensions::ExtensionUninstallDialog::Create( 103 extensions::ExtensionUninstallDialog::Create(profile, window, this));
83 Profile::FromBrowserContext(function->browser_context()),
84 web_contents ? web_contents->GetTopLevelNativeWindow() : nullptr,
85 this));
86 if (show_programmatic_uninstall_ui) { 104 if (show_programmatic_uninstall_ui) {
87 extension_uninstall_dialog_->ConfirmUninstallByExtension( 105 extension_uninstall_dialog_->ConfirmUninstallByExtension(
88 target_extension, function->extension(), 106 target_extension, function->extension(),
89 extensions::UNINSTALL_REASON_MANAGEMENT_API); 107 extensions::UNINSTALL_REASON_MANAGEMENT_API);
90 } else { 108 } else {
91 extension_uninstall_dialog_->ConfirmUninstall( 109 extension_uninstall_dialog_->ConfirmUninstall(
92 target_extension, extensions::UNINSTALL_REASON_MANAGEMENT_API); 110 target_extension, extensions::UNINSTALL_REASON_MANAGEMENT_API);
93 } 111 }
94 } 112 }
95 ~ManagementUninstallFunctionUninstallDialogDelegate() override {} 113 ~ManagementUninstallFunctionUninstallDialogDelegate() override {}
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 328
311 GURL ChromeManagementAPIDelegate::GetIconURL( 329 GURL ChromeManagementAPIDelegate::GetIconURL(
312 const extensions::Extension* extension, 330 const extensions::Extension* extension,
313 int icon_size, 331 int icon_size,
314 ExtensionIconSet::MatchType match, 332 ExtensionIconSet::MatchType match,
315 bool grayscale, 333 bool grayscale,
316 bool* exists) const { 334 bool* exists) const {
317 return extensions::ExtensionIconSource::GetIconURL(extension, icon_size, 335 return extensions::ExtensionIconSource::GetIconURL(extension, icon_size,
318 match, grayscale, exists); 336 match, grayscale, exists);
319 } 337 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698