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

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

Issue 10700007: Page actions behave as disableable browser actions when script badges are enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: estade + sky Created 8 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_toolbar_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 return false; 108 return false;
109 } 109 }
110 } 110 }
111 111
112 return RunExtensionAction(); 112 return RunExtensionAction();
113 } 113 }
114 114
115 void ExtensionActionFunction::NotifyChange() { 115 void ExtensionActionFunction::NotifyChange() {
116 switch (extension_action_->action_type()) { 116 switch (extension_action_->action_type()) {
117 case ExtensionAction::TYPE_BROWSER: 117 case ExtensionAction::TYPE_BROWSER:
118 NotifyBrowserActionChange(); 118 case ExtensionAction::TYPE_PAGE:
119 if (extension_->browser_action()) {
120 NotifyBrowserActionChange();
121 } else if (extension_->page_action()) {
122 NotifyLocationBarChange();
123 }
119 return; 124 return;
120 case ExtensionAction::TYPE_PAGE:
121 case ExtensionAction::TYPE_SCRIPT_BADGE: 125 case ExtensionAction::TYPE_SCRIPT_BADGE:
122 NotifyLocationBarChange(); 126 NotifyLocationBarChange();
123 return; 127 return;
124 } 128 }
125 NOTREACHED(); 129 NOTREACHED();
126 } 130 }
127 131
128 void ExtensionActionFunction::NotifyBrowserActionChange() { 132 void ExtensionActionFunction::NotifyBrowserActionChange() {
129 content::NotificationService::current()->Notify( 133 content::NotificationService::current()->Notify(
130 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, 134 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return false; 171 return false;
168 if (color_ints[i] > 255 || color_ints[i] < 0) 172 if (color_ints[i] > 255 || color_ints[i] < 0)
169 return false; 173 return false;
170 } 174 }
171 175
172 *result = SkColorSetARGB(255, color_ints[0], color_ints[1], color_ints[2]); 176 *result = SkColorSetARGB(255, color_ints[0], color_ints[1], color_ints[2]);
173 return true; 177 return true;
174 } 178 }
175 179
176 bool ExtensionActionFunction::SetVisible(bool visible) { 180 bool ExtensionActionFunction::SetVisible(bool visible) {
177 // If --enable-script-badges is on there will be a browser_action here
178 // instead of a page action. Disable/renable the browser action perhaps?
179 if (!GetExtension()->page_action())
180 return true;
181 extension_action_->SetIsVisible(tab_id_, visible); 181 extension_action_->SetIsVisible(tab_id_, visible);
182 NotifyChange(); 182 NotifyChange();
183 return true; 183 return true;
184 } 184 }
185 185
186 bool ExtensionActionShowFunction::RunExtensionAction() { 186 bool ExtensionActionShowFunction::RunExtensionAction() {
187 return SetVisible(true); 187 return SetVisible(true);
188 } 188 }
189 189
190 bool ExtensionActionHideFunction::RunExtensionAction() { 190 bool ExtensionActionHideFunction::RunExtensionAction() {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { 300 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() {
301 ListValue* list = new ListValue(); 301 ListValue* list = new ListValue();
302 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); 302 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_);
303 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); 303 list->Append(Value::CreateIntegerValue(SkColorGetR(color)));
304 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); 304 list->Append(Value::CreateIntegerValue(SkColorGetG(color)));
305 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); 305 list->Append(Value::CreateIntegerValue(SkColorGetB(color)));
306 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); 306 list->Append(Value::CreateIntegerValue(SkColorGetA(color)));
307 result_.reset(list); 307 result_.reset(list);
308 return true; 308 return true;
309 } 309 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_toolbar_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698