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

Side by Side Diff: chrome/browser/extensions/api/file_system/request_file_system_notification.cc

Issue 1556783002: Convert Pass()→std::move() for CrOS extension code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/extensions/api/file_system/request_file_system_notifica tion.h" 5 #include "chrome/browser/extensions/api/file_system/request_file_system_notifica tion.h"
6 6
7 #include <utility>
8
7 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
8 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/chromeos/file_manager/volume_manager.h" 13 #include "chrome/browser/chromeos/file_manager/volume_manager.h"
12 #include "chrome/browser/extensions/app_icon_loader_impl.h" 14 #include "chrome/browser/extensions/app_icon_loader_impl.h"
13 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
14 #include "extensions/common/extension.h" 16 #include "extensions/common/extension.h"
15 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/message_center/message_center.h" 18 #include "ui/message_center/message_center.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 scoped_ptr<Notification> notification(new Notification( 58 scoped_ptr<Notification> notification(new Notification(
57 message_center::NOTIFICATION_TYPE_SIMPLE, notification_id, 59 message_center::NOTIFICATION_TYPE_SIMPLE, notification_id,
58 base::UTF8ToUTF16(extension.name()), message, 60 base::UTF8ToUTF16(extension.name()), message,
59 gfx::Image(), // Updated asynchronously later. 61 gfx::Image(), // Updated asynchronously later.
60 base::string16(), // display_source 62 base::string16(), // display_source
61 GURL(), 63 GURL(),
62 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, 64 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT,
63 notification_id), 65 notification_id),
64 data, delegate)); 66 data, delegate));
65 67
66 return notification.Pass(); 68 return notification;
67 } 69 }
68 70
69 } // namespace 71 } // namespace
70 72
71 // static 73 // static
72 void RequestFileSystemNotification::ShowAutoGrantedNotification( 74 void RequestFileSystemNotification::ShowAutoGrantedNotification(
73 Profile* profile, 75 Profile* profile,
74 const extensions::Extension& extension, 76 const extensions::Extension& extension,
75 const base::WeakPtr<Volume>& volume, 77 const base::WeakPtr<Volume>& volume,
76 bool writable) { 78 bool writable) {
77 DCHECK(profile); 79 DCHECK(profile);
78 scoped_refptr<RequestFileSystemNotification> 80 scoped_refptr<RequestFileSystemNotification>
79 request_file_system_notification = make_scoped_refptr( 81 request_file_system_notification = make_scoped_refptr(
80 new RequestFileSystemNotification(profile, extension)); 82 new RequestFileSystemNotification(profile, extension));
81 scoped_ptr<message_center::Notification> notification( 83 scoped_ptr<message_center::Notification> notification(
82 CreateAutoGrantedNotification( 84 CreateAutoGrantedNotification(
83 extension, volume, writable, 85 extension, volume, writable,
84 request_file_system_notification.get() /* delegate */)); 86 request_file_system_notification.get() /* delegate */));
85 if (notification.get()) 87 if (notification.get())
86 request_file_system_notification->Show(notification.Pass()); 88 request_file_system_notification->Show(std::move(notification));
87 } 89 }
88 90
89 void RequestFileSystemNotification::SetAppImage(const std::string& id, 91 void RequestFileSystemNotification::SetAppImage(const std::string& id,
90 const gfx::ImageSkia& image) { 92 const gfx::ImageSkia& image) {
91 extension_icon_.reset(new gfx::Image(image)); 93 extension_icon_.reset(new gfx::Image(image));
92 94
93 // If there is a pending notification, then show it now. 95 // If there is a pending notification, then show it now.
94 if (pending_notification_.get()) { 96 if (pending_notification_.get()) {
95 pending_notification_->set_icon(*extension_icon_.get()); 97 pending_notification_->set_icon(*extension_icon_.get());
96 g_browser_process->message_center()->AddNotification( 98 g_browser_process->message_center()->AddNotification(
97 pending_notification_.Pass()); 99 std::move(pending_notification_));
98 } 100 }
99 } 101 }
100 102
101 RequestFileSystemNotification::RequestFileSystemNotification( 103 RequestFileSystemNotification::RequestFileSystemNotification(
102 Profile* profile, 104 Profile* profile,
103 const extensions::Extension& extension) 105 const extensions::Extension& extension)
104 : icon_loader_( 106 : icon_loader_(
105 new extensions::AppIconLoaderImpl(profile, kIconSize, this)) { 107 new extensions::AppIconLoaderImpl(profile, kIconSize, this)) {
106 icon_loader_->FetchImage(extension.id()); 108 icon_loader_->FetchImage(extension.id());
107 } 109 }
108 110
109 RequestFileSystemNotification::~RequestFileSystemNotification() { 111 RequestFileSystemNotification::~RequestFileSystemNotification() {
110 } 112 }
111 113
112 void RequestFileSystemNotification::Show( 114 void RequestFileSystemNotification::Show(
113 scoped_ptr<Notification> notification) { 115 scoped_ptr<Notification> notification) {
114 pending_notification_.reset(notification.release()); 116 pending_notification_.reset(notification.release());
115 // If the extension icon is not known yet, then defer showing the notification 117 // If the extension icon is not known yet, then defer showing the notification
116 // until it is (from SetAppImage). 118 // until it is (from SetAppImage).
117 if (!extension_icon_.get()) 119 if (!extension_icon_.get())
118 return; 120 return;
119 121
120 pending_notification_->set_icon(*extension_icon_.get()); 122 pending_notification_->set_icon(*extension_icon_.get());
121 g_browser_process->message_center()->AddNotification( 123 g_browser_process->message_center()->AddNotification(
122 pending_notification_.Pass()); 124 std::move(pending_notification_));
123 } 125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698