Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: chrome/browser/ui/extensions/extension_installed_bubble.cc

Issue 1503583002: [Extensions Views] Update the extension installed bubble's sync promo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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() {
60 OnExtensionLoaded(nullptr, bubble_->extension());
61 }
62
59 private: 63 private:
60 ~ExtensionInstalledBubbleObserver() override {} 64 ~ExtensionInstalledBubbleObserver() override {}
61 65
62 // content::NotificationObserver: 66 // content::NotificationObserver:
63 void Observe(int type, 67 void Observe(int type,
64 const content::NotificationSource& source, 68 const content::NotificationSource& source,
65 const content::NotificationDetails& details) override { 69 const content::NotificationDetails& details) override {
66 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_CLOSING) 70 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_CLOSING)
67 << "Received unexpected notification"; 71 << "Received unexpected notification";
68 // Browser is closing before the bubble was shown. 72 // Browser is closing before the bubble was shown.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 166
163 } // namespace 167 } // namespace
164 168
165 // static 169 // static
166 void ExtensionInstalledBubble::ShowBubble( 170 void ExtensionInstalledBubble::ShowBubble(
167 const extensions::Extension* extension, 171 const extensions::Extension* extension,
168 Browser* browser, 172 Browser* browser,
169 const SkBitmap& icon) { 173 const SkBitmap& icon) {
170 // The ExtensionInstalledBubbleObserver will delete itself when the 174 // The ExtensionInstalledBubbleObserver will delete itself when the
171 // ExtensionInstalledBubble is shown or when it can't be shown anymore. 175 // ExtensionInstalledBubble is shown or when it can't be shown anymore.
172 new ExtensionInstalledBubbleObserver( 176 auto x = new ExtensionInstalledBubbleObserver(
sky 2015/12/04 23:41:06 x, huh? bubble_observer?
Devlin 2015/12/05 01:10:15 D'oh! This was all for testing. I remembered to
173 make_scoped_ptr(new ExtensionInstalledBubble(extension, browser, icon))); 177 make_scoped_ptr(new ExtensionInstalledBubble(extension, browser, icon)));
178 extensions::ExtensionRegistry* reg =
179 extensions::ExtensionRegistry::Get(browser->profile());
180 if (reg->enabled_extensions().GetByID(extension->id())) {
sky 2015/12/04 23:41:06 nit: no {}
Devlin 2015/12/05 01:10:15 Ditto.
181 x->Run();
182 }
174 } 183 }
175 184
176 ExtensionInstalledBubble::ExtensionInstalledBubble(const Extension* extension, 185 ExtensionInstalledBubble::ExtensionInstalledBubble(const Extension* extension,
177 Browser* browser, 186 Browser* browser,
178 const SkBitmap& icon) 187 const SkBitmap& icon)
179 : extension_(extension), browser_(browser), icon_(icon) { 188 : extension_(extension), browser_(browser), icon_(icon) {
180 if (!extensions::OmniboxInfo::GetKeyword(extension).empty()) 189 if (!extensions::OmniboxInfo::GetKeyword(extension).empty())
181 type_ = OMNIBOX_KEYWORD; 190 type_ = OMNIBOX_KEYWORD;
182 else if (extensions::ActionInfo::GetBrowserActionInfo(extension)) 191 else if (extensions::ActionInfo::GetBrowserActionInfo(extension))
183 type_ = BROWSER_ACTION; 192 type_ = BROWSER_ACTION;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 234
226 if (message_id == 0) 235 if (message_id == 0)
227 return base::string16(); 236 return base::string16();
228 return extra.empty() ? l10n_util::GetStringUTF16(message_id) : 237 return extra.empty() ? l10n_util::GetStringUTF16(message_id) :
229 l10n_util::GetStringFUTF16(message_id, extra); 238 l10n_util::GetStringFUTF16(message_id, extra);
230 } 239 }
231 240
232 void ExtensionInstalledBubble::OnExtensionLoaded() { 241 void ExtensionInstalledBubble::OnExtensionLoaded() {
233 action_command_ = GetCommand(extension_->id(), browser_->profile(), type_); 242 action_command_ = GetCommand(extension_->id(), browser_->profile(), type_);
234 } 243 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698