Commit 3dca75f7 authored by bshe@chromium.org's avatar bshe@chromium.org

Wallpaper manager backend APIs


BUG=118684
TEST=none


Review URL: https://chromiumcodereview.appspot.com/10754014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148400 0039d316-1c4b-4281-b951-d872f2087c98
parent 4d453457
...@@ -12,6 +12,14 @@ ...@@ -12,6 +12,14 @@
namespace { namespace {
// Keeps in sync (same order) with WallpaperLayout enum in header file.
const char* kWallpaperLayoutArrays[] = {
"CENTER",
"CENTER_CROPPED",
"STRETCH",
"TILE"
};
const ash::WallpaperInfo kDefaultWallpapers[] = { const ash::WallpaperInfo kDefaultWallpapers[] = {
#if !defined(GOOGLE_CHROME_BUILD) #if !defined(GOOGLE_CHROME_BUILD)
{ {
...@@ -221,6 +229,7 @@ const ash::WallpaperInfo kDefaultWallpapers[] = { ...@@ -221,6 +229,7 @@ const ash::WallpaperInfo kDefaultWallpapers[] = {
}, },
}; };
const int kWallpaperLayoutCount = arraysize(kWallpaperLayoutArrays);
const int kDefaultWallpaperCount = arraysize(kDefaultWallpapers); const int kDefaultWallpaperCount = arraysize(kDefaultWallpapers);
const int kInvalidWallpaperIndex = -1; const int kInvalidWallpaperIndex = -1;
const int kSolidColorIndex = -2; const int kSolidColorIndex = -2;
...@@ -258,6 +267,15 @@ int GetInvalidWallpaperIndex() { ...@@ -258,6 +267,15 @@ int GetInvalidWallpaperIndex() {
return kInvalidWallpaperIndex; return kInvalidWallpaperIndex;
} }
WallpaperLayout GetLayoutEnum(const std::string& layout) {
for (int i = 0; i < kWallpaperLayoutCount; i++) {
if (layout.compare(kWallpaperLayoutArrays[i]) == 0)
return static_cast<WallpaperLayout>(i);
}
// Default to use CENTER layout.
return CENTER;
}
int GetNextWallpaperIndex(int index) { int GetNextWallpaperIndex(int index) {
DCHECK(kLastRandomWallpaperIndex < kDefaultWallpaperCount); DCHECK(kLastRandomWallpaperIndex < kDefaultWallpaperCount);
return (index + 1) % (kLastRandomWallpaperIndex + 1); return (index + 1) % (kLastRandomWallpaperIndex + 1);
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_RESOURCES_H_ #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_RESOURCES_H_
#define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_RESOURCES_H_ #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_RESOURCES_H_
#include <string>
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
...@@ -32,6 +34,7 @@ const SkColor kLoginWallpaperColor = 0xFEFEFE; ...@@ -32,6 +34,7 @@ const SkColor kLoginWallpaperColor = 0xFEFEFE;
ASH_EXPORT int GetDefaultWallpaperIndex(); ASH_EXPORT int GetDefaultWallpaperIndex();
ASH_EXPORT int GetGuestWallpaperIndex(); ASH_EXPORT int GetGuestWallpaperIndex();
ASH_EXPORT int GetInvalidWallpaperIndex(); ASH_EXPORT int GetInvalidWallpaperIndex();
ASH_EXPORT WallpaperLayout GetLayoutEnum(const std::string& layout);
ASH_EXPORT int GetNextWallpaperIndex(int index); ASH_EXPORT int GetNextWallpaperIndex(int index);
ASH_EXPORT int GetSolidColorIndex(); ASH_EXPORT int GetSolidColorIndex();
ASH_EXPORT int GetWallpaperCount(); ASH_EXPORT int GetWallpaperCount();
......
...@@ -10809,6 +10809,29 @@ Some features may be unavailable. Please check that the profile exists and you ...@@ -10809,6 +10809,29 @@ Some features may be unavailable. Please check that the profile exists and you
Deny Deny
</message> </message>
<!-- Wallpaper Manager -->
<message name="IDS_WALLPAPER_MANAGER_SEARCH_TEXT_LABEL" desc="Search text field label.">
Search backgrounds
</message>
<message name="IDS_WALLPAPER_MANAGER_AUTHOR_LABEL" desc="Wallpaper author label.">
By
</message>
<message name="IDS_WALLPAPER_MANAGER_CUSTOM_CATEGORY_LABEL" desc="Wallpaper category label.">
Custom
</message>
<message name="IDS_WALLPAPER_MANAGER_SELECT_CUSTOM_LABEL" desc="Selects custom wallpaper label.">
Custom Image:
</message>
<message name="IDS_WALLPAPER_MANAGER_POSITION_LABEL" desc="Custom wallpaper position label">
Position:
</message>
<message name="IDS_WALLPAPER_MANAGER_COLOR_LABEL" desc="Custom wallpaper color label.">
Color:
</message>
<message name="IDS_WALLPAPER_MANAGER_PREVIEW_LABEL" desc="Custom wallpaper preview label.">
Preview:
</message>
<!-- File Browser --> <!-- File Browser -->
<message name="IDS_FILE_BROWSER_ROOT_DIRECTORY_LABEL" desc="Root directory label."> <message name="IDS_FILE_BROWSER_ROOT_DIRECTORY_LABEL" desc="Root directory label.">
Files Files
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "ash/wm/window_animations.h" #include "ash/wm/window_animations.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/browser/chromeos/extensions/wallpaper_manager_api.h" #include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h"
#include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
......
...@@ -2,13 +2,9 @@ ...@@ -2,13 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/extensions/wallpaper_manager_api.h" #include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/file_util.h"
#include "base/path_service.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
...@@ -16,14 +12,10 @@ ...@@ -16,14 +12,10 @@
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/extensions/application_launch.h" #include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread; const char kWallpaperManagerID[] = "obklkkbkpaoaejdabbfldmcfplpdgolj";
const char kWallpaperManagerDomain[] = "obklkkbkpaoaejdabbfldmcfplpdgolj";
namespace wallpaper_manager_util { namespace wallpaper_manager_util {
...@@ -38,7 +30,7 @@ void OpenWallpaperManager() { ...@@ -38,7 +30,7 @@ void OpenWallpaperManager() {
return; return;
const extensions::Extension* extension = const extensions::Extension* extension =
service->GetExtensionById(kWallpaperManagerDomain, false); service->GetExtensionById(kWallpaperManagerID, false);
if (!extension) if (!extension)
return; return;
...@@ -49,7 +41,7 @@ void OpenWallpaperManager() { ...@@ -49,7 +41,7 @@ void OpenWallpaperManager() {
application_launch::OpenApplication(params); application_launch::OpenApplication(params);
} else { } else {
Browser* browser = browser::FindOrCreateTabbedBrowser( Browser* browser = browser::FindOrCreateTabbedBrowser(
ProfileManager::GetDefaultProfileOrOffTheRecord()); ProfileManager::GetDefaultProfileOrOffTheRecord());
chrome::ShowSettingsSubPage(browser, "setWallpaper"); chrome::ShowSettingsSubPage(browser, "setWallpaper");
} }
} }
......
...@@ -2,21 +2,11 @@ ...@@ -2,21 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_MANAGER_API_H_ #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_MANAGER_UTIL_H_
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_MANAGER_API_H_ #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_MANAGER_UTIL_H_
#include "base/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/time.h"
#include "chrome/browser/extensions/extension_function.h"
#include "googleurl/src/gurl.h"
#include "net/url_request/url_fetcher_delegate.h"
extern const char kWallpaperManagerDomain[]; extern const char kWallpaperManagerDomain[];
// Wallpaper manager API functions. Followup CL will add implementations of
// some API functions.
namespace wallpaper_manager_util { namespace wallpaper_manager_util {
// Opens wallpaper manager application. // Opens wallpaper manager application.
...@@ -24,4 +14,4 @@ void OpenWallpaperManager(); ...@@ -24,4 +14,4 @@ void OpenWallpaperManager();
} // namespace wallpaper_manager_util } // namespace wallpaper_manager_util
#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_MANAGER_API_H_ #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_MANAGER_UTIL_H_
// 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 "chrome/browser/chromeos/extensions/wallpaper_private_api.h"
#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/shell.h"
#include "base/file_util.h"
#include "base/json/json_writer.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/synchronization/cancellation_flag.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/wallpaper_manager.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/image_decoder.h"
#include "chrome/common/chrome_paths.h"
#include "content/public/browser/browser_thread.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "net/url_request/url_request_status.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
using base::BinaryValue;
using content::BrowserThread;
bool WallpaperStringsFunction::RunImpl() {
DictionaryValue* dict = new DictionaryValue();
SetResult(dict);
#define SET_STRING(ns, id) \
dict->SetString(#id, l10n_util::GetStringUTF16(ns##_##id))
SET_STRING(IDS_WALLPAPER_MANAGER, SEARCH_TEXT_LABEL);
SET_STRING(IDS_WALLPAPER_MANAGER, AUTHOR_LABEL);
SET_STRING(IDS_WALLPAPER_MANAGER, CUSTOM_CATEGORY_LABEL);
SET_STRING(IDS_WALLPAPER_MANAGER, SELECT_CUSTOM_LABEL);
SET_STRING(IDS_WALLPAPER_MANAGER, POSITION_LABEL);
SET_STRING(IDS_WALLPAPER_MANAGER, COLOR_LABEL);
SET_STRING(IDS_WALLPAPER_MANAGER, PREVIEW_LABEL);
SET_STRING(IDS_OPTIONS, SET_WALLPAPER_DAILY);
#undef SET_STRING
ChromeURLDataManager::DataSource::SetFontAndTextDirection(dict);
return true;
}
class WallpaperSetWallpaperFunction::WallpaperDecoder
: public ImageDecoder::Delegate {
public:
explicit WallpaperDecoder(
scoped_refptr<WallpaperSetWallpaperFunction> function)
: function_(function) {
}
void Start(const std::string& image_data) {
image_decoder_ = new ImageDecoder(this, image_data);
image_decoder_->Start();
}
void Cancel() {
cancel_flag_.Set();
function_->SendResponse(false);
}
virtual void OnImageDecoded(const ImageDecoder* decoder,
const SkBitmap& decoded_image) OVERRIDE {
gfx::ImageSkia final_image(decoded_image);
if (cancel_flag_.IsSet()) {
delete this;
return;
}
function_->OnWallpaperDecoded(final_image);
delete this;
}
virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE {
if (cancel_flag_.IsSet()) {
delete this;
return;
}
function_->OnFail();
// TODO(bshe): Dispatches an encoding error event.
delete this;
}
private:
scoped_refptr<WallpaperSetWallpaperFunction> function_;
scoped_refptr<ImageDecoder> image_decoder_;
base::CancellationFlag cancel_flag_;
DISALLOW_COPY_AND_ASSIGN(WallpaperDecoder);
};
WallpaperSetWallpaperFunction::WallpaperDecoder*
WallpaperSetWallpaperFunction::wallpaper_decoder_;
WallpaperSetWallpaperFunction::WallpaperSetWallpaperFunction(){
}
WallpaperSetWallpaperFunction::~WallpaperSetWallpaperFunction(){
}
bool WallpaperSetWallpaperFunction::RunImpl() {
BinaryValue* input = NULL;
if (args_ == NULL || !args_->GetBinary(0, &input)) {
return false;
}
std::string layout_string;
if (!args_->GetString(1, &layout_string) || layout_string.empty()) {
return false;
}
layout_ = ash::GetLayoutEnum(layout_string);
std::string url;
if (!args_->GetString(2, &url) || url.empty()) {
return false;
}
file_name_ = GURL(url).ExtractFileName();
// Gets email address while at UI thread.
email_ = chromeos::UserManager::Get()->GetLoggedInUser().email();
image_data_.assign(input->GetBuffer(), input->GetSize());
if (wallpaper_decoder_)
wallpaper_decoder_->Cancel();
wallpaper_decoder_ = new WallpaperDecoder(this);
wallpaper_decoder_->Start(image_data_);
return true;
}
void WallpaperSetWallpaperFunction::OnWallpaperDecoded(
const gfx::ImageSkia& wallpaper) {
wallpaper_ = wallpaper;
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(&WallpaperSetWallpaperFunction::SaveToFile,
this));
}
void WallpaperSetWallpaperFunction::OnFail() {
wallpaper_decoder_ = NULL;
SendResponse(false);
}
void WallpaperSetWallpaperFunction::SaveToFile() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
FilePath wallpaper_dir;
CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPERS, &wallpaper_dir));
if (!file_util::DirectoryExists(wallpaper_dir) &&
!file_util::CreateDirectory(wallpaper_dir)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&WallpaperSetWallpaperFunction::OnFail,
this));
return;
}
FilePath file_path = wallpaper_dir.Append(file_name_);
if (file_util::PathExists(file_path) ||
file_util::WriteFile(file_path, image_data_.c_str(),
image_data_.size()) != -1 ) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&WallpaperSetWallpaperFunction::SetDecodedWallpaper,
this));
} else {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&WallpaperSetWallpaperFunction::OnFail,
this));
}
}
void WallpaperSetWallpaperFunction::SetDecodedWallpaper() {
ash::Shell::GetInstance()->desktop_background_controller()->
SetCustomWallpaper(wallpaper_, layout_);
wallpaper_decoder_ = NULL;
SendResponse(true);
}
// 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.
#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_PRIVATE_API_H_
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_PRIVATE_API_H_
#include "ash/desktop_background/desktop_background_resources.h"
#include "chrome/browser/extensions/extension_function.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "ui/gfx/image/image_skia.h"
// Wallpaper manager strings.
class WallpaperStringsFunction : public SyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME("wallpaperPrivate.getStrings");
protected:
virtual ~WallpaperStringsFunction() {}
// SyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
};
class WallpaperSetWallpaperFunction : public AsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME("wallpaperPrivate.setWallpaper");
WallpaperSetWallpaperFunction();
protected:
virtual ~WallpaperSetWallpaperFunction();
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
private:
class WallpaperDecoder;
void OnWallpaperDecoded(const gfx::ImageSkia& wallpaper);
void OnFail();
// Saves the image data to a file.
void SaveToFile();
// Sets wallpaper to the decoded image.
void SetDecodedWallpaper();
// Layout of the downloaded wallpaper.
ash::WallpaperLayout layout_;
// The decoded wallpaper.
gfx::ImageSkia wallpaper_;
// Email address of logged in user.
std::string email_;
// File name extracts from URL.
std::string file_name_;
// String representation of downloaded wallpaper.
std::string image_data_;
// Holds an instance of WallpaperDecoder.
static WallpaperDecoder* wallpaper_decoder_;
};
#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_PRIVATE_API_H_
...@@ -67,6 +67,15 @@ void WallpaperManager::SetLastSelectedUser( ...@@ -67,6 +67,15 @@ void WallpaperManager::SetLastSelectedUser(
last_selected_user_ = last_selected_user; last_selected_user_ = last_selected_user;
} }
void WallpaperManager::SetWallpaperFromFile(std::string email,
const std::string& path,
ash::WallpaperLayout layout) {
image_loader_->Start(
path, 0, false,
base::Bind(&WallpaperManager::OnCustomWallpaperLoaded,
base::Unretained(this), email, layout));
}
void WallpaperManager::UserDeselected() { void WallpaperManager::UserDeselected() {
if (!UserManager::Get()->IsUserLoggedIn()) { if (!UserManager::Get()->IsUserLoggedIn()) {
// This will set default login wallpaper (#fefefe). // This will set default login wallpaper (#fefefe).
...@@ -82,6 +91,14 @@ WallpaperManager::~WallpaperManager() { ...@@ -82,6 +91,14 @@ WallpaperManager::~WallpaperManager() {
system::TimezoneSettings::GetInstance()->RemoveObserver(this); system::TimezoneSettings::GetInstance()->RemoveObserver(this);
} }
void WallpaperManager::OnCustomWallpaperLoaded(const std::string& email,
ash::WallpaperLayout layout,
const UserImage& user_image) {
const SkBitmap& wallpaper = user_image.image();
ash::Shell::GetInstance()->desktop_background_controller()->
SetCustomWallpaper(wallpaper, layout);
}
void WallpaperManager::BatchUpdateWallpaper() { void WallpaperManager::BatchUpdateWallpaper() {
PrefService* local_state = g_browser_process->local_state(); PrefService* local_state = g_browser_process->local_state();
UserManager* user_manager = UserManager::Get(); UserManager* user_manager = UserManager::Get();
......
...@@ -7,7 +7,11 @@ ...@@ -7,7 +7,11 @@
#include <string> #include <string>
#include "ash/desktop_background/desktop_background_resources.h"
#include "base/memory/scoped_ptr.h"
#include "base/timer.h" #include "base/timer.h"
#include "chrome/browser/chromeos/login/user_image.h"
#include "chrome/browser/chromeos/login/user_image_loader.h"
#include "chrome/browser/chromeos/power/resume_observer.h" #include "chrome/browser/chromeos/power/resume_observer.h"
#include "chrome/browser/chromeos/system/timezone_settings.h" #include "chrome/browser/chromeos/system/timezone_settings.h"
#include "unicode/timezone.h" #include "unicode/timezone.h"
...@@ -34,17 +38,29 @@ class WallpaperManager: public system::TimezoneSettings::Observer, ...@@ -34,17 +38,29 @@ class WallpaperManager: public system::TimezoneSettings::Observer,
// Sets last selected user on user pod row. // Sets last selected user on user pod row.
void SetLastSelectedUser(const std::string& last_selected_user); void SetLastSelectedUser(const std::string& last_selected_user);
// Sets wallpaper to the image file |path| points to.
void SetWallpaperFromFile(std::string email,
const std::string& path,
ash::WallpaperLayout layout);
// User was deselected at login screen, reset wallpaper if needed. // User was deselected at login screen, reset wallpaper if needed.
void UserDeselected(); void UserDeselected();
private: private:
virtual ~WallpaperManager(); virtual ~WallpaperManager();
void OnCustomWallpaperLoaded(const std::string& email,
ash::WallpaperLayout layout,
const UserImage& user_image);
// Change the wallpapers for users who choose DAILY wallpaper type. Updates // Change the wallpapers for users who choose DAILY wallpaper type. Updates
// current wallpaper if it changed. This function should be called at exactly // current wallpaper if it changed. This function should be called at exactly
// at 0am if chromeos device is on. // at 0am if chromeos device is on.
void BatchUpdateWallpaper(); void BatchUpdateWallpaper();
// Loads user image from its file.
scoped_refptr<UserImageLoader> image_loader_;
// Overridden from chromeos::ResumeObserver // Overridden from chromeos::ResumeObserver
virtual void SystemResumed() OVERRIDE; virtual void SystemResumed() OVERRIDE;
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include "chrome/browser/chromeos/extensions/echo_private_api.h" #include "chrome/browser/chromeos/extensions/echo_private_api.h"
#include "chrome/browser/chromeos/extensions/file_browser_handler_api.h" #include "chrome/browser/chromeos/extensions/file_browser_handler_api.h"
#include "chrome/browser/chromeos/extensions/file_browser_private_api.h" #include "chrome/browser/chromeos/extensions/file_browser_private_api.h"
#include "chrome/browser/chromeos/extensions/wallpaper_private_api.h"
#include "chrome/browser/chromeos/media/media_player_extension_api.h" #include "chrome/browser/chromeos/media/media_player_extension_api.h"
#include "chrome/browser/extensions/api/input_ime/input_ime_api.h" #include "chrome/browser/extensions/api/input_ime/input_ime_api.h"
#include "chrome/browser/extensions/api/terminal/terminal_private_api.h" #include "chrome/browser/extensions/api/terminal/terminal_private_api.h"
...@@ -386,6 +387,10 @@ void ExtensionFunctionRegistry::ResetFunctions() { ...@@ -386,6 +387,10 @@ void ExtensionFunctionRegistry::ResetFunctions() {
RegisterFunction<SetWindowHeightMediaplayerFunction>(); RegisterFunction<SetWindowHeightMediaplayerFunction>();
RegisterFunction<CloseWindowMediaplayerFunction>(); RegisterFunction<CloseWindowMediaplayerFunction>();
// WallpaperManagerPrivate functions.
RegisterFunction<WallpaperStringsFunction>();
RegisterFunction<WallpaperSetWallpaperFunction>();
// InputMethod // InputMethod
RegisterFunction<GetInputMethodFunction>(); RegisterFunction<GetInputMethodFunction>();
......
...@@ -9,8 +9,17 @@ ...@@ -9,8 +9,17 @@
"wallpapers": "main.html" "wallpapers": "main.html"
}, },
"permissions": [ "permissions": [
"tabs" "wallpaperPrivate",
"tabs",
"webRequest",
"http://lh5.ggpht.com/",
"http://*.googleapis.com/"
], ],
"app": {
"launch": {
"local_path": "main.html"
}
},
"content_security_policy": "content_security_policy":
"default-src:none; object-src 'none'; script-src 'self'" "default-src:none; object-src 'none'; script-src 'self'"
} }
...@@ -83,7 +83,8 @@ ...@@ -83,7 +83,8 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/accessibility/accessibility_util.h" #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
#include "chrome/browser/chromeos/extensions/wallpaper_manager_api.h" #include "chrome/browser/chromeos/cros_settings.h"
#include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h"
#include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/options/take_photo_dialog.h" #include "chrome/browser/chromeos/options/take_photo_dialog.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
......
...@@ -4342,8 +4342,10 @@ ...@@ -4342,8 +4342,10 @@
'browser/chromeos/extensions/file_browser_handler_api.h', 'browser/chromeos/extensions/file_browser_handler_api.h',
'browser/chromeos/extensions/file_browser_private_api.cc', 'browser/chromeos/extensions/file_browser_private_api.cc',
'browser/chromeos/extensions/file_browser_private_api.h', 'browser/chromeos/extensions/file_browser_private_api.h',
'browser/chromeos/extensions/wallpaper_manager_api.cc', 'browser/chromeos/extensions/wallpaper_manager_util.cc',
'browser/chromeos/extensions/wallpaper_manager_api.h', 'browser/chromeos/extensions/wallpaper_manager_util.h',
'browser/chromeos/extensions/wallpaper_private_api.cc',
'browser/chromeos/extensions/wallpaper_private_api.h',
'browser/chromeos/media/media_player_extension_api.cc', 'browser/chromeos/media/media_player_extension_api.cc',
'browser/chromeos/media/media_player_extension_api.h', 'browser/chromeos/media/media_player_extension_api.h',
'browser/history/history_extension_api.cc', 'browser/history/history_extension_api.cc',
......
...@@ -325,6 +325,13 @@ bool PathProvider(int key, FilePath* result) { ...@@ -325,6 +325,13 @@ bool PathProvider(int key, FilePath* result) {
cur = cur.Append(FILE_PATH_LITERAL("resources")) cur = cur.Append(FILE_PATH_LITERAL("resources"))
.Append(FILE_PATH_LITERAL("extension")); .Append(FILE_PATH_LITERAL("extension"));
break; break;
#if defined(OS_CHROMEOS)
case chrome::DIR_CHROMEOS_WALLPAPERS:
if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("wallpapers"));
break;
#endif
// The following are only valid in the development environment, and // The following are only valid in the development environment, and
// will fail if executed from an installed executable (because the // will fail if executed from an installed executable (because the
// generated path won't exist). // generated path won't exist).
......
...@@ -102,6 +102,10 @@ enum { ...@@ -102,6 +102,10 @@ enum {
// binary data (e.g., html files and images // binary data (e.g., html files and images
// used by interal pages). // used by interal pages).
DIR_RESOURCES_EXTENSION, // Full path to extension resources. DIR_RESOURCES_EXTENSION, // Full path to extension resources.
#if defined(OS_CHROMEOS)
DIR_CHROMEOS_WALLPAPERS, // Directory where downloaded chromeos
// wallpapers reside.
#endif
// Valid only in development environment; TODO(darin): move these // Valid only in development environment; TODO(darin): move these
DIR_GEN_TEST_DATA, // Directory where generated test data resides. DIR_GEN_TEST_DATA, // Directory where generated test data resides.
......
...@@ -291,6 +291,11 @@ ...@@ -291,6 +291,11 @@
"channel": "stable", "channel": "stable",
"extension_types": ["platform_app"] "extension_types": ["platform_app"]
}, },
"wallpaperPrivate": {
"channel": "stable",
"extension_types": ["extension", "packaged_app"],
"location": "component"
},
"webNavigation": { "webNavigation": {
"channel": "stable", "channel": "stable",
"extension_types": ["extension", "packaged_app"] "extension_types": ["extension", "packaged_app"]
......
...@@ -455,6 +455,8 @@ void ExtensionAPI::InitDefaultConfiguration() { ...@@ -455,6 +455,8 @@ void ExtensionAPI::InitDefaultConfiguration() {
IDR_EXTENSION_API_JSON_TTS)); IDR_EXTENSION_API_JSON_TTS));
RegisterSchema("types", ReadFromResource( RegisterSchema("types", ReadFromResource(
IDR_EXTENSION_API_JSON_TYPES)); IDR_EXTENSION_API_JSON_TYPES));
RegisterSchema("wallpaperPrivate", ReadFromResource(
IDR_EXTENSION_API_JSON_WALLPAPERPRIVATE));
RegisterSchema("webNavigation", ReadFromResource( RegisterSchema("webNavigation", ReadFromResource(
IDR_EXTENSION_API_JSON_WEBNAVIGATION)); IDR_EXTENSION_API_JSON_WEBNAVIGATION));
RegisterSchema("webRequest", ReadFromResource( RegisterSchema("webRequest", ReadFromResource(
......
// 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.
[
{
"namespace":"wallpaperPrivate",
"nodoc": "true",
"functions": [
{
"name": "getStrings",
"type": "function",
"description": "Gets translated strings.",
"nodoc": "true",
"parameters": [
{
"type": "function",
"name": "callback",
"parameters": [
{
"name": "result",
"type": "object",
"additionalProperties": {"type": "string"}
}
]
}
]
},
{
"name": "setWallpaper",
"type": "function",
"description": "Sets wallpaper to the image from url with specified layout",
"nodoc": "true",
"parameters": [
{
"type": "binary",
"name": "wallpaper"
},
{
"type": "string",
"name": "layout",
"enum": [ "STRETCH", "CENTER", "CENTER_CROPPED"]
},
{
"type": "string",
"name": "url"
}
]
}
]
}
]
...@@ -85,6 +85,7 @@ var MODULE_SCHEMAS = [ ...@@ -85,6 +85,7 @@ var MODULE_SCHEMAS = [
'../../api/tts.json', '../../api/tts.json',
'../../api/tts_engine.json', '../../api/tts_engine.json',
'../../api/types.json', '../../api/types.json',
'../../api/wallpaper_private.json',
'../../api/web_navigation.json', '../../api/web_navigation.json',
'../../api/web_request.json', '../../api/web_request.json',
'../../api/web_socket_proxy_private.json', '../../api/web_socket_proxy_private.json',
......
...@@ -139,6 +139,7 @@ void APIPermission::RegisterAllPermissions( ...@@ -139,6 +139,7 @@ void APIPermission::RegisterAllPermissions(
{ kInputMethodPrivate, "inputMethodPrivate", kFlagCannotBeOptional }, { kInputMethodPrivate, "inputMethodPrivate", kFlagCannotBeOptional },
{ kEchoPrivate, "echoPrivate", kFlagCannotBeOptional }, { kEchoPrivate, "echoPrivate", kFlagCannotBeOptional },
{ kTerminalPrivate, "terminalPrivate", kFlagCannotBeOptional }, { kTerminalPrivate, "terminalPrivate", kFlagCannotBeOptional },
{ kWallpaperPrivate, "wallpaperPrivate", kFlagCannotBeOptional },
{ kWebRequestInternal, "webRequestInternal" }, { kWebRequestInternal, "webRequestInternal" },
{ kWebSocketProxyPrivate, "webSocketProxyPrivate", kFlagCannotBeOptional }, { kWebSocketProxyPrivate, "webSocketProxyPrivate", kFlagCannotBeOptional },
{ kWebstorePrivate, "webstorePrivate", kFlagCannotBeOptional }, { kWebstorePrivate, "webstorePrivate", kFlagCannotBeOptional },
......
...@@ -81,6 +81,7 @@ class APIPermission { ...@@ -81,6 +81,7 @@ class APIPermission {
kUnlimitedStorage, kUnlimitedStorage,
kUsb, kUsb,
kVideoCapture, kVideoCapture,
kWallpaperPrivate,
kWebNavigation, kWebNavigation,
kWebRequest, kWebRequest,
kWebRequestBlocking, kWebRequestBlocking,
......
...@@ -599,6 +599,7 @@ TEST(PermissionsTest, PermissionMessages) { ...@@ -599,6 +599,7 @@ TEST(PermissionsTest, PermissionMessages) {
skip.insert(APIPermission::kEchoPrivate); skip.insert(APIPermission::kEchoPrivate);
skip.insert(APIPermission::kSystemPrivate); skip.insert(APIPermission::kSystemPrivate);
skip.insert(APIPermission::kTerminalPrivate); skip.insert(APIPermission::kTerminalPrivate);
skip.insert(APIPermission::kWallpaperPrivate);
skip.insert(APIPermission::kWebRequestInternal); skip.insert(APIPermission::kWebRequestInternal);
skip.insert(APIPermission::kWebSocketProxyPrivate); skip.insert(APIPermission::kWebSocketProxyPrivate);
skip.insert(APIPermission::kWebstorePrivate); skip.insert(APIPermission::kWebstorePrivate);
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
<include name="IDR_EXTENSION_API_JSON_TTS" file="extensions\api\tts.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_TTS" file="extensions\api\tts.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_TTSENGINE" file="extensions\api\tts_engine.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_TTSENGINE" file="extensions\api\tts_engine.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_TYPES" file="extensions\api\types.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_TYPES" file="extensions\api\types.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_WALLPAPERPRIVATE" file="extensions\api\wallpaper_private.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_WEBNAVIGATION" file="extensions\api\web_navigation.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_WEBNAVIGATION" file="extensions\api\web_navigation.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_WEBREQUEST" file="extensions\api\web_request.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_WEBREQUEST" file="extensions\api\web_request.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_WEBSOCKETPROXYPRIVATE" file="extensions\api\web_socket_proxy_private.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_WEBSOCKETPROXYPRIVATE" file="extensions\api\web_socket_proxy_private.json" type="BINDATA" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment