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

Unified Diff: chrome/browser/status_icons/status_tray_manager.cc

Issue 661454: Initial implementation of status tray functionality (mac-only, currently). (Closed)
Patch Set: more changes per review feedback Created 10 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/status_icons/status_tray_manager.cc
diff --git a/chrome/browser/status_icons/status_tray_manager.cc b/chrome/browser/status_icons/status_tray_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..26d0840dc4e9e4327071e8934e3e9795f57ef437
--- /dev/null
+++ b/chrome/browser/status_icons/status_tray_manager.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/status_icons/status_tray_manager.h"
+
+#include "app/resource_bundle.h"
+#include "base/logging.h"
+#include "base/string_util.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_list.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/status_icons/status_tray.h"
+#include "grit/browser_resources.h"
+#include "grit/theme_resources.h"
+
+class StatusIconFactoryImpl : public StatusIconFactory {
+ public:
+ virtual StatusIcon* CreateIcon();
+};
+
+StatusIcon* StatusIconFactoryImpl::CreateIcon() {
+#ifdef OS_MACOSX
+ return StatusIcon::Create();
+#else
+ // TODO(atwilson): Add support for non-Mac platforms.
+ return 0;
+#endif
+}
+
+
+StatusTrayManager::StatusTrayManager() {
+}
+
+StatusTrayManager::~StatusTrayManager() {
+}
+
+void StatusTrayManager::Init(Profile* profile) {
+ DCHECK(profile);
+ profile_ = profile;
+ status_tray_.reset(new StatusTray(new StatusIconFactoryImpl()));
+ StatusIcon* icon = status_tray_->GetStatusIcon(ASCIIToUTF16("chrome_main"));
+ if (icon) {
+ // Create an icon and add ourselves as a click observer on it
+ SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_STATUS_TRAY_ICON);
+ icon->SetImage(*bitmap);
+ icon->AddObserver(this);
+ }
+}
+
+void StatusTrayManager::OnClicked() {
+ // When the tray icon is clicked, bring up the extensions page for now.
+ Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
+ if (browser) {
+ // Bring up the existing browser window and show the extensions tab.
+ browser->window()->Activate();
+ browser->ShowExtensionsTab();
+ } else {
+ // No windows are currently open, so open a new one.
+ Browser::OpenExtensionsWindow(profile_);
+ }
+}
« no previous file with comments | « chrome/browser/status_icons/status_tray_manager.h ('k') | chrome/browser/status_icons/status_tray_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698