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

Side by Side Diff: chrome/browser/ui/views/app_list/app_list_controller_win.cc

Issue 13947002: Update App Launcher icons, splitting for Chromium, Chrome, Canary. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: move to app_list_service_win.cc Created 7 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
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 <sstream> 5 #include <sstream>
6 6
7 #include "apps/switches.h" 7 #include "apps/switches.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 29 matching lines...) Expand all
40 #include "chrome/common/chrome_switches.h" 40 #include "chrome/common/chrome_switches.h"
41 #include "chrome/common/pref_names.h" 41 #include "chrome/common/pref_names.h"
42 #include "chrome/installer/launcher_support/chrome_launcher_support.h" 42 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
43 #include "chrome/installer/util/browser_distribution.h" 43 #include "chrome/installer/util/browser_distribution.h"
44 #include "chrome/installer/util/google_update_settings.h" 44 #include "chrome/installer/util/google_update_settings.h"
45 #include "chrome/installer/util/util_constants.h" 45 #include "chrome/installer/util/util_constants.h"
46 #include "content/public/browser/browser_thread.h" 46 #include "content/public/browser/browser_thread.h"
47 #include "grit/chromium_strings.h" 47 #include "grit/chromium_strings.h"
48 #include "grit/generated_resources.h" 48 #include "grit/generated_resources.h"
49 #include "grit/google_chrome_strings.h" 49 #include "grit/google_chrome_strings.h"
50 #include "grit/theme_resources.h"
51 #include "ui/app_list/pagination_model.h" 50 #include "ui/app_list/pagination_model.h"
52 #include "ui/app_list/views/app_list_view.h" 51 #include "ui/app_list/views/app_list_view.h"
53 #include "ui/base/l10n/l10n_util.h" 52 #include "ui/base/l10n/l10n_util.h"
54 #include "ui/base/resource/resource_bundle.h" 53 #include "ui/base/resource/resource_bundle.h"
55 #include "ui/base/win/shell.h" 54 #include "ui/base/win/shell.h"
56 #include "ui/gfx/display.h" 55 #include "ui/gfx/display.h"
57 #include "ui/gfx/image/image_skia.h" 56 #include "ui/gfx/image/image_skia.h"
58 #include "ui/gfx/screen.h" 57 #include "ui/gfx/screen.h"
59 #include "ui/views/bubble/bubble_border.h" 58 #include "ui/views/bubble/bubble_border.h"
60 #include "ui/views/widget/widget.h" 59 #include "ui/views/widget/widget.h"
61 #include "win8/util/win8_util.h" 60 #include "win8/util/win8_util.h"
62 61
62 #if defined(GOOGLE_CHROME_BUILD)
63 #include "chrome/installer/util/install_util.h"
64 #endif
65
63 #if defined(USE_AURA) 66 #if defined(USE_AURA)
64 #include "ui/aura/root_window.h" 67 #include "ui/aura/root_window.h"
65 #include "ui/aura/window.h" 68 #include "ui/aura/window.h"
66 #endif 69 #endif
67 70
68 namespace { 71 namespace {
69 72
70 // Offset from the cursor to the point of the bubble arrow. It looks weird 73 // Offset from the cursor to the point of the bubble arrow. It looks weird
71 // if the arrow comes up right on top of the cursor, so it is offset by this 74 // if the arrow comes up right on top of the cursor, so it is offset by this
72 // amount. 75 // amount.
73 static const int kAnchorOffset = 25; 76 static const int kAnchorOffset = 25;
74 77
75 static const wchar_t kTrayClassName[] = L"Shell_TrayWnd"; 78 static const wchar_t kTrayClassName[] = L"Shell_TrayWnd";
76 79
77 // Icons are added to the resources of the DLL using icon names. The icon index 80 // Icons are added to the resources of the DLL using icon names. The icon index
78 // for the app list icon is named IDR_X_APP_LIST. Creating shortcuts needs to 81 // for the app list icon is named IDR_X_APP_LIST or (for official builds)
79 // specify a resource index, which are different to icon names. They are 0 82 // IDR_X_APP_LIST_SXS for Chrome Canary. Creating shortcuts needs to specify a
80 // based and contiguous. As Google Chrome builds have extra icons the icon for 83 // resource index, which are different to icon names. They are 0 based and
81 // Google Chrome builds need to be higher. Unfortunately these indexes are not 84 // contiguous. As Google Chrome builds have extra icons the icon for Google
82 // in any generated header file. 85 // Chrome builds need to be higher. Unfortunately these indexes are not in any
86 // generated header file.
87 int GetAppListIconIndex() {
88 const int kAppListIconIndex = 5;
89 const int kAppListIconIndexSxS = 6;
90 const int kAppListIconIndexChromium = 1;
83 #if defined(GOOGLE_CHROME_BUILD) 91 #if defined(GOOGLE_CHROME_BUILD)
84 const int kAppListIconIndex = 5; 92 if (InstallUtil::IsChromeSxSProcess())
93 return kAppListIconIndexSxS;
94 return kAppListIconIndex;
85 #else 95 #else
86 const int kAppListIconIndex = 1; 96 return kAppListIconIndexChromium;
87 #endif 97 #endif
98 }
88 99
89 CommandLine GetAppListCommandLine() { 100 CommandLine GetAppListCommandLine() {
90 const char* const kSwitchesToCopy[] = { switches::kUserDataDir }; 101 const char* const kSwitchesToCopy[] = { switches::kUserDataDir };
91 CommandLine* current = CommandLine::ForCurrentProcess(); 102 CommandLine* current = CommandLine::ForCurrentProcess();
92 CommandLine command_line(current->GetProgram()); 103 CommandLine command_line(current->GetProgram());
93 command_line.CopySwitchesFrom(*current, kSwitchesToCopy, 104 command_line.CopySwitchesFrom(*current, kSwitchesToCopy,
94 arraysize(kSwitchesToCopy)); 105 arraysize(kSwitchesToCopy));
95 command_line.AppendSwitch(switches::kShowAppList); 106 command_line.AppendSwitch(switches::kShowAppList);
96 return command_line; 107 return command_line;
97 } 108 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 public: 170 public:
160 ScopedKeepAlive(); 171 ScopedKeepAlive();
161 ~ScopedKeepAlive(); 172 ~ScopedKeepAlive();
162 173
163 private: 174 private:
164 DISALLOW_COPY_AND_ASSIGN(ScopedKeepAlive); 175 DISALLOW_COPY_AND_ASSIGN(ScopedKeepAlive);
165 }; 176 };
166 177
167 // The AppListController class manages global resources needed for the app 178 // The AppListController class manages global resources needed for the app
168 // list to operate, and controls when the app list is opened and closed. 179 // list to operate, and controls when the app list is opened and closed.
169 // TODO(tapted): Rename this class to AppListServiceWin and move entire file to 180 // TODO(tapted): Rename this class to AppListServiceWin and move entire file to
tapted 2013/04/10 06:36:38 Hrm. Still need to do this. This will make app_lis
170 // chrome/browser/ui/app_list/app_list_service_win.cc after removing 181 // chrome/browser/ui/app_list/app_list_service_win.cc after removing
171 // chrome/browser/ui/views dependency. 182 // chrome/browser/ui/views dependency.
172 class AppListController : public AppListService { 183 class AppListController : public AppListService {
173 public: 184 public:
174 virtual ~AppListController(); 185 virtual ~AppListController();
175 186
176 static AppListController* GetInstance() { 187 static AppListController* GetInstance() {
177 return Singleton<AppListController, 188 return Singleton<AppListController,
178 LeakySingletonTraits<AppListController> >::get(); 189 LeakySingletonTraits<AppListController> >::get();
179 } 190 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 AppListController::GetInstance()->AppListClosing(); 338 AppListController::GetInstance()->AppListClosing();
328 } 339 }
329 340
330 gfx::NativeWindow AppListControllerDelegateWin::GetAppListWindow() { 341 gfx::NativeWindow AppListControllerDelegateWin::GetAppListWindow() {
331 app_list::AppListView* view = AppListController::GetInstance()->GetView(); 342 app_list::AppListView* view = AppListController::GetInstance()->GetView();
332 return view ? view->GetWidget()->GetNativeWindow() : NULL; 343 return view ? view->GetWidget()->GetNativeWindow() : NULL;
333 } 344 }
334 345
335 gfx::ImageSkia AppListControllerDelegateWin::GetWindowIcon() { 346 gfx::ImageSkia AppListControllerDelegateWin::GetWindowIcon() {
336 gfx::ImageSkia* resource = ResourceBundle::GetSharedInstance(). 347 gfx::ImageSkia* resource = ResourceBundle::GetSharedInstance().
337 GetImageSkiaNamed(IDR_APP_LIST); 348 GetImageSkiaNamed(chrome::GetAppListIconResourceId());
338 return *resource; 349 return *resource;
339 } 350 }
340 351
341 bool AppListControllerDelegateWin::CanPin() { 352 bool AppListControllerDelegateWin::CanPin() {
342 return false; 353 return false;
343 } 354 }
344 355
345 void AppListControllerDelegateWin::OnShowExtensionPrompt() { 356 void AppListControllerDelegateWin::OnShowExtensionPrompt() {
346 AppListController::GetInstance()->set_can_close(false); 357 AppListController::GetInstance()->set_can_close(false);
347 } 358 }
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 } 731 }
721 732
722 string16 AppListController::GetAppListIconPath() { 733 string16 AppListController::GetAppListIconPath() {
723 base::FilePath icon_path; 734 base::FilePath icon_path;
724 if (!PathService::Get(base::FILE_EXE, &icon_path)) { 735 if (!PathService::Get(base::FILE_EXE, &icon_path)) {
725 NOTREACHED(); 736 NOTREACHED();
726 return string16(); 737 return string16();
727 } 738 }
728 739
729 std::stringstream ss; 740 std::stringstream ss;
730 ss << "," << kAppListIconIndex; 741 ss << "," << GetAppListIconIndex();
731 string16 result = icon_path.value(); 742 string16 result = icon_path.value();
732 result.append(UTF8ToUTF16(ss.str())); 743 result.append(UTF8ToUTF16(ss.str()));
733 return result; 744 return result;
734 } 745 }
735 746
736 void AppListController::CheckTaskbarOrViewHasFocus() { 747 void AppListController::CheckTaskbarOrViewHasFocus() {
737 // Remember if the taskbar had focus without the right mouse button being 748 // Remember if the taskbar had focus without the right mouse button being
738 // down. 749 // down.
739 bool was_preserving_focus = preserving_focus_for_taskbar_menu_; 750 bool was_preserving_focus = preserving_focus_for_taskbar_menu_;
740 preserving_focus_for_taskbar_menu_ = false; 751 preserving_focus_for_taskbar_menu_ = false;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 865
855 base::win::ShortcutProperties shortcut_properties; 866 base::win::ShortcutProperties shortcut_properties;
856 shortcut_properties.set_target(chrome_exe); 867 shortcut_properties.set_target(chrome_exe);
857 shortcut_properties.set_working_dir(chrome_exe.DirName()); 868 shortcut_properties.set_working_dir(chrome_exe.DirName());
858 869
859 string16 wide_switches(GetAppListCommandLine().GetArgumentsString()); 870 string16 wide_switches(GetAppListCommandLine().GetArgumentsString());
860 shortcut_properties.set_arguments(wide_switches); 871 shortcut_properties.set_arguments(wide_switches);
861 shortcut_properties.set_description(l10n_util::GetStringUTF16( 872 shortcut_properties.set_description(l10n_util::GetStringUTF16(
862 IDS_APP_LIST_SHORTCUT_NAME)); 873 IDS_APP_LIST_SHORTCUT_NAME));
863 874
864 shortcut_properties.set_icon(chrome_exe, kAppListIconIndex); 875 shortcut_properties.set_icon(chrome_exe, GetAppListIconIndex());
865 shortcut_properties.set_app_id(app_model_id); 876 shortcut_properties.set_app_id(app_model_id);
866 877
867 const base::FilePath shortcut_path( 878 const base::FilePath shortcut_path(
868 GetAppListTaskbarShortcutPath(user_data_dir)); 879 GetAppListTaskbarShortcutPath(user_data_dir));
869 base::win::CreateOrUpdateShortcutLink(shortcut_path, shortcut_properties, 880 base::win::CreateOrUpdateShortcutLink(shortcut_path, shortcut_properties,
870 base::win::SHORTCUT_CREATE_ALWAYS); 881 base::win::SHORTCUT_CREATE_ALWAYS);
871 882
872 if (!base::win::TaskbarPinShortcutLink(shortcut_path.value().c_str())) 883 if (!base::win::TaskbarPinShortcutLink(shortcut_path.value().c_str()))
873 LOG(WARNING) << "Failed to pin AppList using " << shortcut_path.value(); 884 LOG(WARNING) << "Failed to pin AppList using " << shortcut_path.value();
874 } 885 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 984
974 } // namespace 985 } // namespace
975 986
976 namespace chrome { 987 namespace chrome {
977 988
978 AppListService* GetAppListServiceWin() { 989 AppListService* GetAppListServiceWin() {
979 return AppListController::GetInstance(); 990 return AppListController::GetInstance();
980 } 991 }
981 992
982 } // namespace chrome 993 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698