| 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 "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 void ExtensionEnableFlow::CreatePrompt() { | 104 void ExtensionEnableFlow::CreatePrompt() { |
| 105 if (!window_getter_.is_null()) | 105 if (!window_getter_.is_null()) |
| 106 parent_window_ = window_getter_.Run(); | 106 parent_window_ = window_getter_.Run(); |
| 107 prompt_.reset(parent_contents_ ? | 107 prompt_.reset(parent_contents_ ? |
| 108 new ExtensionInstallPrompt(parent_contents_) : | 108 new ExtensionInstallPrompt(parent_contents_) : |
| 109 new ExtensionInstallPrompt(profile_, parent_window_, this)); | 109 new ExtensionInstallPrompt(profile_, parent_window_, this)); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void ExtensionEnableFlow::StartObserving() { | 112 void ExtensionEnableFlow::StartObserving() { |
| 113 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 113 registrar_.Add(this, |
| 114 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 114 content::Source<Profile>(profile_)); | 115 content::Source<Profile>(profile_)); |
| 115 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, | 116 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, |
| 116 content::Source<Profile>(profile_)); | 117 content::Source<Profile>(profile_)); |
| 117 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 118 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
| 118 content::Source<Profile>(profile_)); | 119 content::Source<Profile>(profile_)); |
| 119 } | 120 } |
| 120 | 121 |
| 121 void ExtensionEnableFlow::StopObserving() { | 122 void ExtensionEnableFlow::StopObserving() { |
| 122 registrar_.RemoveAll(); | 123 registrar_.RemoveAll(); |
| 123 } | 124 } |
| 124 | 125 |
| 125 void ExtensionEnableFlow::Observe(int type, | 126 void ExtensionEnableFlow::Observe(int type, |
| 126 const content::NotificationSource& source, | 127 const content::NotificationSource& source, |
| 127 const content::NotificationDetails& details) { | 128 const content::NotificationDetails& details) { |
| 128 switch (type) { | 129 switch (type) { |
| 129 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 130 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { |
| 130 const Extension* extension = | 131 const Extension* extension = |
| 131 content::Details<const Extension>(details).ptr(); | 132 content::Details<const Extension>(details).ptr(); |
| 132 if (extension->id() == extension_id_) { | 133 if (extension->id() == extension_id_) { |
| 133 StopObserving(); | 134 StopObserving(); |
| 134 CheckPermissionAndMaybePromptUser(); | 135 CheckPermissionAndMaybePromptUser(); |
| 135 } | 136 } |
| 136 | 137 |
| 137 break; | 138 break; |
| 138 } | 139 } |
| 139 case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR: { | 140 case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR: { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 delegate_->ExtensionEnableFlowAborted(user_initiated); | 177 delegate_->ExtensionEnableFlowAborted(user_initiated); |
| 177 // |delegate_| may delete us. | 178 // |delegate_| may delete us. |
| 178 } | 179 } |
| 179 | 180 |
| 180 content::WebContents* ExtensionEnableFlow::OpenURL( | 181 content::WebContents* ExtensionEnableFlow::OpenURL( |
| 181 const content::OpenURLParams& params) { | 182 const content::OpenURLParams& params) { |
| 182 chrome::ScopedTabbedBrowserDisplayer displayer( | 183 chrome::ScopedTabbedBrowserDisplayer displayer( |
| 183 profile_, chrome::GetActiveDesktop()); | 184 profile_, chrome::GetActiveDesktop()); |
| 184 return displayer.browser()->OpenURL(params); | 185 return displayer.browser()->OpenURL(params); |
| 185 } | 186 } |
| OLD | NEW |