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

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

Issue 10703090: Turn pageAction.show -> browserAction.sensibleThing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: views (incomplete) 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 kNoTabError, base::IntToString(tab_id_)); 107 kNoTabError, base::IntToString(tab_id_));
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:
118 NotifyBrowserActionChange();
119 return;
120 case ExtensionAction::TYPE_PAGE:
121 case ExtensionAction::TYPE_SCRIPT_BADGE: 117 case ExtensionAction::TYPE_SCRIPT_BADGE:
122 NotifyLocationBarChange(); 118 NotifyLocationBarChange();
123 return; 119 return;
120 case ExtensionAction::TYPE_BROWSER:
121 case ExtensionAction::TYPE_PAGE:
122 if (extension_->browser_action())
123 NotifyBrowserActionChange();
124 else if (extension_->page_action())
125 NotifyLocationBarChange();
126 else
127 NOTREACHED();
128 return;
124 } 129 }
125 NOTREACHED(); 130 NOTREACHED();
126 } 131 }
127 132
128 void ExtensionActionFunction::NotifyBrowserActionChange() { 133 void ExtensionActionFunction::NotifyBrowserActionChange() {
129 content::NotificationService::current()->Notify( 134 content::NotificationService::current()->Notify(
130 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, 135 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED,
131 content::Source<ExtensionAction>(extension_action_), 136 content::Source<ExtensionAction>(extension_action_),
132 content::NotificationService::NoDetails()); 137 content::NotificationService::NoDetails());
133 } 138 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return false; 172 return false;
168 if (color_ints[i] > 255 || color_ints[i] < 0) 173 if (color_ints[i] > 255 || color_ints[i] < 0)
169 return false; 174 return false;
170 } 175 }
171 176
172 *result = SkColorSetARGB(255, color_ints[0], color_ints[1], color_ints[2]); 177 *result = SkColorSetARGB(255, color_ints[0], color_ints[1], color_ints[2]);
173 return true; 178 return true;
174 } 179 }
175 180
176 bool ExtensionActionFunction::SetVisible(bool visible) { 181 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); 182 extension_action_->SetIsVisible(tab_id_, visible);
182 NotifyChange(); 183 NotifyChange();
183 return true; 184 return true;
184 } 185 }
185 186
186 bool ExtensionActionShowFunction::RunExtensionAction() { 187 bool ExtensionActionShowFunction::RunExtensionAction() {
187 return SetVisible(true); 188 return SetVisible(true);
188 } 189 }
189 190
190 bool ExtensionActionHideFunction::RunExtensionAction() { 191 bool ExtensionActionHideFunction::RunExtensionAction() {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { 301 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() {
301 ListValue* list = new ListValue(); 302 ListValue* list = new ListValue();
302 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); 303 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_);
303 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); 304 list->Append(Value::CreateIntegerValue(SkColorGetR(color)));
304 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); 305 list->Append(Value::CreateIntegerValue(SkColorGetG(color)));
305 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); 306 list->Append(Value::CreateIntegerValue(SkColorGetB(color)));
306 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); 307 list->Append(Value::CreateIntegerValue(SkColorGetA(color)));
307 result_.reset(list); 308 result_.reset(list);
308 return true; 309 return true;
309 } 310 }
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