| Index: chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
|
| diff --git a/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc b/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
|
| index 46c1fa85363fd97dbb46754c6ad5690bf52e582d..15f0191ce61aa63a1dcbac00f0148bb5e549acc2 100644
|
| --- a/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
|
| +++ b/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
|
| @@ -4,13 +4,17 @@
|
|
|
| #include "chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.h"
|
|
|
| +#include "base/command_line.h"
|
| #include "chrome/browser/extensions/shell_window_registry.h"
|
| #include "chrome/browser/ui/extensions/native_app_window.h"
|
| #include "chrome/browser/ui/extensions/shell_window.h"
|
| +#include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/extensions/api/app_current_window_internal.h"
|
| +#include "chrome/common/extensions/api/app_window.h"
|
|
|
| namespace SetBounds = extensions::api::app_current_window_internal::SetBounds;
|
| using extensions::api::app_current_window_internal::Bounds;
|
| +namespace SetIcon = extensions::api::app_current_window_internal::SetIcon;
|
|
|
| namespace extensions {
|
|
|
| @@ -20,6 +24,10 @@ const char kNoAssociatedShellWindow[] =
|
| "The context from which the function was called did not have an "
|
| "associated shell window.";
|
|
|
| +const char kNoExperimental[] =
|
| + "This function is experimental. Use --enable-experimental-extension-apis "
|
| + "to enable.";
|
| +
|
| } // namespace
|
|
|
| bool AppCurrentWindowInternalExtensionFunction::RunImpl() {
|
| @@ -105,4 +113,24 @@ bool AppCurrentWindowInternalSetBoundsFunction::RunWithWindow(
|
| return true;
|
| }
|
|
|
| +bool AppCurrentWindowInternalSetIconFunction::RunWithWindow(
|
| + ShellWindow* window) {
|
| + if (!CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableExperimentalExtensionApis)) {
|
| + error_ = kNoExperimental;
|
| + return false;
|
| + }
|
| +
|
| + scoped_ptr<SetIcon::Params> params(SetIcon::Params::Create(*args_));
|
| + CHECK(params.get());
|
| + // The |icon_url| parameter may be a blob url (e.g. an image fetched with an
|
| + // XMLHttpRequest) or a resource url.
|
| + GURL url(params->icon_url);
|
| + if (!url.is_valid())
|
| + url = GetExtension()->GetResourceURL(params->icon_url);
|
| +
|
| + window->SetAppIconUrl(url);
|
| + return true;
|
| +}
|
| +
|
| } // namespace extensions
|
|
|