| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 // extensions::ExtensionRegistryObserver: | 80 // extensions::ExtensionRegistryObserver: |
| 81 void OnExtensionLoaded(content::BrowserContext* browser_context, | 81 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 82 const extensions::Extension* extension) override { | 82 const extensions::Extension* extension) override { |
| 83 if (extension == bubble_->extension()) { | 83 if (extension == bubble_->extension()) { |
| 84 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. | 84 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. |
| 85 // Only then can we be sure that a BrowserAction or PageAction has had | 85 // Only then can we be sure that a BrowserAction or PageAction has had |
| 86 // views created which we can inspect for the purpose of previewing of | 86 // views created which we can inspect for the purpose of previewing of |
| 87 // pointing to them. | 87 // pointing to them. |
| 88 base::ThreadTaskRunnerHandle::Get()->PostTask( | 88 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 89 FROM_HERE, base::Bind(&ExtensionInstalledBubbleObserver::Initialize, | 89 FROM_HERE, |
| 90 weak_factory_.GetWeakPtr())); | 90 base::BindOnce(&ExtensionInstalledBubbleObserver::Initialize, |
| 91 weak_factory_.GetWeakPtr())); |
| 91 } | 92 } |
| 92 } | 93 } |
| 93 | 94 |
| 94 void OnExtensionUnloaded( | 95 void OnExtensionUnloaded( |
| 95 content::BrowserContext* browser_context, | 96 content::BrowserContext* browser_context, |
| 96 const extensions::Extension* extension, | 97 const extensions::Extension* extension, |
| 97 extensions::UnloadedExtensionInfo::Reason reason) override { | 98 extensions::UnloadedExtensionInfo::Reason reason) override { |
| 98 if (extension == bubble_->extension()) { | 99 if (extension == bubble_->extension()) { |
| 99 // Extension is going away. | 100 // Extension is going away. |
| 100 delete this; | 101 delete this; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 115 // to delay showing the bubble. | 116 // to delay showing the bubble. |
| 116 if (bubble_->ShouldShow()) { | 117 if (bubble_->ShouldShow()) { |
| 117 // Must be 2 lines because the manager will take ownership of bubble. | 118 // Must be 2 lines because the manager will take ownership of bubble. |
| 118 BubbleManager* manager = bubble_->browser()->GetBubbleManager(); | 119 BubbleManager* manager = bubble_->browser()->GetBubbleManager(); |
| 119 manager->ShowBubble(std::move(bubble_)); | 120 manager->ShowBubble(std::move(bubble_)); |
| 120 delete this; | 121 delete this; |
| 121 return; | 122 return; |
| 122 } | 123 } |
| 123 if (animation_wait_retries_++ < kAnimationWaitRetries) { | 124 if (animation_wait_retries_++ < kAnimationWaitRetries) { |
| 124 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 125 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 125 FROM_HERE, base::Bind(&ExtensionInstalledBubbleObserver::Show, | 126 FROM_HERE, |
| 126 weak_factory_.GetWeakPtr()), | 127 base::BindOnce(&ExtensionInstalledBubbleObserver::Show, |
| 128 weak_factory_.GetWeakPtr()), |
| 127 base::TimeDelta::FromMilliseconds(kAnimationWaitMs)); | 129 base::TimeDelta::FromMilliseconds(kAnimationWaitMs)); |
| 128 } else { | 130 } else { |
| 129 // Retries are over; won't try again. | 131 // Retries are over; won't try again. |
| 130 // TODO(hcarmona): Look into logging this with the BubbleManager. | 132 // TODO(hcarmona): Look into logging this with the BubbleManager. |
| 131 delete this; | 133 delete this; |
| 132 } | 134 } |
| 133 } | 135 } |
| 134 | 136 |
| 135 // The bubble that will be shown when the extension has finished installing. | 137 // The bubble that will be shown when the extension has finished installing. |
| 136 std::unique_ptr<ExtensionInstalledBubble> bubble_; | 138 std::unique_ptr<ExtensionInstalledBubble> bubble_; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 break; | 288 break; |
| 287 case OMNIBOX_KEYWORD: | 289 case OMNIBOX_KEYWORD: |
| 288 options_ |= HOW_TO_USE | HOW_TO_MANAGE; | 290 options_ |= HOW_TO_USE | HOW_TO_MANAGE; |
| 289 anchor_position_ = ANCHOR_OMNIBOX; | 291 anchor_position_ = ANCHOR_OMNIBOX; |
| 290 break; | 292 break; |
| 291 case GENERIC: | 293 case GENERIC: |
| 292 anchor_position_ = ANCHOR_APP_MENU; | 294 anchor_position_ = ANCHOR_APP_MENU; |
| 293 break; | 295 break; |
| 294 } | 296 } |
| 295 } | 297 } |
| OLD | NEW |