diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-26 21:44:32 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-26 21:44:32 +0000 |
commit | 37ad8892fe9576eef898295e50e7d42b5d7a3e27 (patch) | |
tree | 2074f825af3d7430187dde4f7d5de75a91580d90 /chrome | |
parent | 68828be583862a07c72c3c223a6309b8fb708051 (diff) | |
download | chromium_src-37ad8892fe9576eef898295e50e7d42b5d7a3e27.zip chromium_src-37ad8892fe9576eef898295e50e7d42b5d7a3e27.tar.gz chromium_src-37ad8892fe9576eef898295e50e7d42b5d7a3e27.tar.bz2 |
Add two Extension view types: Notification and Infobars.
Also hooked them up to GetExtensionViews and consolidated
various methods of getting views into one (getViews, which
now takes an optional param type).
BUG=26463
TEST=None
Review URL: http://codereview.chromium.org/1397002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42828 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/notifications/balloon_host.h | 4 | ||||
-rwxr-xr-x | chrome/common/extensions/api/extension_api.json | 28 | ||||
-rw-r--r-- | chrome/common/extensions/docs/extension.html | 245 | ||||
-rw-r--r-- | chrome/common/view_types.cc | 1 | ||||
-rw-r--r-- | chrome/common/view_types.h | 2 | ||||
-rw-r--r-- | chrome/renderer/extensions/extension_process_bindings.cc | 8 |
6 files changed, 176 insertions, 112 deletions
diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h index b1f47a2..42cd0e0 100644 --- a/chrome/browser/notifications/balloon_host.h +++ b/chrome/browser/notifications/balloon_host.h @@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_ #define CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_ +#include <string> + #include "chrome/browser/extensions/extension_function_dispatcher.h" #include "chrome/browser/notifications/balloon.h" #include "chrome/browser/notifications/notification.h" @@ -58,7 +60,7 @@ class BalloonHost : public RenderViewHostDelegate, int32 page_id, const std::wstring& title) {} virtual int GetBrowserWindowID() const { return -1; } virtual ViewType::Type GetRenderViewType() const { - return ViewType::TAB_CONTENTS; + return ViewType::NOTIFICATION; } virtual RenderViewHostDelegate::View* GetViewDelegate() { return this; diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index 1adf289..5ab7351 100755 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -125,8 +125,27 @@ { "name": "getViews", "type": "function", - "description": "Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension. This includes background pages and tabs.", - "parameters": [], + "description": "Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension.", + "parameters": [ + { + "type": "object", + "name": "fetchProperties", + "optional": true, + "properties": { + "type": { + "type": "string", + "enum": ["tab", "infobar", "notification"], + "optional": true, + "description": "The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: 'tab', 'infobar', 'notification'." + }, + "windowId": { + "type": "integer", + "optional": true, + "description": "The window to restrict the search to. If omitted, returns all views." + } + } + } + ], "returns": { "type": "array", "description": "Array of global objects", @@ -146,7 +165,7 @@ "name": "getToolstrips", "nodoc": true, "type": "function", - "description": "Returns an array of the JavaScript 'window' objects for each of the toolstrip views running inside the current extension. If windowId is specified, returns only the 'window' objects of toolstrips attached to the specified window.", + "description": "Deprecated. Please use getViews({type: 'TOOLSTRIP'}). Returns an array of the JavaScript 'window' objects for each of the toolstrip views running inside the current extension. If windowId is specified, returns only the 'window' objects of toolstrips attached to the specified window.", "parameters": [ {"type": "integer", "name": "windowId", "optional": true} ], @@ -158,8 +177,9 @@ }, { "name": "getExtensionTabs", + "nodoc": true, "type": "function", - "description": "Returns an array of the JavaScript 'window' objects for each of the tabs running inside the current extension. If windowId is specified, returns only the 'window' objects of tabs attached to the specified window.", + "description": "Deprecated. Please use getViews({type: 'TAB'}). Returns an array of the JavaScript 'window' objects for each of the tabs running inside the current extension. If windowId is specified, returns only the 'window' objects of tabs attached to the specified window.", "parameters": [ {"type": "integer", "name": "windowId", "optional": true} ], diff --git a/chrome/common/extensions/docs/extension.html b/chrome/common/extensions/docs/extension.html index 8285e27..f4ba4dd 100644 --- a/chrome/common/extensions/docs/extension.html +++ b/chrome/common/extensions/docs/extension.html @@ -228,8 +228,8 @@ <a href="#method-connect">connect</a> </li><li> <a href="#method-getBackgroundPage">getBackgroundPage</a> - </li><li> - <a href="#method-getExtensionTabs">getExtensionTabs</a> + </li><li style="display: none; "> + <a href="#method-anchor">methodName</a> </li><li style="display: none; "> <a href="#method-anchor">methodName</a> </li><li> @@ -825,65 +825,27 @@ For details, see </div> <!-- /description --> - </div><div class="apiItem"> - <a name="method-getExtensionTabs"></a> <!-- method-anchor --> - <h4>getExtensionTabs</h4> + </div><div class="apiItem" style="display: none; "> + <a></a> <!-- method-anchor --> + <h4>method name</h4> - <div class="summary"><span>array of DOMWindow</span> + <div class="summary"><span>void</span> <!-- Note: intentionally longer 80 columns --> - <span>chrome.extension.getExtensionTabs</span>(<span class="optional"><span style="display: none; ">, </span><span>integer</span> - <var><span>windowId</span></var></span>)</div> + <span>chrome.module.methodName</span>(<span><span>, </span><span></span> + <var><span></span></var></span>)</div> <div class="description"> - <p class="todo" style="display: none; ">Undocumented.</p> - <p>Returns an array of the JavaScript 'window' objects for each of the tabs running inside the current extension. If windowId is specified, returns only the 'window' objects of tabs attached to the specified window.</p> + <p class="todo">Undocumented.</p> + <p> + A description from the json schema def of the function goes here. + </p> <!-- PARAMETERS --> <h4>Parameters</h4> <dl> <div> <div> - <dt> - <var>windowId</var> - <em> - - <!-- TYPE --> - <div style="display:inline"> - ( - <span class="optional">optional</span> - <span id="typeTemplate"> - <span style="display: none; "> - <a> Type</a> - </span> - <span> - <span style="display: none; "> - array of <span><span></span></span> - </span> - <span>integer</span> - </span> - </span> - ) - </div> - - </em> - </dt> - <dd class="todo"> - Undocumented. - </dd> - <dd style="display: none; "> - Description of this parameter from the json schema. - </dd> - - <!-- OBJECT PROPERTIES --> - <dd style="display: none; "> - <dl> - <div> - <div> - </div> - </div> - </dl> - </dd> - </div> + </div> </div> </dl> @@ -892,60 +854,12 @@ For details, see <dl> <div> <div> - <dt> - <var style="display: none; ">paramName</var> - <em> - - <!-- TYPE --> - <div style="display:inline"> - ( - <span class="optional" style="display: none; ">optional</span> - <span id="typeTemplate"> - <span style="display: none; "> - <a> Type</a> - </span> - <span> - <span> - array of <span><span> - <span style="display: none; "> - <a> Type</a> - </span> - <span> - <span style="display: none; "> - array of <span><span></span></span> - </span> - <span>DOMWindow</span> - </span> - </span></span> - </span> - <span style="display: none; ">paramType</span> - </span> - </span> - ) - </div> - - </em> - </dt> - <dd class="todo" style="display: none; "> - Undocumented. - </dd> - <dd>Array of global window objects</dd> - - <!-- OBJECT PROPERTIES --> - <dd style="display: none; "> - <dl> - <div> - <div> - </div> - </div> - </dl> - </dd> - </div> + </div> </div> </dl> <!-- CALLBACK --> - <div style="display: none; "> + <div> <div> <h4>Callback function</h4> <p> @@ -1168,19 +1082,138 @@ For details, see <div class="summary"><span>array of DOMWindow</span> <!-- Note: intentionally longer 80 columns --> - <span>chrome.extension.getViews</span>(<span style="display: none; "><span>, </span><span></span> - <var><span></span></var></span>)</div> + <span>chrome.extension.getViews</span>(<span class="optional"><span style="display: none; ">, </span><span>object</span> + <var><span>fetchProperties</span></var></span>)</div> <div class="description"> <p class="todo" style="display: none; ">Undocumented.</p> - <p>Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension. This includes background pages and tabs.</p> + <p>Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension.</p> <!-- PARAMETERS --> <h4>Parameters</h4> <dl> - <div style="display: none; "> + <div> <div> - </div> + <dt> + <var>fetchProperties</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional">optional</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>object</span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo"> + Undocumented. + </dd> + <dd style="display: none; "> + Description of this parameter from the json schema. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd> + <dl> + <div> + <div> + <dt> + <var>type</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional">optional</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>string</span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: 'tab', 'infobar', 'notification'.</dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + </div> + </div><div> + <div> + <dt> + <var>windowId</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional">optional</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>integer</span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>The window to restrict the search to. If omitted, returns all views.</dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + </div> + </div> + </dl> + </dd> + </div> </div> </dl> diff --git a/chrome/common/view_types.cc b/chrome/common/view_types.cc index 5dff5b0..6759577 100644 --- a/chrome/common/view_types.cc +++ b/chrome/common/view_types.cc @@ -10,6 +10,7 @@ const char* ViewType::kMole = "MOLE"; const char* ViewType::kBackgroundPage = "BACKGROUND"; const char* ViewType::kPopup = "POPUP"; const char* ViewType::kInfobar = "INFOBAR"; +const char* ViewType::kNotification = "NOTIFICATION"; const char* ViewType::kAll = "ALL"; bool ViewType::ShouldAutoResize(ViewType::Type view_type) { diff --git a/chrome/common/view_types.h b/chrome/common/view_types.h index 6db4161..d3f1782 100644 --- a/chrome/common/view_types.h +++ b/chrome/common/view_types.h @@ -20,6 +20,7 @@ class ViewType { EXTENSION_INFOBAR, DEV_TOOLS_UI, INTERSTITIAL_PAGE, + NOTIFICATION, }; // Constant strings corresponding to the Type enumeration values. Used @@ -30,6 +31,7 @@ class ViewType { static const char* kBackgroundPage; static const char* kPopup; static const char* kInfobar; + static const char* kNotification; static const char* kAll; // Return true if a view type should automatically resize to fit its contents. diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc index 78285b1..71b77a5 100644 --- a/chrome/renderer/extensions/extension_process_bindings.cc +++ b/chrome/renderer/extensions/extension_process_bindings.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -12,6 +12,7 @@ #include "base/command_line.h" #include "base/json/json_reader.h" #include "base/singleton.h" +#include "base/string_util.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/url_pattern.h" @@ -319,6 +320,7 @@ class ExtensionImpl : public ExtensionBase { int browser_window_id = args[0]->Int32Value(); std::string view_type_string = *v8::String::Utf8Value(args[1]->ToString()); + StringToUpperASCII(&view_type_string); // |view_type| == ViewType::INVALID means getting any type of views. ViewType::Type view_type = ViewType::INVALID; if (view_type_string == ViewType::kToolstrip) { @@ -327,6 +329,10 @@ class ExtensionImpl : public ExtensionBase { view_type = ViewType::EXTENSION_MOLE; } else if (view_type_string == ViewType::kBackgroundPage) { view_type = ViewType::EXTENSION_BACKGROUND_PAGE; + } else if (view_type_string == ViewType::kInfobar) { + view_type = ViewType::EXTENSION_INFOBAR; + } else if (view_type_string == ViewType::kNotification) { + view_type = ViewType::NOTIFICATION; } else if (view_type_string == ViewType::kTabContents) { view_type = ViewType::TAB_CONTENTS; } else if (view_type_string == ViewType::kPopup) { |