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 "chrome/browser/chromeos/extensions/wallpaper_manager_api.h" | 5 #include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | |
9 #include "base/path_service.h" | |
10 #include "chrome/browser/browser_process.h" | |
11 #include "chrome/browser/chromeos/login/user_manager.h" | |
12 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
17 #include "chrome/browser/ui/chrome_pages.h" | 13 #include "chrome/browser/ui/chrome_pages.h" |
18 #include "chrome/browser/ui/extensions/application_launch.h" | 14 #include "chrome/browser/ui/extensions/application_launch.h" |
19 #include "chrome/common/chrome_paths.h" | |
20 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
22 #include "content/public/browser/browser_thread.h" | |
23 | 17 |
24 using content::BrowserThread; | 18 const char kWallpaperManagerID[] = "obklkkbkpaoaejdabbfldmcfplpdgolj"; |
25 | |
26 const char kWallpaperManagerDomain[] = "obklkkbkpaoaejdabbfldmcfplpdgolj"; | |
27 | 19 |
28 namespace wallpaper_manager_util { | 20 namespace wallpaper_manager_util { |
29 | 21 |
30 void OpenWallpaperManager() { | 22 void OpenWallpaperManager() { |
31 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | 23 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
32 // Hides the new UI container behind a flag. | 24 // Hides the new UI container behind a flag. |
33 if (CommandLine::ForCurrentProcess()->HasSwitch( | 25 if (CommandLine::ForCurrentProcess()->HasSwitch( |
34 switches::kExperimentalWallpaperUI)) { | 26 switches::kExperimentalWallpaperUI)) { |
35 std::string url = chrome::kChromeUIWallpaperURL; | 27 std::string url = chrome::kChromeUIWallpaperURL; |
36 ExtensionService* service = profile->GetExtensionService(); | 28 ExtensionService* service = profile->GetExtensionService(); |
37 if (!service) | 29 if (!service) |
38 return; | 30 return; |
39 | 31 |
40 const extensions::Extension* extension = | 32 const extensions::Extension* extension = |
41 service->GetExtensionById(kWallpaperManagerDomain, false); | 33 service->GetExtensionById(kWallpaperManagerID, false); |
42 if (!extension) | 34 if (!extension) |
43 return; | 35 return; |
44 | 36 |
45 application_launch::LaunchParams params(profile, extension, | 37 application_launch::LaunchParams params(profile, extension, |
46 extension_misc::LAUNCH_WINDOW, | 38 extension_misc::LAUNCH_WINDOW, |
47 NEW_FOREGROUND_TAB); | 39 NEW_FOREGROUND_TAB); |
48 params.override_url = GURL(url); | 40 params.override_url = GURL(url); |
49 application_launch::OpenApplication(params); | 41 application_launch::OpenApplication(params); |
50 } else { | 42 } else { |
51 Browser* browser = browser::FindOrCreateTabbedBrowser( | 43 Browser* browser = browser::FindOrCreateTabbedBrowser( |
52 ProfileManager::GetDefaultProfileOrOffTheRecord()); | 44 ProfileManager::GetDefaultProfileOrOffTheRecord()); |
53 chrome::ShowSettingsSubPage(browser, "setWallpaper"); | 45 chrome::ShowSettingsSubPage(browser, "setWallpaper"); |
54 } | 46 } |
55 } | 47 } |
56 | 48 |
57 } // namespace wallpaper_manager_util | 49 } // namespace wallpaper_manager_util |
OLD | NEW |