Chromium Code Reviews| Index: chrome/browser/ui/views/app_list/app_list_controller_win.cc |
| diff --git a/chrome/browser/ui/views/app_list/app_list_controller_win.cc b/chrome/browser/ui/views/app_list/app_list_controller_win.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3666560a31b6b88be114b5ad20d949df85e37e6c |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/app_list/app_list_controller_win.cc |
| @@ -0,0 +1,103 @@ |
| +// Copyright (c) 2012 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 "base/lazy_instance.h" |
| +#include "chrome/browser/extensions/extension_service.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/ui/app_list/app_list_controller.h" |
| +#include "chrome/browser/ui/app_list/app_list_view_delegate.h" |
| +#include "chrome/browser/ui/extensions/application_launch.h" |
| +#include "grit/theme_resources.h" |
| +#include "ui/app_list/app_list_view.h" |
| +#include "ui/app_list/icon_cache.h" |
| +#include "ui/app_list/pagination_model.h" |
| +#include "ui/base/resource/resource_bundle.h" |
| +#include "ui/base/win/shell.h" |
| +#include "ui/views/bubble/bubble_border.h" |
| +#include "ui/views/widget/widget.h" |
| + |
| +namespace { |
|
msw
2012/08/29 08:02:35
nit: blank lines inside namespace braces, here and
benwells
2012/08/30 06:51:30
Done.
|
| + const wchar_t kAppListAppId[] = L"ChromeAppList"; |
|
xiyuan
2012/08/29 17:39:15
nit: After insert blank line above, shift two-spac
benwells
2012/08/30 06:51:30
Done.
|
| + const gfx::Point kDefaultAppListAnchor(500, 750); |
|
msw
2012/08/29 08:02:35
nit: consider moving this static object to ShowApp
xiyuan
2012/08/29 17:39:15
How is this anchor point picked? Just an arbitrary
benwells
2012/08/30 06:51:30
Done.
benwells
2012/08/30 06:51:30
How is this picked: yes, this is just arbitrary fo
|
| + |
| + class AppListControllerWin : public AppListController { |
| + public: |
| + AppListControllerWin() {} |
|
msw
2012/08/29 08:02:35
nit: the style guide discourages inline ctors and
benwells
2012/08/30 06:51:30
Done.
|
| + virtual ~AppListControllerWin() {} |
| + |
| + private: |
| + // AppListController overrides: |
| + virtual void CloseView() {} |
|
xiyuan
2012/08/29 17:39:15
How do we plan to implement this?
benwells
2012/08/30 06:51:30
On Windows, when you hit ESC to close the app list
|
| + |
| + virtual bool IsAppPinned(const std::string& extension_id) { |
| + return false; |
| + } |
| + |
| + virtual void PinApp(const std::string& extension_id) OVERRIDE {} |
| + |
| + virtual void UnpinApp(const std::string& extension_id) OVERRIDE {} |
| + |
| + virtual bool CanPin() OVERRIDE { |
| + return false; |
| + } |
|
xiyuan
2012/08/29 17:39:15
nit: wrong indent
benwells
2012/08/30 06:51:30
Done.
|
| + |
| + virtual void ActivateApp(Profile* profile, |
| + const std::string& extension_id, |
| + int event_flags) OVERRIDE { |
| + ExtensionService* service = profile->GetExtensionService(); |
| + DCHECK(service); |
| + const extensions::Extension* extension = service->GetInstalledExtension( |
| + extension_id); |
| + DCHECK(extension); |
| + application_launch::OpenApplication(application_launch::LaunchParams( |
| + profile, extension, extension_misc::LAUNCH_TAB, NEW_FOREGROUND_TAB)); |
| + } |
| + |
| + virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE { |
| + gfx::ImageSkia* resource = ResourceBundle::GetSharedInstance(). |
| + GetImageSkiaNamed(IDR_APP_LIST); |
| + DCHECK(resource); |
| + return *resource; |
| + }; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AppListControllerWin); |
| + }; |
| + |
| + // The AppListResources class manages global resources needed for the app |
| + // list to operate. |
| + class AppListResources { |
| + public: |
| + AppListResources::AppListResources() { |
| + app_list::IconCache::CreateInstance(); |
| + } |
| + |
| + app_list::PaginationModel* pagination_model() { return &pagination_model_; } |
| + |
| + private: |
| + app_list::PaginationModel pagination_model_; |
| + }; |
|
msw
2012/08/29 08:02:35
nit: DISALLOW_COPY_AND_ASSIGN.
benwells
2012/08/30 06:51:30
Done.
|
| + |
| + base::LazyInstance<AppListResources>::Leaky |
| + g_app_list_resources = LAZY_INSTANCE_INITIALIZER; |
| +} // namespace |
| + |
| +namespace app_list_controller { |
| + void ShowAppList() { |
| + // The controller will be owned by the view delegate, and the delegate is |
| + // owned by the app list view. The app list view manages it's own lifetime. |
| + AppListControllerWin* controller = new AppListControllerWin(); |
|
msw
2012/08/29 08:02:35
nit: consider nixing |controller|, passing new App
benwells
2012/08/30 06:51:30
Done.
|
| + app_list::AppListView* view = new app_list::AppListView( |
| + new AppListViewDelegate(controller)); |
|
msw
2012/08/29 08:02:35
nit: indent two more spaces.
benwells
2012/08/30 06:51:30
Done.
|
| + view->InitAsBubble( |
| + GetDesktopWindow(), |
| + g_app_list_resources.Get().pagination_model(), |
| + NULL, |
| + kDefaultAppListAnchor, |
| + views::BubbleBorder::BOTTOM_LEFT); |
| + view->Show(); |
| + view->GetWidget()->GetTopLevelWidget()->UpdateWindowIcon(); |
| + ui::win::SetAppIdForWindow(kAppListAppId, |
| + view->GetWidget()->GetTopLevelWidget()->GetNativeWindow()); |
| + } |
| +} // namespace app_list_controller |