Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / ash / launcher / chrome_launcher_app_menu_item_browser.cc
blob3f38fb4dfb4fac31fd7b702058dbaf17855c9159
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h"
7 #include "ash/wm/window_util.h"
8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "content/public/browser/notification_service.h"
14 #include "ui/events/event_constants.h"
16 ChromeLauncherAppMenuItemBrowser::ChromeLauncherAppMenuItemBrowser(
17 const base::string16 title,
18 const gfx::Image* icon,
19 Browser* browser,
20 bool has_leading_separator)
21 : ChromeLauncherAppMenuItem(title, icon, has_leading_separator),
22 browser_(browser) {
23 registrar_.Add(this,
24 chrome::NOTIFICATION_BROWSER_CLOSING,
25 content::Source<Browser>(browser));
28 bool ChromeLauncherAppMenuItemBrowser::IsActive() const {
29 return browser_ == chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow());
32 bool ChromeLauncherAppMenuItemBrowser::IsEnabled() const {
33 return true;
36 void ChromeLauncherAppMenuItemBrowser::Execute(int event_flags) {
37 if (browser_) {
38 if (event_flags & (ui::EF_SHIFT_DOWN | ui::EF_MIDDLE_MOUSE_BUTTON)) {
39 TabStripModel* tab_strip = browser_->tab_strip_model();
40 tab_strip->CloseAllTabs();
41 } else {
42 browser_->window()->Show();
43 ash::wm::ActivateWindow(browser_->window()->GetNativeWindow());
48 void ChromeLauncherAppMenuItemBrowser::Observe(
49 int type,
50 const content::NotificationSource& source,
51 const content::NotificationDetails& details) {
52 switch (type) {
53 case chrome::NOTIFICATION_BROWSER_CLOSING:
54 DCHECK_EQ(browser_, content::Source<Browser>(source).ptr());
55 browser_ = NULL;
56 break;
58 default:
59 NOTREACHED();