1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
<div id="pageData-title" class="pageData">Tutorial: Getting Started (Hello, World!)</div>
<div id="pageData-showTOC" class="pageData">true</div>
<p>
This tutorial walks you through creating a simple extension.
You'll add a button to Google Chrome
that, when clicked, displays an automatically generated page.
The button and page will look something like this:
</p>
<img src="images/hello-world-small.png"
width="300" height="199"
alt="a window with a grid of images related to HELLO WORLD" />
<h2 id="browser">Get your browser ready</h2>
<p>To develop extensions for Google Chrome,
you need to <a href="http://dev.chromium.org/getting-involved/dev-channel">subscribe
to the Dev or Beta channel</a> of Google Chrome for Windows. Extensions aren't yet available in the stable channel.
</p>
<p>
<b>Note:</b> This tutorial requires Windows.
You can try it on Linux and OS X, and it might work,
but the extensions support is less stable on those platforms.
We're working hard to bring them up to speed.
</p>
<h2 id="load">Create and load an extension</h2>
<p>
In this section, you'll write an extension
that adds a <em>browser action</em>
to the toolbar of Google Chrome.
</p>
<ol>
<li>
Create a folder somewhere on your computer to contain your extension's code.
We'll assume the folder is located at
<strong><code>c:\myext</code></strong>,
but it can be anywhere.
</li>
<li>
Inside your extension's folder,
create a text file called <strong><code>manifest.json</code></strong>,
and put this in it:
<pre>{
"name": "My First Extension",
"version": "1.0",
"description": "The first extension that I made.",
"browser_action": {
""default_icon": "icon.png""
},
"permissions": [
"http://api.flickr.com/"
]
}</pre>
</li>
<li>
Copy this icon to the same folder:<br>
<table cellpadding="0" cellspacing="0">
<tr>
<td style="text-align:center; border:0;"><a
href="samples/hello_world/icon.png"
><img src="samples/hello_world/icon.png"
width="19" height="19" border="0"></a><br>
<a href="samples/hello_world/icon.png"
>Download icon.png</a></td>
</tr>
</table>
</li>
<li> Load the extension.
<ol type="a">
<li>
Bring up the Extensions management page by clicking the wrench icon, and selecting the "Extensions" menu item.
</li>
<li>
Click the <b>Load extension...</b> button.
A file dialog appears.
</li>
<li>
In the file dialog,
navigate to your extension's folder
(<code>c:\myext</code>, for example)
and click the <b>OK</b> button.
</li>
</ol> </li>
</ol>
<p>
If your extension is valid,
information about it
appears in the <b>Installed extensions</b> part
of the Extensions page,
as the following screenshot shows.
</p>
<p>
<a href="images/load_after.png"><img
src="images/load_after_small.png"
width="327" height="206" /></a>
</p>
<h2 id="code">Add code to the extension</h2>
<p> In this step, you'll make your extension <em>do</em> something besides just look good. </p>
<ol>
<li>
<p> Edit <code>manifest.json</code> to add the following line:</p>
<pre>
...
"browser_action": {
"default_icon": "icon.png",
<b style="background:yellow">"popup": "popup.html"</b>
},
...
</pre>
<p> Inside your extension's folder,
create a text file called <strong><code>popup.html</code></strong>,
and add the following code to it:</p>
<blockquote> <a href="samples/hello_world/popup.html" onclick="window.open('view-source:' + this.href); return false;">CSS
and JavaScript code for hello_world</a></blockquote>
</li>
<li>
Return to <b>chrome://extensions</b>,
and click the <b>Reload</b> button
to load the new version of the extension.</li>
<li>Click the button.
A popup bubble should come up that displays <code>popup.html</code>. </li>
</ol>
<p> It should look something like this:</p>
<img src="images/hello-world.png"
width="583" height="387"
alt="a popup with a grid of images related to HELLO WORLD" />
<p> If you don't see the popup,
try the instructions again,
following them exactly.
Don't try loading an HTML file that isn't in the extension's folder —
it won't work! </p>
<h2 id="summary">Now what?</h2>
<p class="comment">
[PENDING: Summarize what we did,
what it means,
what else we would've done if this were a real extension (e.g. package it),
and where to find more information.]</p>
<p>
Here are some suggestions for what to do next:
</p>
<ul>
<li>
Read the <a href="overview.html">Overview</a>
</li>
<li>
Learn how to debug extensions by following the
<a href="tut_debugging.html">debugging tutorial</a>
</li>
<li>
Keep up to date with the latest news by subscribing to
<a href="http://groups.google.com/group/chromium-extensions/subscribe">chromium-extensions</a>
</li>
<li>
Learn more about
<a href="browserAction.html">browser actions</a>
</li>
<li>
Look at some
<a href="http://sites.google.com/a/chromium.org/dev/developers/design-documents/extensions/samples">sample extensions</a>
</li>
</ul>
|