blob: 26d0840dc4e9e4327071e8934e3e9795f57ef437 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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_);
}
}
|