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/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 weak_factory_(this) { | 49 weak_factory_(this) { |
50 // |extension| has been initialized but not loaded at this point. We need to | 50 // |extension| has been initialized but not loaded at this point. We need to |
51 // wait on showing the Bubble until the EXTENSION_LOADED gets fired. | 51 // wait on showing the Bubble until the EXTENSION_LOADED gets fired. |
52 extension_registry_observer_.Add( | 52 extension_registry_observer_.Add( |
53 extensions::ExtensionRegistry::Get(bubble_->browser()->profile())); | 53 extensions::ExtensionRegistry::Get(bubble_->browser()->profile())); |
54 | 54 |
55 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING, | 55 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING, |
56 content::Source<Browser>(bubble_->browser())); | 56 content::Source<Browser>(bubble_->browser())); |
57 } | 57 } |
58 | 58 |
| 59 void Run() { OnExtensionLoaded(nullptr, bubble_->extension()); } |
| 60 |
59 private: | 61 private: |
60 ~ExtensionInstalledBubbleObserver() override {} | 62 ~ExtensionInstalledBubbleObserver() override {} |
61 | 63 |
62 // content::NotificationObserver: | 64 // content::NotificationObserver: |
63 void Observe(int type, | 65 void Observe(int type, |
64 const content::NotificationSource& source, | 66 const content::NotificationSource& source, |
65 const content::NotificationDetails& details) override { | 67 const content::NotificationDetails& details) override { |
66 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_CLOSING) | 68 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_CLOSING) |
67 << "Received unexpected notification"; | 69 << "Received unexpected notification"; |
68 // Browser is closing before the bubble was shown. | 70 // Browser is closing before the bubble was shown. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 164 |
163 } // namespace | 165 } // namespace |
164 | 166 |
165 // static | 167 // static |
166 void ExtensionInstalledBubble::ShowBubble( | 168 void ExtensionInstalledBubble::ShowBubble( |
167 const extensions::Extension* extension, | 169 const extensions::Extension* extension, |
168 Browser* browser, | 170 Browser* browser, |
169 const SkBitmap& icon) { | 171 const SkBitmap& icon) { |
170 // The ExtensionInstalledBubbleObserver will delete itself when the | 172 // The ExtensionInstalledBubbleObserver will delete itself when the |
171 // ExtensionInstalledBubble is shown or when it can't be shown anymore. | 173 // ExtensionInstalledBubble is shown or when it can't be shown anymore. |
172 new ExtensionInstalledBubbleObserver( | 174 auto x = new ExtensionInstalledBubbleObserver( |
173 make_scoped_ptr(new ExtensionInstalledBubble(extension, browser, icon))); | 175 make_scoped_ptr(new ExtensionInstalledBubble(extension, browser, icon))); |
| 176 extensions::ExtensionRegistry* reg = |
| 177 extensions::ExtensionRegistry::Get(browser->profile()); |
| 178 if (reg->enabled_extensions().GetByID(extension->id())) { |
| 179 x->Run(); |
| 180 } |
174 } | 181 } |
175 | 182 |
176 ExtensionInstalledBubble::ExtensionInstalledBubble(const Extension* extension, | 183 ExtensionInstalledBubble::ExtensionInstalledBubble(const Extension* extension, |
177 Browser* browser, | 184 Browser* browser, |
178 const SkBitmap& icon) | 185 const SkBitmap& icon) |
179 : extension_(extension), browser_(browser), icon_(icon) { | 186 : extension_(extension), browser_(browser), icon_(icon) { |
180 if (!extensions::OmniboxInfo::GetKeyword(extension).empty()) | 187 if (!extensions::OmniboxInfo::GetKeyword(extension).empty()) |
181 type_ = OMNIBOX_KEYWORD; | 188 type_ = OMNIBOX_KEYWORD; |
182 else if (extensions::ActionInfo::GetBrowserActionInfo(extension)) | 189 else if (extensions::ActionInfo::GetBrowserActionInfo(extension)) |
183 type_ = BROWSER_ACTION; | 190 type_ = BROWSER_ACTION; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 232 |
226 if (message_id == 0) | 233 if (message_id == 0) |
227 return base::string16(); | 234 return base::string16(); |
228 return extra.empty() ? l10n_util::GetStringUTF16(message_id) : | 235 return extra.empty() ? l10n_util::GetStringUTF16(message_id) : |
229 l10n_util::GetStringFUTF16(message_id, extra); | 236 l10n_util::GetStringFUTF16(message_id, extra); |
230 } | 237 } |
231 | 238 |
232 void ExtensionInstalledBubble::OnExtensionLoaded() { | 239 void ExtensionInstalledBubble::OnExtensionLoaded() { |
233 action_command_ = GetCommand(extension_->id(), browser_->profile(), type_); | 240 action_command_ = GetCommand(extension_->id(), browser_->profile(), type_); |
234 } | 241 } |
OLD | NEW |