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

Side by Side 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, 9 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
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/status_icons/status_tray_manager.h"
6
7 #include "app/resource_bundle.h"
8 #include "base/logging.h"
9 #include "base/string_util.h"
10 #include "chrome/browser/browser.h"
11 #include "chrome/browser/browser_list.h"
12 #include "chrome/browser/browser_window.h"
13 #include "chrome/browser/status_icons/status_tray.h"
14 #include "grit/browser_resources.h"
15 #include "grit/theme_resources.h"
16
17 class StatusIconFactoryImpl : public StatusIconFactory {
18 public:
19 virtual StatusIcon* CreateIcon();
20 };
21
22 StatusIcon* StatusIconFactoryImpl::CreateIcon() {
23 #ifdef OS_MACOSX
24 return StatusIcon::Create();
25 #else
26 // TODO(atwilson): Add support for non-Mac platforms.
27 return 0;
28 #endif
29 }
30
31
32 StatusTrayManager::StatusTrayManager() {
33 }
34
35 StatusTrayManager::~StatusTrayManager() {
36 }
37
38 void StatusTrayManager::Init(Profile* profile) {
39 DCHECK(profile);
40 profile_ = profile;
41 status_tray_.reset(new StatusTray(new StatusIconFactoryImpl()));
42 StatusIcon* icon = status_tray_->GetStatusIcon(ASCIIToUTF16("chrome_main"));
43 if (icon) {
44 // Create an icon and add ourselves as a click observer on it
45 SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed(
46 IDR_STATUS_TRAY_ICON);
47 icon->SetImage(*bitmap);
48 icon->AddObserver(this);
49 }
50 }
51
52 void StatusTrayManager::OnClicked() {
53 // When the tray icon is clicked, bring up the extensions page for now.
54 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
55 if (browser) {
56 // Bring up the existing browser window and show the extensions tab.
57 browser->window()->Activate();
58 browser->ShowExtensionsTab();
59 } else {
60 // No windows are currently open, so open a new one.
61 Browser::OpenExtensionsWindow(profile_);
62 }
63 }
OLDNEW
« 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