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

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

Issue 1160073004: chrome/browser/ui: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments. Created 5 years, 6 months 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/message_loop/message_loop.h" 10 #include "base/location.h"
11 #include "base/single_thread_task_runner.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/thread_task_runner_handle.h"
12 #include "base/time/time.h" 14 #include "base/time/time.h"
13 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/extensions/api/commands/command_service.h" 16 #include "chrome/browser/extensions/api/commands/command_service.h"
15 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
17 #include "chrome/common/extensions/api/extension_action/action_info.h" 19 #include "chrome/common/extensions/api/extension_action/action_info.h"
18 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" 20 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h"
19 #include "chrome/common/extensions/command.h" 21 #include "chrome/common/extensions/command.h"
20 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
21 #include "content/public/browser/notification_details.h" 23 #include "content/public/browser/notification_details.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 if (message_id == 0) 126 if (message_id == 0)
125 return base::string16(); 127 return base::string16();
126 return extra.empty() ? l10n_util::GetStringUTF16(message_id) : 128 return extra.empty() ? l10n_util::GetStringUTF16(message_id) :
127 l10n_util::GetStringFUTF16(message_id, extra); 129 l10n_util::GetStringFUTF16(message_id, extra);
128 } 130 }
129 131
130 void ExtensionInstalledBubble::ShowInternal() { 132 void ExtensionInstalledBubble::ShowInternal() {
131 if (delegate_->MaybeShowNow()) 133 if (delegate_->MaybeShowNow())
132 return; 134 return;
133 if (animation_wait_retries_++ < kAnimationWaitRetries) { 135 if (animation_wait_retries_++ < kAnimationWaitRetries) {
134 base::MessageLoopForUI::current()->PostDelayedTask( 136 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
135 FROM_HERE, 137 FROM_HERE, base::Bind(&ExtensionInstalledBubble::ShowInternal,
136 base::Bind(&ExtensionInstalledBubble::ShowInternal, 138 weak_factory_.GetWeakPtr()),
137 weak_factory_.GetWeakPtr()),
138 base::TimeDelta::FromMilliseconds(kAnimationWaitMs)); 139 base::TimeDelta::FromMilliseconds(kAnimationWaitMs));
139 } 140 }
140 } 141 }
141 142
142 void ExtensionInstalledBubble::OnExtensionLoaded( 143 void ExtensionInstalledBubble::OnExtensionLoaded(
143 content::BrowserContext* browser_context, 144 content::BrowserContext* browser_context,
144 const extensions::Extension* extension) { 145 const extensions::Extension* extension) {
145 if (extension == extension_) { 146 if (extension == extension_) {
146 // Parse the extension command, if one exists. 147 // Parse the extension command, if one exists.
147 action_command_ = GetCommand(extension_->id(), browser_->profile(), type_); 148 action_command_ = GetCommand(extension_->id(), browser_->profile(), type_);
148 149
149 animation_wait_retries_ = 0; 150 animation_wait_retries_ = 0;
150 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. 151 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run.
151 base::MessageLoopForUI::current()->PostTask( 152 base::ThreadTaskRunnerHandle::Get()->PostTask(
152 FROM_HERE, 153 FROM_HERE, base::Bind(&ExtensionInstalledBubble::ShowInternal,
153 base::Bind(&ExtensionInstalledBubble::ShowInternal, 154 weak_factory_.GetWeakPtr()));
154 weak_factory_.GetWeakPtr()));
155 } 155 }
156 } 156 }
157 157
158 void ExtensionInstalledBubble::OnExtensionUnloaded( 158 void ExtensionInstalledBubble::OnExtensionUnloaded(
159 content::BrowserContext* browser_context, 159 content::BrowserContext* browser_context,
160 const extensions::Extension* extension, 160 const extensions::Extension* extension,
161 extensions::UnloadedExtensionInfo::Reason reason) { 161 extensions::UnloadedExtensionInfo::Reason reason) {
162 if (extension == extension_) { 162 if (extension == extension_) {
163 // Extension is going away, make sure ShowInternal won't be called. 163 // Extension is going away, make sure ShowInternal won't be called.
164 weak_factory_.InvalidateWeakPtrs(); 164 weak_factory_.InvalidateWeakPtrs();
165 extension_ = NULL; 165 extension_ = NULL;
166 } 166 }
167 } 167 }
168 168
169 void ExtensionInstalledBubble::Observe( 169 void ExtensionInstalledBubble::Observe(
170 int type, 170 int type,
171 const content::NotificationSource& source, 171 const content::NotificationSource& source,
172 const content::NotificationDetails& details) { 172 const content::NotificationDetails& details) {
173 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_CLOSING) 173 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_CLOSING)
174 << "Received unexpected notification"; 174 << "Received unexpected notification";
175 delete delegate_; 175 delete delegate_;
176 } 176 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/exclusive_access/fullscreen_controller.cc ('k') | chrome/browser/ui/fast_unload_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698