| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_installed_bubble.h" | 5 #include "chrome/browser/ui/extensions/extension_installed_bubble.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 extensions::ActionInfo::IsVerboseInstallMessage(extension)) | 47 extensions::ActionInfo::IsVerboseInstallMessage(extension)) |
| 48 type_ = PAGE_ACTION; | 48 type_ = PAGE_ACTION; |
| 49 else | 49 else |
| 50 type_ = GENERIC; | 50 type_ = GENERIC; |
| 51 | 51 |
| 52 // |extension| has been initialized but not loaded at this point. We need | 52 // |extension| has been initialized but not loaded at this point. We need |
| 53 // to wait on showing the Bubble until not only the EXTENSION_LOADED gets | 53 // to wait on showing the Bubble until not only the EXTENSION_LOADED gets |
| 54 // fired, but all of the EXTENSION_LOADED Observers have run. Only then can we | 54 // fired, but all of the EXTENSION_LOADED Observers have run. Only then can we |
| 55 // be sure that a BrowserAction or PageAction has had views created which we | 55 // be sure that a BrowserAction or PageAction has had views created which we |
| 56 // can inspect for the purpose of previewing of pointing to them. | 56 // can inspect for the purpose of previewing of pointing to them. |
| 57 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 57 registrar_.Add(this, |
| 58 content::Source<Profile>(browser->profile())); | 58 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 59 content::Source<Profile>(browser->profile())); |
| 59 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 60 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 60 content::Source<Profile>(browser->profile())); | 61 content::Source<Profile>(browser->profile())); |
| 61 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING, | 62 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING, |
| 62 content::Source<Browser>(browser)); | 63 content::Source<Browser>(browser)); |
| 63 } | 64 } |
| 64 | 65 |
| 65 ExtensionInstalledBubble::~ExtensionInstalledBubble() {} | 66 ExtensionInstalledBubble::~ExtensionInstalledBubble() {} |
| 66 | 67 |
| 67 void ExtensionInstalledBubble::IgnoreBrowserClosing() { | 68 void ExtensionInstalledBubble::IgnoreBrowserClosing() { |
| 68 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_CLOSING, | 69 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_CLOSING, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 79 weak_factory_.GetWeakPtr()), | 80 weak_factory_.GetWeakPtr()), |
| 80 base::TimeDelta::FromMilliseconds(kAnimationWaitMs)); | 81 base::TimeDelta::FromMilliseconds(kAnimationWaitMs)); |
| 81 } | 82 } |
| 82 } | 83 } |
| 83 | 84 |
| 84 void ExtensionInstalledBubble::Observe( | 85 void ExtensionInstalledBubble::Observe( |
| 85 int type, | 86 int type, |
| 86 const content::NotificationSource& source, | 87 const content::NotificationSource& source, |
| 87 const content::NotificationDetails& details) { | 88 const content::NotificationDetails& details) { |
| 88 switch (type) { | 89 switch (type) { |
| 89 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 90 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { |
| 90 const Extension* extension = Details<const Extension>(details).ptr(); | 91 const Extension* extension = Details<const Extension>(details).ptr(); |
| 91 if (extension == extension_) { | 92 if (extension == extension_) { |
| 92 animation_wait_retries_ = 0; | 93 animation_wait_retries_ = 0; |
| 93 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. | 94 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. |
| 94 base::MessageLoopForUI::current()->PostTask( | 95 base::MessageLoopForUI::current()->PostTask( |
| 95 FROM_HERE, | 96 FROM_HERE, |
| 96 base::Bind(&ExtensionInstalledBubble::ShowInternal, | 97 base::Bind(&ExtensionInstalledBubble::ShowInternal, |
| 97 weak_factory_.GetWeakPtr())); | 98 weak_factory_.GetWeakPtr())); |
| 98 } | 99 } |
| 99 break; | 100 break; |
| 100 } | 101 } |
| 101 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { | 102 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
| 102 const Extension* extension = | 103 const Extension* extension = |
| 103 Details<extensions::UnloadedExtensionInfo>(details)->extension; | 104 Details<extensions::UnloadedExtensionInfo>(details)->extension; |
| 104 if (extension == extension_) { | 105 if (extension == extension_) { |
| 105 // Extension is going away, make sure ShowInternal won't be called. | 106 // Extension is going away, make sure ShowInternal won't be called. |
| 106 weak_factory_.InvalidateWeakPtrs(); | 107 weak_factory_.InvalidateWeakPtrs(); |
| 107 extension_ = NULL; | 108 extension_ = NULL; |
| 108 } | 109 } |
| 109 break; | 110 break; |
| 110 } | 111 } |
| 111 case chrome::NOTIFICATION_BROWSER_CLOSING: | 112 case chrome::NOTIFICATION_BROWSER_CLOSING: |
| 112 delete delegate_; | 113 delete delegate_; |
| 113 break; | 114 break; |
| 114 | 115 |
| 115 default: | 116 default: |
| 116 NOTREACHED() << "Received unexpected notification"; | 117 NOTREACHED() << "Received unexpected notification"; |
| 117 } | 118 } |
| 118 } | 119 } |
| OLD | NEW |