| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/system_indicator/system_indicator_manage
r.h" | 5 #include "chrome/browser/extensions/api/system_indicator/system_indicator_manage
r.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 StatusIcon* icon_; | 54 StatusIcon* icon_; |
| 55 Profile* profile_; | 55 Profile* profile_; |
| 56 ExtensionActionIconFactory icon_factory_; | 56 ExtensionActionIconFactory icon_factory_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 ExtensionIndicatorIcon* ExtensionIndicatorIcon::Create( | 59 ExtensionIndicatorIcon* ExtensionIndicatorIcon::Create( |
| 60 const Extension* extension, | 60 const Extension* extension, |
| 61 ExtensionAction* action, | 61 ExtensionAction* action, |
| 62 Profile* profile, | 62 Profile* profile, |
| 63 StatusTray* status_tray) { | 63 StatusTray* status_tray) { |
| 64 scoped_ptr<ExtensionIndicatorIcon> extension_icon( | 64 std::unique_ptr<ExtensionIndicatorIcon> extension_icon( |
| 65 new ExtensionIndicatorIcon(extension, action, profile, status_tray)); | 65 new ExtensionIndicatorIcon(extension, action, profile, status_tray)); |
| 66 | 66 |
| 67 // Check if a status icon was successfully created. | 67 // Check if a status icon was successfully created. |
| 68 if (extension_icon->icon_) | 68 if (extension_icon->icon_) |
| 69 return extension_icon.release(); | 69 return extension_icon.release(); |
| 70 | 70 |
| 71 // We could not create a status icon. | 71 // We could not create a status icon. |
| 72 return NULL; | 72 return NULL; |
| 73 } | 73 } |
| 74 | 74 |
| 75 ExtensionIndicatorIcon::~ExtensionIndicatorIcon() { | 75 ExtensionIndicatorIcon::~ExtensionIndicatorIcon() { |
| 76 if (icon_) { | 76 if (icon_) { |
| 77 icon_->RemoveObserver(this); | 77 icon_->RemoveObserver(this); |
| 78 status_tray_->RemoveStatusIcon(icon_); | 78 status_tray_->RemoveStatusIcon(icon_); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 void ExtensionIndicatorIcon::OnStatusIconClicked() { | 82 void ExtensionIndicatorIcon::OnStatusIconClicked() { |
| 83 scoped_ptr<base::ListValue> params( | 83 std::unique_ptr<base::ListValue> params( |
| 84 api::system_indicator::OnClicked::Create()); | 84 api::system_indicator::OnClicked::Create()); |
| 85 | 85 |
| 86 EventRouter* event_router = EventRouter::Get(profile_); | 86 EventRouter* event_router = EventRouter::Get(profile_); |
| 87 scoped_ptr<Event> event(new Event(events::SYSTEM_INDICATOR_ON_CLICKED, | 87 std::unique_ptr<Event> event(new Event( |
| 88 system_indicator::OnClicked::kEventName, | 88 events::SYSTEM_INDICATOR_ON_CLICKED, |
| 89 std::move(params), profile_)); | 89 system_indicator::OnClicked::kEventName, std::move(params), profile_)); |
| 90 event_router->DispatchEventToExtension(extension_->id(), std::move(event)); | 90 event_router->DispatchEventToExtension(extension_->id(), std::move(event)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void ExtensionIndicatorIcon::OnIconUpdated() { | 93 void ExtensionIndicatorIcon::OnIconUpdated() { |
| 94 icon_->SetImage( | 94 icon_->SetImage( |
| 95 icon_factory_.GetIcon(ExtensionAction::kDefaultTabId).AsImageSkia()); | 95 icon_factory_.GetIcon(ExtensionAction::kDefaultTabId).AsImageSkia()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 ExtensionIndicatorIcon::ExtensionIndicatorIcon(const Extension* extension, | 98 ExtensionIndicatorIcon::ExtensionIndicatorIcon(const Extension* extension, |
| 99 ExtensionAction* action, | 99 ExtensionAction* action, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 if (extension_icon) | 188 if (extension_icon) |
| 189 system_indicators_[extension->id()] = make_linked_ptr(extension_icon); | 189 system_indicators_[extension->id()] = make_linked_ptr(extension_icon); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void SystemIndicatorManager::RemoveIndicator(const std::string& extension_id) { | 192 void SystemIndicatorManager::RemoveIndicator(const std::string& extension_id) { |
| 193 DCHECK(thread_checker_.CalledOnValidThread()); | 193 DCHECK(thread_checker_.CalledOnValidThread()); |
| 194 system_indicators_.erase(extension_id); | 194 system_indicators_.erase(extension_id); |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace extensions | 197 } // namespace extensions |
| OLD | NEW |