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

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

Issue 1550053002: Convert Pass()→std::move() in //chrome/browser/ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "base/scoped_observer.h" 13 #include "base/scoped_observer.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/extensions/api/commands/command_service.h" 18 #include "chrome/browser/extensions/api/commands/command_service.h"
(...skipping 22 matching lines...) Expand all
40 // How often we retry when waiting for browser action animation to end. 41 // How often we retry when waiting for browser action animation to end.
41 const int kAnimationWaitRetries = 10; 42 const int kAnimationWaitRetries = 10;
42 43
43 // Class responsible for showing the bubble after it's installed. Owns itself. 44 // Class responsible for showing the bubble after it's installed. Owns itself.
44 class ExtensionInstalledBubbleObserver 45 class ExtensionInstalledBubbleObserver
45 : public content::NotificationObserver, 46 : public content::NotificationObserver,
46 public extensions::ExtensionRegistryObserver { 47 public extensions::ExtensionRegistryObserver {
47 public: 48 public:
48 explicit ExtensionInstalledBubbleObserver( 49 explicit ExtensionInstalledBubbleObserver(
49 scoped_ptr<ExtensionInstalledBubble> bubble) 50 scoped_ptr<ExtensionInstalledBubble> bubble)
50 : bubble_(bubble.Pass()), 51 : bubble_(std::move(bubble)),
51 extension_registry_observer_(this), 52 extension_registry_observer_(this),
52 animation_wait_retries_(0), 53 animation_wait_retries_(0),
53 weak_factory_(this) { 54 weak_factory_(this) {
54 // |extension| has been initialized but not loaded at this point. We need to 55 // |extension| has been initialized but not loaded at this point. We need to
55 // wait on showing the Bubble until the EXTENSION_LOADED gets fired. 56 // wait on showing the Bubble until the EXTENSION_LOADED gets fired.
56 extension_registry_observer_.Add( 57 extension_registry_observer_.Add(
57 extensions::ExtensionRegistry::Get(bubble_->browser()->profile())); 58 extensions::ExtensionRegistry::Get(bubble_->browser()->profile()));
58 59
59 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING, 60 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING,
60 content::Source<Browser>(bubble_->browser())); 61 content::Source<Browser>(bubble_->browser()));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 109
109 // Called internally via PostTask to show the bubble. 110 // Called internally via PostTask to show the bubble.
110 void Show() { 111 void Show() {
111 DCHECK(bubble_); 112 DCHECK(bubble_);
112 // TODO(hcarmona): Investigate having the BubbleManager query the bubble 113 // TODO(hcarmona): Investigate having the BubbleManager query the bubble
113 // for |ShouldShow|. This is important because the BubbleManager may decide 114 // for |ShouldShow|. This is important because the BubbleManager may decide
114 // to delay showing the bubble. 115 // to delay showing the bubble.
115 if (bubble_->ShouldShow()) { 116 if (bubble_->ShouldShow()) {
116 // Must be 2 lines because the manager will take ownership of bubble. 117 // Must be 2 lines because the manager will take ownership of bubble.
117 BubbleManager* manager = bubble_->browser()->GetBubbleManager(); 118 BubbleManager* manager = bubble_->browser()->GetBubbleManager();
118 manager->ShowBubble(bubble_.Pass()); 119 manager->ShowBubble(std::move(bubble_));
119 delete this; 120 delete this;
120 return; 121 return;
121 } 122 }
122 if (animation_wait_retries_++ < kAnimationWaitRetries) { 123 if (animation_wait_retries_++ < kAnimationWaitRetries) {
123 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 124 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
124 FROM_HERE, base::Bind(&ExtensionInstalledBubbleObserver::Show, 125 FROM_HERE, base::Bind(&ExtensionInstalledBubbleObserver::Show,
125 weak_factory_.GetWeakPtr()), 126 weak_factory_.GetWeakPtr()),
126 base::TimeDelta::FromMilliseconds(kAnimationWaitMs)); 127 base::TimeDelta::FromMilliseconds(kAnimationWaitMs));
127 } else { 128 } else {
128 // Retries are over; won't try again. 129 // Retries are over; won't try again.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 bool has_command = false; 162 bool has_command = false;
162 if (type == ExtensionInstalledBubble::BROWSER_ACTION) { 163 if (type == ExtensionInstalledBubble::BROWSER_ACTION) {
163 has_command = command_service->GetBrowserActionCommand( 164 has_command = command_service->GetBrowserActionCommand(
164 extension_id, extensions::CommandService::ACTIVE, &command, nullptr); 165 extension_id, extensions::CommandService::ACTIVE, &command, nullptr);
165 } else if (type == ExtensionInstalledBubble::PAGE_ACTION) { 166 } else if (type == ExtensionInstalledBubble::PAGE_ACTION) {
166 has_command = command_service->GetPageActionCommand( 167 has_command = command_service->GetPageActionCommand(
167 extension_id, extensions::CommandService::ACTIVE, &command, nullptr); 168 extension_id, extensions::CommandService::ACTIVE, &command, nullptr);
168 } 169 }
169 if (has_command) 170 if (has_command)
170 result.reset(new extensions::Command(command)); 171 result.reset(new extensions::Command(command));
171 return result.Pass(); 172 return result;
172 } 173 }
173 174
174 } // namespace 175 } // namespace
175 176
176 // static 177 // static
177 void ExtensionInstalledBubble::ShowBubble( 178 void ExtensionInstalledBubble::ShowBubble(
178 const extensions::Extension* extension, 179 const extensions::Extension* extension,
179 Browser* browser, 180 Browser* browser,
180 const SkBitmap& icon) { 181 const SkBitmap& icon) {
181 // The ExtensionInstalledBubbleObserver will delete itself when the 182 // The ExtensionInstalledBubbleObserver will delete itself when the
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 break; 288 break;
288 case OMNIBOX_KEYWORD: 289 case OMNIBOX_KEYWORD:
289 options_ |= HOW_TO_USE | HOW_TO_MANAGE; 290 options_ |= HOW_TO_USE | HOW_TO_MANAGE;
290 anchor_position_ = ANCHOR_OMNIBOX; 291 anchor_position_ = ANCHOR_OMNIBOX;
291 break; 292 break;
292 case GENERIC: 293 case GENERIC:
293 anchor_position_ = ANCHOR_APP_MENU; 294 anchor_position_ = ANCHOR_APP_MENU;
294 break; 295 break;
295 } 296 }
296 } 297 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698