blob: d60fc5e0f64a118db2538df7831dc130068b1e07 (
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
|
// 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/l10n_util.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/chromium_strings.h"
#include "grit/theme_resources.h"
StatusTrayManager::StatusTrayManager() : profile_(NULL) {
}
StatusTrayManager::~StatusTrayManager() {
}
void StatusTrayManager::Init(Profile* profile) {
#if !(defined(OS_LINUX) && defined(TOOLKIT_VIEWS))
DCHECK(profile);
profile_ = profile;
status_tray_.reset(StatusTray::Create());
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);
SkBitmap* pressed = ResourceBundle::GetSharedInstance().GetBitmapNamed(
IDR_STATUS_TRAY_ICON_PRESSED);
icon->SetImage(*bitmap);
icon->SetPressedImage(*pressed);
icon->SetToolTip(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
icon->AddObserver(this);
}
#endif
}
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_);
}
}
|