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

Side by Side Diff: chrome/browser/ui/views/ash/launcher/launcher_context_menu.cc

Issue 10066015: ash: Replace launcher app type with Extension launch type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/ash/launcher/launcher_context_menu.h" 5 #include "chrome/browser/ui/views/ash/launcher/launcher_context_menu.h"
6 6
7 #include "ash/launcher/launcher_context_menu.h" 7 #include "ash/launcher/launcher_context_menu.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "chrome/browser/extensions/extension_prefs.h"
9 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h" 10 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h"
10 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
11 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
12 13
13 LauncherContextMenu::LauncherContextMenu(ChromeLauncherDelegate* delegate, 14 LauncherContextMenu::LauncherContextMenu(ChromeLauncherDelegate* delegate,
14 const ash::LauncherItem* item) 15 const ash::LauncherItem* item)
15 : ui::SimpleMenuModel(NULL), 16 : ui::SimpleMenuModel(NULL),
16 delegate_(delegate), 17 delegate_(delegate),
17 item_(item ? *item : ash::LauncherItem()) { 18 item_(item ? *item : ash::LauncherItem()) {
18 set_delegate(this); 19 set_delegate(this);
19 20
20 if (is_valid_item()) { 21 if (is_valid_item()) {
21 if (item_.type == ash::TYPE_APP_SHORTCUT) { 22 if (item_.type == ash::TYPE_APP_SHORTCUT) {
22 DCHECK(delegate->IsPinned(item_.id)); 23 DCHECK(delegate->IsPinned(item_.id));
23 AddItem( 24 AddItem(
24 MENU_PIN, 25 MENU_PIN,
25 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_UNPIN)); 26 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_UNPIN));
27 AddSeparator();
26 AddCheckItemWithStringId( 28 AddCheckItemWithStringId(
27 LAUNCH_TYPE_REGULAR_TAB, 29 LAUNCH_TYPE_REGULAR_TAB,
28 IDS_APP_CONTEXT_MENU_OPEN_REGULAR); 30 IDS_APP_CONTEXT_MENU_OPEN_REGULAR);
29 AddCheckItemWithStringId( 31 AddCheckItemWithStringId(
32 LAUNCH_TYPE_PINNED_TAB,
33 IDS_APP_CONTEXT_MENU_OPEN_PINNED);
34 AddCheckItemWithStringId(
30 LAUNCH_TYPE_WINDOW, 35 LAUNCH_TYPE_WINDOW,
31 IDS_APP_CONTEXT_MENU_OPEN_WINDOW); 36 IDS_APP_CONTEXT_MENU_OPEN_WINDOW);
37 AddCheckItemWithStringId(
38 LAUNCH_TYPE_FULLSCREEN,
39 IDS_APP_CONTEXT_MENU_OPEN_FULLSCREEN);
32 } else { 40 } else {
33 AddItem(MENU_OPEN, delegate->GetTitle(item_)); 41 AddItem(MENU_OPEN, delegate->GetTitle(item_));
34 if (delegate->IsOpen(item_.id)) { 42 if (delegate->IsOpen(item_.id)) {
35 AddItem(MENU_CLOSE, 43 AddItem(MENU_CLOSE,
36 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); 44 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE));
37 } 45 }
38 } 46 }
39 AddSeparator(); 47 AddSeparator();
40 } 48 }
41 AddCheckItemWithStringId( 49 AddCheckItemWithStringId(
42 MENU_AUTO_HIDE, ash::LauncherContextMenu::GetAutoHideResourceStringId()); 50 MENU_AUTO_HIDE, ash::LauncherContextMenu::GetAutoHideResourceStringId());
43 } 51 }
44 52
45 LauncherContextMenu::~LauncherContextMenu() { 53 LauncherContextMenu::~LauncherContextMenu() {
46 } 54 }
47 55
48 bool LauncherContextMenu::IsCommandIdChecked(int command_id) const { 56 bool LauncherContextMenu::IsCommandIdChecked(int command_id) const {
49 switch (command_id) { 57 switch (command_id) {
58 case LAUNCH_TYPE_PINNED_TAB:
59 return delegate_->GetLaunchType(item_.id) ==
60 ExtensionPrefs::LAUNCH_PINNED;
50 case LAUNCH_TYPE_REGULAR_TAB: 61 case LAUNCH_TYPE_REGULAR_TAB:
51 return delegate_->GetAppType(item_.id) == 62 return delegate_->GetLaunchType(item_.id) ==
52 ChromeLauncherDelegate::APP_TYPE_TAB; 63 ExtensionPrefs::LAUNCH_REGULAR;
53 case LAUNCH_TYPE_WINDOW: 64 case LAUNCH_TYPE_WINDOW:
54 return delegate_->GetAppType(item_.id) == 65 return delegate_->GetLaunchType(item_.id) ==
55 ChromeLauncherDelegate::APP_TYPE_WINDOW; 66 ExtensionPrefs::LAUNCH_WINDOW;
67 case LAUNCH_TYPE_FULLSCREEN:
68 return delegate_->GetLaunchType(item_.id) ==
69 ExtensionPrefs::LAUNCH_FULLSCREEN;
56 case MENU_AUTO_HIDE: 70 case MENU_AUTO_HIDE:
57 return ash::LauncherContextMenu::IsAutoHideMenuHideChecked(); 71 return ash::LauncherContextMenu::IsAutoHideMenuHideChecked();
58 default: 72 default:
59 return false; 73 return false;
60 } 74 }
61 } 75 }
62 76
63 bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const { 77 bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const {
64 return true; 78 return true;
65 } 79 }
66 80
67 bool LauncherContextMenu::GetAcceleratorForCommandId( 81 bool LauncherContextMenu::GetAcceleratorForCommandId(
68 int command_id, 82 int command_id,
69 ui::Accelerator* accelerator) { 83 ui::Accelerator* accelerator) {
70 return false; 84 return false;
71 } 85 }
72 86
73 void LauncherContextMenu::ExecuteCommand(int command_id) { 87 void LauncherContextMenu::ExecuteCommand(int command_id) {
74 switch (static_cast<MenuItem>(command_id)) { 88 switch (static_cast<MenuItem>(command_id)) {
75 case MENU_OPEN: 89 case MENU_OPEN:
76 delegate_->Open(item_.id); 90 delegate_->Open(item_.id);
77 break; 91 break;
78 case MENU_CLOSE: 92 case MENU_CLOSE:
79 delegate_->Close(item_.id); 93 delegate_->Close(item_.id);
80 break; 94 break;
81 case MENU_PIN: 95 case MENU_PIN:
82 delegate_->TogglePinned(item_.id); 96 delegate_->TogglePinned(item_.id);
83 break; 97 break;
98 case LAUNCH_TYPE_PINNED_TAB:
99 delegate_->SetLaunchType(item_.id, ExtensionPrefs::LAUNCH_PINNED);
100 break;
84 case LAUNCH_TYPE_REGULAR_TAB: 101 case LAUNCH_TYPE_REGULAR_TAB:
85 delegate_->SetAppType(item_.id, ChromeLauncherDelegate::APP_TYPE_TAB); 102 delegate_->SetLaunchType(item_.id, ExtensionPrefs::LAUNCH_REGULAR);
86 break; 103 break;
87 case LAUNCH_TYPE_WINDOW: 104 case LAUNCH_TYPE_WINDOW:
88 delegate_->SetAppType(item_.id, ChromeLauncherDelegate::APP_TYPE_WINDOW); 105 delegate_->SetLaunchType(item_.id, ExtensionPrefs::LAUNCH_WINDOW);
106 break;
107 case LAUNCH_TYPE_FULLSCREEN:
108 delegate_->SetLaunchType(item_.id, ExtensionPrefs::LAUNCH_FULLSCREEN);
89 break; 109 break;
90 case MENU_AUTO_HIDE: 110 case MENU_AUTO_HIDE:
91 return ash::LauncherContextMenu::ToggleAutoHideMenu(); 111 return ash::LauncherContextMenu::ToggleAutoHideMenu();
92 } 112 }
93 } 113 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/ash/launcher/launcher_context_menu.h ('k') | chrome/browser/ui/views/ash/launcher/launcher_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698