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/extensions/extension_enable_flow.h" | 5 #include "chrome/browser/ui/extensions/extension_enable_flow.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/extension_util.h" | 10 #include "chrome/browser/extensions/extension_util.h" |
10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/profiles/profiles_state.h" | 12 #include "chrome/browser/profiles/profiles_state.h" |
12 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" | 13 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" |
13 #include "chrome/browser/ui/user_manager.h" | 14 #include "chrome/browser/ui/user_manager.h" |
14 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
15 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
16 #include "extensions/browser/extension_prefs.h" | 17 #include "extensions/browser/extension_prefs.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 service->EnableExtension(extension_id_); | 111 service->EnableExtension(extension_id_); |
111 | 112 |
112 delegate_->ExtensionEnableFlowFinished(); // |delegate_| may delete us. | 113 delegate_->ExtensionEnableFlowFinished(); // |delegate_| may delete us. |
113 return; | 114 return; |
114 } | 115 } |
115 | 116 |
116 CreatePrompt(); | 117 CreatePrompt(); |
117 ExtensionInstallPrompt::PromptType type = | 118 ExtensionInstallPrompt::PromptType type = |
118 ExtensionInstallPrompt::GetReEnablePromptTypeForExtension(profile_, | 119 ExtensionInstallPrompt::GetReEnablePromptTypeForExtension(profile_, |
119 extension); | 120 extension); |
120 prompt_->ShowDialog(base::Bind(&ExtensionEnableFlow::InstallPromptDone, | 121 prompt_->ShowDialog( |
121 weak_ptr_factory_.GetWeakPtr()), | 122 base::Bind(&ExtensionEnableFlow::InstallPromptDone, |
122 extension, nullptr, | 123 weak_ptr_factory_.GetWeakPtr()), |
123 make_scoped_ptr(new ExtensionInstallPrompt::Prompt(type)), | 124 extension, nullptr, |
124 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); | 125 base::WrapUnique(new ExtensionInstallPrompt::Prompt(type)), |
| 126 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); |
125 } | 127 } |
126 | 128 |
127 void ExtensionEnableFlow::CreatePrompt() { | 129 void ExtensionEnableFlow::CreatePrompt() { |
128 if (!window_getter_.is_null()) | 130 if (!window_getter_.is_null()) |
129 parent_window_ = window_getter_.Run(); | 131 parent_window_ = window_getter_.Run(); |
130 prompt_.reset(parent_contents_ ? | 132 prompt_.reset(parent_contents_ ? |
131 new ExtensionInstallPrompt(parent_contents_) : | 133 new ExtensionInstallPrompt(parent_contents_) : |
132 new ExtensionInstallPrompt(profile_, parent_window_)); | 134 new ExtensionInstallPrompt(profile_, parent_window_)); |
133 } | 135 } |
134 | 136 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 } | 189 } |
188 | 190 |
189 service->GrantPermissionsAndEnableExtension(extension); | 191 service->GrantPermissionsAndEnableExtension(extension); |
190 delegate_->ExtensionEnableFlowFinished(); // |delegate_| may delete us. | 192 delegate_->ExtensionEnableFlowFinished(); // |delegate_| may delete us. |
191 } else { | 193 } else { |
192 delegate_->ExtensionEnableFlowAborted( | 194 delegate_->ExtensionEnableFlowAborted( |
193 result == ExtensionInstallPrompt::Result::USER_CANCELED); | 195 result == ExtensionInstallPrompt::Result::USER_CANCELED); |
194 // |delegate_| may delete us. | 196 // |delegate_| may delete us. |
195 } | 197 } |
196 } | 198 } |
OLD | NEW |