OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/api/launcher_page/launcher_page_api.h" | 5 #include "chrome/browser/extensions/api/launcher_page/launcher_page_api.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/app_list/app_list_service.h" | 9 #include "chrome/browser/ui/app_list/app_list_service.h" |
10 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" | 10 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 app_list::AppListModel* model = service->GetModel(); | 47 app_list::AppListModel* model = service->GetModel(); |
48 model->PushCustomLauncherPageSubpage(); | 48 model->PushCustomLauncherPageSubpage(); |
49 | 49 |
50 return RespondNow(NoArguments()); | 50 return RespondNow(NoArguments()); |
51 } | 51 } |
52 | 52 |
53 LauncherPageShowFunction::LauncherPageShowFunction() { | 53 LauncherPageShowFunction::LauncherPageShowFunction() { |
54 } | 54 } |
55 | 55 |
56 ExtensionFunction::ResponseAction LauncherPageShowFunction::Run() { | 56 ExtensionFunction::ResponseAction LauncherPageShowFunction::Run() { |
57 chrome::HostDesktopType host_desktop = | 57 ui::HostDesktopType host_desktop = chrome::GetHostDesktopTypeForNativeWindow( |
58 chrome::GetHostDesktopTypeForNativeWindow( | 58 GetAssociatedWebContents()->GetTopLevelNativeWindow()); |
59 GetAssociatedWebContents()->GetTopLevelNativeWindow()); | |
60 | 59 |
61 AppListService::Get(host_desktop) | 60 AppListService::Get(host_desktop) |
62 ->ShowForCustomLauncherPage( | 61 ->ShowForCustomLauncherPage( |
63 Profile::FromBrowserContext(browser_context())); | 62 Profile::FromBrowserContext(browser_context())); |
64 | 63 |
65 return RespondNow(NoArguments()); | 64 return RespondNow(NoArguments()); |
66 } | 65 } |
67 | 66 |
68 LauncherPageHideFunction::LauncherPageHideFunction() { | 67 LauncherPageHideFunction::LauncherPageHideFunction() { |
69 } | 68 } |
70 | 69 |
71 ExtensionFunction::ResponseAction LauncherPageHideFunction::Run() { | 70 ExtensionFunction::ResponseAction LauncherPageHideFunction::Run() { |
72 chrome::HostDesktopType host_desktop = | 71 ui::HostDesktopType host_desktop = chrome::GetHostDesktopTypeForNativeWindow( |
73 chrome::GetHostDesktopTypeForNativeWindow( | 72 GetAssociatedWebContents()->GetTopLevelNativeWindow()); |
74 GetAssociatedWebContents()->GetTopLevelNativeWindow()); | |
75 | 73 |
76 AppListService::Get(host_desktop)->HideCustomLauncherPage(); | 74 AppListService::Get(host_desktop)->HideCustomLauncherPage(); |
77 | 75 |
78 return RespondNow(NoArguments()); | 76 return RespondNow(NoArguments()); |
79 } | 77 } |
80 | 78 |
81 LauncherPageSetEnabledFunction::LauncherPageSetEnabledFunction() { | 79 LauncherPageSetEnabledFunction::LauncherPageSetEnabledFunction() { |
82 } | 80 } |
83 | 81 |
84 ExtensionFunction::ResponseAction LauncherPageSetEnabledFunction::Run() { | 82 ExtensionFunction::ResponseAction LauncherPageSetEnabledFunction::Run() { |
85 scoped_ptr<api::launcher_page::SetEnabled::Params> params( | 83 scoped_ptr<api::launcher_page::SetEnabled::Params> params( |
86 api::launcher_page::SetEnabled::Params::Create(*args_)); | 84 api::launcher_page::SetEnabled::Params::Create(*args_)); |
87 EXTENSION_FUNCTION_VALIDATE(params.get()); | 85 EXTENSION_FUNCTION_VALIDATE(params.get()); |
88 | 86 |
89 app_list::AppListSyncableService* service = | 87 app_list::AppListSyncableService* service = |
90 LauncherPageAPI::GetFactoryInstance() | 88 LauncherPageAPI::GetFactoryInstance() |
91 ->Get(browser_context()) | 89 ->Get(browser_context()) |
92 ->GetService(); | 90 ->GetService(); |
93 app_list::AppListModel* model = service->GetModel(); | 91 app_list::AppListModel* model = service->GetModel(); |
94 model->SetCustomLauncherPageEnabled(params->enabled); | 92 model->SetCustomLauncherPageEnabled(params->enabled); |
95 | 93 |
96 return RespondNow(NoArguments()); | 94 return RespondNow(NoArguments()); |
97 } | 95 } |
98 | 96 |
99 } // namespace extensions | 97 } // namespace extensions |
OLD | NEW |