Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: chrome/browser/extensions/api/extension_action/extension_actions_api.cc

Issue 10382216: Remove browser-actions-for-all flag and replace funcionality with action-box. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: whitespace Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/extensions/api/extension_action/extension_actions_api.h " 5 #include "chrome/browser/extensions/api/extension_action/extension_actions_api.h "
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return false; 151 return false;
152 if (color_ints[i] > 255 || color_ints[i] < 0) 152 if (color_ints[i] > 255 || color_ints[i] < 0)
153 return false; 153 return false;
154 } 154 }
155 155
156 *result = SkColorSetARGB(255, color_ints[0], color_ints[1], color_ints[2]); 156 *result = SkColorSetARGB(255, color_ints[0], color_ints[1], color_ints[2]);
157 return true; 157 return true;
158 } 158 }
159 159
160 bool ExtensionActionFunction::SetVisible(bool visible) { 160 bool ExtensionActionFunction::SetVisible(bool visible) {
161 // If --browser-actions-for-all is enabled there will be a browser_action 161 // If --enable-action-box is on there will be a browser_action here instead
162 // here instead of a page action. Until we decide what to do with that, just 162 // of a page action. Until we decide what to do with that, just ignore.
163 // ignore.
164 if (!GetExtension()->page_action()) 163 if (!GetExtension()->page_action())
165 return true; 164 return true;
166 extension_action_->SetIsVisible(tab_id_, visible); 165 extension_action_->SetIsVisible(tab_id_, visible);
167 NotifyChange(); 166 NotifyChange();
168 return true; 167 return true;
169 } 168 }
170 169
171 bool ExtensionActionShowFunction::RunExtensionAction() { 170 bool ExtensionActionShowFunction::RunExtensionAction() {
172 return SetVisible(true); 171 return SetVisible(true);
173 } 172 }
174 173
175 bool ExtensionActionHideFunction::RunExtensionAction() { 174 bool ExtensionActionHideFunction::RunExtensionAction() {
176 return SetVisible(false); 175 return SetVisible(false);
177 } 176 }
178 177
179 bool ExtensionActionSetIconFunction::RunExtensionAction() { 178 bool ExtensionActionSetIconFunction::RunExtensionAction() {
180 // setIcon can take a variant argument: either a canvas ImageData, or an 179 // setIcon can take a variant argument: either a canvas ImageData, or an
181 // icon index. 180 // icon index.
182 base::BinaryValue* binary = NULL; 181 base::BinaryValue* binary = NULL;
183 int icon_index; 182 int icon_index;
184 if (details_->GetBinary("imageData", &binary)) { 183 if (details_->GetBinary("imageData", &binary)) {
185 IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize()); 184 IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize());
186 PickleIterator iter(bitmap_pickle); 185 PickleIterator iter(bitmap_pickle);
187 SkBitmap bitmap; 186 SkBitmap bitmap;
188 EXTENSION_FUNCTION_VALIDATE( 187 EXTENSION_FUNCTION_VALIDATE(
189 IPC::ReadParam(&bitmap_pickle, &iter, &bitmap)); 188 IPC::ReadParam(&bitmap_pickle, &iter, &bitmap));
190 extension_action_->SetIcon(tab_id_, bitmap); 189 extension_action_->SetIcon(tab_id_, bitmap);
191 } else if (details_->GetInteger("iconIndex", &icon_index)) { 190 } else if (details_->GetInteger("iconIndex", &icon_index)) {
192 // If --browser-actions-for-all is enabled there might legitimately be an 191 // If --enable-action-box is on there might legitimately be an iconIndex
193 // iconIndex set. Until we decide what to do with that, ignore. 192 // set. Until we decide what to do with that, ignore.
194 if (!GetExtension()->page_action()) 193 if (!GetExtension()->page_action())
195 return true; 194 return true;
196 if (icon_index < 0 || 195 if (icon_index < 0 ||
197 static_cast<size_t>(icon_index) >= 196 static_cast<size_t>(icon_index) >=
198 extension_action_->icon_paths()->size()) { 197 extension_action_->icon_paths()->size()) {
199 error_ = kIconIndexOutOfBounds; 198 error_ = kIconIndexOutOfBounds;
200 return false; 199 return false;
201 } 200 }
202 extension_action_->SetIcon(tab_id_, SkBitmap()); 201 extension_action_->SetIcon(tab_id_, SkBitmap());
203 extension_action_->SetIconIndex(tab_id_, icon_index); 202 extension_action_->SetIconIndex(tab_id_, icon_index);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { 284 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() {
286 ListValue* list = new ListValue(); 285 ListValue* list = new ListValue();
287 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); 286 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_);
288 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); 287 list->Append(Value::CreateIntegerValue(SkColorGetR(color)));
289 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); 288 list->Append(Value::CreateIntegerValue(SkColorGetG(color)));
290 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); 289 list->Append(Value::CreateIntegerValue(SkColorGetB(color)));
291 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); 290 list->Append(Value::CreateIntegerValue(SkColorGetA(color)));
292 result_.reset(list); 291 result_.reset(list);
293 return true; 292 return true;
294 } 293 }
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/extensions/api/extension_action/page_as_browser_action_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698