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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, chrome::NOTIFICATION_EXTENSION_LOADED, |
58 content::Source<Profile>(browser->profile())); | 58 content::Source<Profile>(browser->profile())); |
59 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 59 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
60 content::Source<Profile>(browser->profile())); | 60 content::Source<Profile>(browser->profile())); |
61 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING, | 61 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING, |
62 content::Source<Browser>(browser)); | 62 content::Source<Browser>(browser)); |
63 } | 63 } |
64 | 64 |
65 ExtensionInstalledBubble::~ExtensionInstalledBubble() {} | 65 ExtensionInstalledBubble::~ExtensionInstalledBubble() {} |
66 | 66 |
67 void ExtensionInstalledBubble::IgnoreBrowserClosing() { | 67 void ExtensionInstalledBubble::IgnoreBrowserClosing() { |
68 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_CLOSING, | 68 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_CLOSING, |
69 content::Source<Browser>(browser_)); | 69 content::Source<Browser>(browser_)); |
(...skipping 21 matching lines...) Expand all Loading... |
91 if (extension == extension_) { | 91 if (extension == extension_) { |
92 animation_wait_retries_ = 0; | 92 animation_wait_retries_ = 0; |
93 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. | 93 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. |
94 base::MessageLoopForUI::current()->PostTask( | 94 base::MessageLoopForUI::current()->PostTask( |
95 FROM_HERE, | 95 FROM_HERE, |
96 base::Bind(&ExtensionInstalledBubble::ShowInternal, | 96 base::Bind(&ExtensionInstalledBubble::ShowInternal, |
97 weak_factory_.GetWeakPtr())); | 97 weak_factory_.GetWeakPtr())); |
98 } | 98 } |
99 break; | 99 break; |
100 } | 100 } |
101 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 101 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
102 const Extension* extension = | 102 const Extension* extension = |
103 Details<extensions::UnloadedExtensionInfo>(details)->extension; | 103 Details<extensions::UnloadedExtensionInfo>(details)->extension; |
104 if (extension == extension_) { | 104 if (extension == extension_) { |
105 // Extension is going away, make sure ShowInternal won't be called. | 105 // Extension is going away, make sure ShowInternal won't be called. |
106 weak_factory_.InvalidateWeakPtrs(); | 106 weak_factory_.InvalidateWeakPtrs(); |
107 extension_ = NULL; | 107 extension_ = NULL; |
108 } | 108 } |
109 break; | 109 break; |
110 } | 110 } |
111 case chrome::NOTIFICATION_BROWSER_CLOSING: | 111 case chrome::NOTIFICATION_BROWSER_CLOSING: |
112 delete delegate_; | 112 delete delegate_; |
113 break; | 113 break; |
114 | 114 |
115 default: | 115 default: |
116 NOTREACHED() << "Received unexpected notification"; | 116 NOTREACHED() << "Received unexpected notification"; |
117 } | 117 } |
118 } | 118 } |
OLD | NEW |