OLD | NEW |
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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "apps/pref_names.h" | 7 #include "apps/pref_names.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
42 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
43 #include "chrome/installer/launcher_support/chrome_launcher_support.h" | 43 #include "chrome/installer/launcher_support/chrome_launcher_support.h" |
44 #include "chrome/installer/util/browser_distribution.h" | 44 #include "chrome/installer/util/browser_distribution.h" |
45 #include "chrome/installer/util/google_update_settings.h" | 45 #include "chrome/installer/util/google_update_settings.h" |
46 #include "chrome/installer/util/util_constants.h" | 46 #include "chrome/installer/util/util_constants.h" |
47 #include "content/public/browser/browser_thread.h" | 47 #include "content/public/browser/browser_thread.h" |
48 #include "grit/chromium_strings.h" | 48 #include "grit/chromium_strings.h" |
49 #include "grit/generated_resources.h" | 49 #include "grit/generated_resources.h" |
50 #include "grit/google_chrome_strings.h" | 50 #include "grit/google_chrome_strings.h" |
51 #include "grit/theme_resources.h" | |
52 #include "ui/app_list/pagination_model.h" | 51 #include "ui/app_list/pagination_model.h" |
53 #include "ui/app_list/views/app_list_view.h" | 52 #include "ui/app_list/views/app_list_view.h" |
54 #include "ui/base/l10n/l10n_util.h" | 53 #include "ui/base/l10n/l10n_util.h" |
55 #include "ui/base/resource/resource_bundle.h" | 54 #include "ui/base/resource/resource_bundle.h" |
56 #include "ui/base/win/shell.h" | 55 #include "ui/base/win/shell.h" |
57 #include "ui/gfx/display.h" | 56 #include "ui/gfx/display.h" |
58 #include "ui/gfx/image/image_skia.h" | 57 #include "ui/gfx/image/image_skia.h" |
59 #include "ui/gfx/screen.h" | 58 #include "ui/gfx/screen.h" |
60 #include "ui/views/bubble/bubble_border.h" | 59 #include "ui/views/bubble/bubble_border.h" |
61 #include "ui/views/widget/widget.h" | 60 #include "ui/views/widget/widget.h" |
62 #include "win8/util/win8_util.h" | 61 #include "win8/util/win8_util.h" |
63 | 62 |
| 63 #if defined(GOOGLE_CHROME_BUILD) |
| 64 #include "chrome/installer/util/install_util.h" |
| 65 #endif |
| 66 |
64 #if defined(USE_AURA) | 67 #if defined(USE_AURA) |
65 #include "ui/aura/root_window.h" | 68 #include "ui/aura/root_window.h" |
66 #include "ui/aura/window.h" | 69 #include "ui/aura/window.h" |
67 #endif | 70 #endif |
68 | 71 |
69 namespace { | 72 namespace { |
70 | 73 |
71 // Offset from the cursor to the point of the bubble arrow. It looks weird | 74 // Offset from the cursor to the point of the bubble arrow. It looks weird |
72 // if the arrow comes up right on top of the cursor, so it is offset by this | 75 // if the arrow comes up right on top of the cursor, so it is offset by this |
73 // amount. | 76 // amount. |
74 static const int kAnchorOffset = 25; | 77 static const int kAnchorOffset = 25; |
75 | 78 |
76 static const wchar_t kTrayClassName[] = L"Shell_TrayWnd"; | 79 static const wchar_t kTrayClassName[] = L"Shell_TrayWnd"; |
77 | 80 |
78 // Icons are added to the resources of the DLL using icon names. The icon index | 81 // Icons are added to the resources of the DLL using icon names. The icon index |
79 // for the app list icon is named IDR_X_APP_LIST. Creating shortcuts needs to | 82 // for the app list icon is named IDR_X_APP_LIST or (for official builds) |
80 // specify a resource index, which are different to icon names. They are 0 | 83 // IDR_X_APP_LIST_SXS for Chrome Canary. Creating shortcuts needs to specify a |
81 // based and contiguous. As Google Chrome builds have extra icons the icon for | 84 // resource index, which are different to icon names. They are 0 based and |
82 // Google Chrome builds need to be higher. Unfortunately these indexes are not | 85 // contiguous. As Google Chrome builds have extra icons the icon for Google |
83 // in any generated header file. | 86 // Chrome builds need to be higher. Unfortunately these indexes are not in any |
| 87 // generated header file. |
| 88 int GetAppListIconIndex() { |
| 89 const int kAppListIconIndex = 5; |
| 90 const int kAppListIconIndexSxS = 6; |
| 91 const int kAppListIconIndexChromium = 1; |
84 #if defined(GOOGLE_CHROME_BUILD) | 92 #if defined(GOOGLE_CHROME_BUILD) |
85 const int kAppListIconIndex = 5; | 93 if (InstallUtil::IsChromeSxSProcess()) |
| 94 return kAppListIconIndexSxS; |
| 95 return kAppListIconIndex; |
86 #else | 96 #else |
87 const int kAppListIconIndex = 1; | 97 return kAppListIconIndexChromium; |
88 #endif | 98 #endif |
| 99 } |
89 | 100 |
90 CommandLine GetAppListCommandLine() { | 101 CommandLine GetAppListCommandLine() { |
91 const char* const kSwitchesToCopy[] = { switches::kUserDataDir }; | 102 const char* const kSwitchesToCopy[] = { switches::kUserDataDir }; |
92 CommandLine* current = CommandLine::ForCurrentProcess(); | 103 CommandLine* current = CommandLine::ForCurrentProcess(); |
93 base::FilePath chrome_exe; | 104 base::FilePath chrome_exe; |
94 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { | 105 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
95 NOTREACHED(); | 106 NOTREACHED(); |
96 return CommandLine(CommandLine::NO_PROGRAM); | 107 return CommandLine(CommandLine::NO_PROGRAM); |
97 } | 108 } |
98 CommandLine command_line(chrome_exe); | 109 CommandLine command_line(chrome_exe); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 176 } |
166 | 177 |
167 string16 wide_switches(GetAppListCommandLine().GetArgumentsString()); | 178 string16 wide_switches(GetAppListCommandLine().GetArgumentsString()); |
168 | 179 |
169 base::win::ShortcutProperties shortcut_properties; | 180 base::win::ShortcutProperties shortcut_properties; |
170 shortcut_properties.set_target(chrome_exe); | 181 shortcut_properties.set_target(chrome_exe); |
171 shortcut_properties.set_working_dir(chrome_exe.DirName()); | 182 shortcut_properties.set_working_dir(chrome_exe.DirName()); |
172 shortcut_properties.set_arguments(wide_switches); | 183 shortcut_properties.set_arguments(wide_switches); |
173 shortcut_properties.set_description( | 184 shortcut_properties.set_description( |
174 l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME)); | 185 l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME)); |
175 shortcut_properties.set_icon(chrome_exe, kAppListIconIndex); | 186 shortcut_properties.set_icon(chrome_exe, GetAppListIconIndex()); |
176 shortcut_properties.set_app_id(app_model_id); | 187 shortcut_properties.set_app_id(app_model_id); |
177 | 188 |
178 const string16 file_name = | 189 const string16 file_name = |
179 l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME); | 190 l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME); |
180 | 191 |
181 for (size_t i = 0; i < shortcut_paths.size(); ++i) { | 192 for (size_t i = 0; i < shortcut_paths.size(); ++i) { |
182 base::FilePath shortcut_file = shortcut_paths[i].Append(file_name). | 193 base::FilePath shortcut_file = shortcut_paths[i].Append(file_name). |
183 AddExtension(installer::kLnkExt); | 194 AddExtension(installer::kLnkExt); |
184 if (!file_util::PathExists(shortcut_file.DirName()) && | 195 if (!file_util::PathExists(shortcut_file.DirName()) && |
185 !file_util::CreateDirectory(shortcut_file.DirName())) { | 196 !file_util::CreateDirectory(shortcut_file.DirName())) { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 AppListController::GetInstance()->AppListClosing(); | 412 AppListController::GetInstance()->AppListClosing(); |
402 } | 413 } |
403 | 414 |
404 gfx::NativeWindow AppListControllerDelegateWin::GetAppListWindow() { | 415 gfx::NativeWindow AppListControllerDelegateWin::GetAppListWindow() { |
405 app_list::AppListView* view = AppListController::GetInstance()->GetView(); | 416 app_list::AppListView* view = AppListController::GetInstance()->GetView(); |
406 return view ? view->GetWidget()->GetNativeWindow() : NULL; | 417 return view ? view->GetWidget()->GetNativeWindow() : NULL; |
407 } | 418 } |
408 | 419 |
409 gfx::ImageSkia AppListControllerDelegateWin::GetWindowIcon() { | 420 gfx::ImageSkia AppListControllerDelegateWin::GetWindowIcon() { |
410 gfx::ImageSkia* resource = ResourceBundle::GetSharedInstance(). | 421 gfx::ImageSkia* resource = ResourceBundle::GetSharedInstance(). |
411 GetImageSkiaNamed(IDR_APP_LIST); | 422 GetImageSkiaNamed(chrome::GetAppListIconResourceId()); |
412 return *resource; | 423 return *resource; |
413 } | 424 } |
414 | 425 |
415 bool AppListControllerDelegateWin::CanPin() { | 426 bool AppListControllerDelegateWin::CanPin() { |
416 return false; | 427 return false; |
417 } | 428 } |
418 | 429 |
419 void AppListControllerDelegateWin::OnShowExtensionPrompt() { | 430 void AppListControllerDelegateWin::OnShowExtensionPrompt() { |
420 AppListController::GetInstance()->set_can_close(false); | 431 AppListController::GetInstance()->set_can_close(false); |
421 } | 432 } |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 } | 805 } |
795 | 806 |
796 string16 AppListController::GetAppListIconPath() { | 807 string16 AppListController::GetAppListIconPath() { |
797 base::FilePath icon_path; | 808 base::FilePath icon_path; |
798 if (!PathService::Get(base::FILE_EXE, &icon_path)) { | 809 if (!PathService::Get(base::FILE_EXE, &icon_path)) { |
799 NOTREACHED(); | 810 NOTREACHED(); |
800 return string16(); | 811 return string16(); |
801 } | 812 } |
802 | 813 |
803 std::stringstream ss; | 814 std::stringstream ss; |
804 ss << "," << kAppListIconIndex; | 815 ss << "," << GetAppListIconIndex(); |
805 string16 result = icon_path.value(); | 816 string16 result = icon_path.value(); |
806 result.append(UTF8ToUTF16(ss.str())); | 817 result.append(UTF8ToUTF16(ss.str())); |
807 return result; | 818 return result; |
808 } | 819 } |
809 | 820 |
810 void AppListController::CheckTaskbarOrViewHasFocus() { | 821 void AppListController::CheckTaskbarOrViewHasFocus() { |
811 // Remember if the taskbar had focus without the right mouse button being | 822 // Remember if the taskbar had focus without the right mouse button being |
812 // down. | 823 // down. |
813 bool was_preserving_focus = preserving_focus_for_taskbar_menu_; | 824 bool was_preserving_focus = preserving_focus_for_taskbar_menu_; |
814 preserving_focus_for_taskbar_menu_ = false; | 825 preserving_focus_for_taskbar_menu_ = false; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 | 989 |
979 } // namespace | 990 } // namespace |
980 | 991 |
981 namespace chrome { | 992 namespace chrome { |
982 | 993 |
983 AppListService* GetAppListServiceWin() { | 994 AppListService* GetAppListServiceWin() { |
984 return AppListController::GetInstance(); | 995 return AppListController::GetInstance(); |
985 } | 996 } |
986 | 997 |
987 } // namespace chrome | 998 } // namespace chrome |
OLD | NEW |