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

Side by Side Diff: chrome/browser/extensions/extension_disabled_ui.cc

Issue 10388252: Refactoring ExtenionInstallUI to abstract the Browser references. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced + mac fix Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
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_disabled_ui.h" 5 #include "chrome/browser/extensions/extension_disabled_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/app/chrome_command_ids.h" 16 #include "chrome/app/chrome_command_ids.h"
17 #include "chrome/browser/extensions/extension_install_ui.h" 17 #include "chrome/browser/extensions/extension_install_prompt.h"
18 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/extensions/extension_uninstall_dialog.h" 19 #include "chrome/browser/extensions/extension_uninstall_dialog.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/global_error.h" 22 #include "chrome/browser/ui/global_error.h"
23 #include "chrome/browser/ui/global_error_service.h" 23 #include "chrome/browser/ui/global_error_service.h"
24 #include "chrome/browser/ui/global_error_service_factory.h" 24 #include "chrome/browser/ui/global_error_service_factory.h"
25 #include "chrome/common/chrome_notification_types.h" 25 #include "chrome/common/chrome_notification_types.h"
26 #include "chrome/common/extensions/extension.h" 26 #include "chrome/common/extensions/extension.h"
27 #include "content/public/browser/notification_details.h" 27 #include "content/public/browser/notification_details.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // Make a menu ID available when it is no longer used. 61 // Make a menu ID available when it is no longer used.
62 void ReleaseMenuCommandID(int id) { 62 void ReleaseMenuCommandID(int id) {
63 menu_command_ids.Get().reset(id - IDC_EXTENSION_DISABLED_FIRST); 63 menu_command_ids.Get().reset(id - IDC_EXTENSION_DISABLED_FIRST);
64 } 64 }
65 65
66 } // namespace 66 } // namespace
67 67
68 // ExtensionDisabledDialogDelegate -------------------------------------------- 68 // ExtensionDisabledDialogDelegate --------------------------------------------
69 69
70 class ExtensionDisabledDialogDelegate 70 class ExtensionDisabledDialogDelegate
71 : public ExtensionInstallUI::Delegate, 71 : public ExtensionInstallPrompt::Delegate,
72 public base::RefCountedThreadSafe<ExtensionDisabledDialogDelegate> { 72 public base::RefCountedThreadSafe<ExtensionDisabledDialogDelegate> {
73 public: 73 public:
74 ExtensionDisabledDialogDelegate(Profile* profile, 74 ExtensionDisabledDialogDelegate(Profile* profile,
75 ExtensionService* service, 75 ExtensionService* service,
76 const Extension* extension); 76 const Extension* extension);
77 77
78 private: 78 private:
79 friend class base::RefCountedThreadSafe<ExtensionDisabledDialogDelegate>; 79 friend class base::RefCountedThreadSafe<ExtensionDisabledDialogDelegate>;
80 80
81 virtual ~ExtensionDisabledDialogDelegate(); 81 virtual ~ExtensionDisabledDialogDelegate();
82 82
83 // ExtensionInstallUI::Delegate: 83 // ExtensionInstallPrompt::Delegate:
84 virtual void InstallUIProceed() OVERRIDE; 84 virtual void InstallUIProceed() OVERRIDE;
85 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; 85 virtual void InstallUIAbort(bool user_initiated) OVERRIDE;
86 86
87 // The UI for showing the install dialog when enabling. 87 // The UI for showing the install dialog when enabling.
88 scoped_ptr<ExtensionInstallUI> install_ui_; 88 scoped_ptr<ExtensionInstallPrompt> install_ui_;
89 89
90 ExtensionService* service_; 90 ExtensionService* service_;
91 const Extension* extension_; 91 const Extension* extension_;
92 }; 92 };
93 93
94 ExtensionDisabledDialogDelegate::ExtensionDisabledDialogDelegate( 94 ExtensionDisabledDialogDelegate::ExtensionDisabledDialogDelegate(
95 Profile* profile, 95 Profile* profile,
96 ExtensionService* service, 96 ExtensionService* service,
97 const Extension* extension) 97 const Extension* extension)
98 : service_(service), extension_(extension) { 98 : service_(service), extension_(extension) {
99 AddRef(); // Balanced in Proceed or Abort. 99 AddRef(); // Balanced in Proceed or Abort.
100 100
101 install_ui_.reset(new ExtensionInstallUI(profile)); 101 install_ui_.reset(new ExtensionInstallPrompt(profile));
102 install_ui_->ConfirmReEnable(this, extension_); 102 install_ui_->ConfirmReEnable(this, extension_);
103 } 103 }
104 104
105 ExtensionDisabledDialogDelegate::~ExtensionDisabledDialogDelegate() { 105 ExtensionDisabledDialogDelegate::~ExtensionDisabledDialogDelegate() {
106 } 106 }
107 107
108 void ExtensionDisabledDialogDelegate::InstallUIProceed() { 108 void ExtensionDisabledDialogDelegate::InstallUIProceed() {
109 service_->GrantPermissionsAndEnableExtension(extension_); 109 service_->GrantPermissionsAndEnableExtension(extension_);
110 Release(); 110 Release();
111 } 111 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 AddGlobalError(new ExtensionDisabledGlobalError(service, extension)); 318 AddGlobalError(new ExtensionDisabledGlobalError(service, extension));
319 } 319 }
320 320
321 void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile, 321 void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile,
322 const Extension* extension) { 322 const Extension* extension) {
323 // This object manages its own lifetime. 323 // This object manages its own lifetime.
324 new ExtensionDisabledDialogDelegate(profile, service, extension); 324 new ExtensionDisabledDialogDelegate(profile, service, extension);
325 } 325 }
326 326
327 } // namespace extensions 327 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.cc ('k') | chrome/browser/extensions/extension_install_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698