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

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

Issue 11588004: Move ScriptBadge, ActionInfo out of Extension; preparation for BrowserAction (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for CQ Created 7 years, 11 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/extension_action/extension_script_badge_api.h » ('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/base64.h" 9 #include "base/base64.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_ api_constants.h" 13 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_ api_constants.h"
14 #include "chrome/browser/extensions/extension_action.h" 14 #include "chrome/browser/extensions/extension_action.h"
15 #include "chrome/browser/extensions/extension_action_manager.h" 15 #include "chrome/browser/extensions/extension_action_manager.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/extension_system.h" 17 #include "chrome/browser/extensions/extension_system.h"
18 #include "chrome/browser/extensions/extension_tab_util.h" 18 #include "chrome/browser/extensions/extension_tab_util.h"
19 #include "chrome/browser/extensions/location_bar_controller.h" 19 #include "chrome/browser/extensions/location_bar_controller.h"
20 #include "chrome/browser/extensions/state_store.h" 20 #include "chrome/browser/extensions/state_store.h"
21 #include "chrome/browser/extensions/tab_helper.h" 21 #include "chrome/browser/extensions/tab_helper.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/common/chrome_notification_types.h" 23 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/extensions/extension.h" 24 #include "chrome/common/extensions/api/extension_action/action_info.h"
25 #include "chrome/common/render_messages.h" 25 #include "chrome/common/render_messages.h"
26 #include "content/public/browser/navigation_entry.h" 26 #include "content/public/browser/navigation_entry.h"
27 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
28 #include "extensions/common/error_utils.h" 28 #include "extensions/common/error_utils.h"
29 29
30 namespace { 30 namespace {
31 31
32 const char kBrowserActionStorageKey[] = "browser_action"; 32 const char kBrowserActionStorageKey[] = "browser_action";
33 const char kPopupUrlStorageKey[] = "poupup_url"; 33 const char kPopupUrlStorageKey[] = "poupup_url";
34 const char kTitleStorageKey[] = "title"; 34 const char kTitleStorageKey[] = "title";
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 if (tab_id_ != ExtensionAction::kDefaultTabId) { 313 if (tab_id_ != ExtensionAction::kDefaultTabId) {
314 ExtensionTabUtil::GetTabById( 314 ExtensionTabUtil::GetTabById(
315 tab_id_, profile(), include_incognito(), NULL, NULL, &contents_, NULL); 315 tab_id_, profile(), include_incognito(), NULL, NULL, &contents_, NULL);
316 if (!contents_) { 316 if (!contents_) {
317 error_ = extensions::ErrorUtils::FormatErrorMessage( 317 error_ = extensions::ErrorUtils::FormatErrorMessage(
318 kNoTabError, base::IntToString(tab_id_)); 318 kNoTabError, base::IntToString(tab_id_));
319 return false; 319 return false;
320 } 320 }
321 } else { 321 } else {
322 // Only browser actions and system indicators have a default tabId. 322 // Only browser actions and system indicators have a default tabId.
323 typedef extensions::Extension::ActionInfo ActionInfo; 323 extensions::ActionInfo::Type action_type = extension_action_->action_type();
324 ActionInfo::Type action_type = extension_action_->action_type();
325 EXTENSION_FUNCTION_VALIDATE( 324 EXTENSION_FUNCTION_VALIDATE(
326 action_type == ActionInfo::TYPE_BROWSER || 325 action_type == extensions::ActionInfo::TYPE_BROWSER ||
327 action_type == ActionInfo::TYPE_SYSTEM_INDICATOR); 326 action_type == extensions::ActionInfo::TYPE_SYSTEM_INDICATOR);
328 } 327 }
329 return RunExtensionAction(); 328 return RunExtensionAction();
330 } 329 }
331 330
332 bool ExtensionActionFunction::ExtractDataFromArguments() { 331 bool ExtensionActionFunction::ExtractDataFromArguments() {
333 // There may or may not be details (depends on the function). 332 // There may or may not be details (depends on the function).
334 // The tabId might appear in details (if it exists), as the first 333 // The tabId might appear in details (if it exists), as the first
335 // argument besides the action type (depends on the function), or be omitted 334 // argument besides the action type (depends on the function), or be omitted
336 // entirely. 335 // entirely.
337 base::Value* first_arg = NULL; 336 base::Value* first_arg = NULL;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 370
372 default: 371 default:
373 return false; 372 return false;
374 } 373 }
375 374
376 return true; 375 return true;
377 } 376 }
378 377
379 void ExtensionActionFunction::NotifyChange() { 378 void ExtensionActionFunction::NotifyChange() {
380 switch (extension_action_->action_type()) { 379 switch (extension_action_->action_type()) {
381 case extensions::Extension::ActionInfo::TYPE_BROWSER: 380 case extensions::ActionInfo::TYPE_BROWSER:
382 case extensions::Extension::ActionInfo::TYPE_PAGE: 381 case extensions::ActionInfo::TYPE_PAGE:
383 if (extensions::ExtensionActionManager::Get(profile_)-> 382 if (extensions::ExtensionActionManager::Get(profile_)->
384 GetBrowserAction(*extension_)) { 383 GetBrowserAction(*extension_)) {
385 NotifyBrowserActionChange(); 384 NotifyBrowserActionChange();
386 } else if (extensions::ExtensionActionManager::Get(profile_)-> 385 } else if (extensions::ExtensionActionManager::Get(profile_)->
387 GetPageAction(*extension_)) { 386 GetPageAction(*extension_)) {
388 NotifyLocationBarChange(); 387 NotifyLocationBarChange();
389 } 388 }
390 return; 389 return;
391 case extensions::Extension::ActionInfo::TYPE_SCRIPT_BADGE: 390 case extensions::ActionInfo::TYPE_SCRIPT_BADGE:
392 NotifyLocationBarChange(); 391 NotifyLocationBarChange();
393 return; 392 return;
394 case extensions::Extension::ActionInfo::TYPE_SYSTEM_INDICATOR: 393 case extensions::ActionInfo::TYPE_SYSTEM_INDICATOR:
395 NotifySystemIndicatorChange(); 394 NotifySystemIndicatorChange();
396 return; 395 return;
397 } 396 }
398 NOTREACHED(); 397 NOTREACHED();
399 } 398 }
400 399
401 void ExtensionActionFunction::NotifyBrowserActionChange() { 400 void ExtensionActionFunction::NotifyBrowserActionChange() {
402 content::NotificationService::current()->Notify( 401 content::NotificationService::current()->Notify(
403 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, 402 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED,
404 content::Source<ExtensionAction>(extension_action_), 403 content::Source<ExtensionAction>(extension_action_),
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { 582 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() {
584 ListValue* list = new ListValue(); 583 ListValue* list = new ListValue();
585 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); 584 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_);
586 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); 585 list->Append(Value::CreateIntegerValue(SkColorGetR(color)));
587 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); 586 list->Append(Value::CreateIntegerValue(SkColorGetG(color)));
588 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); 587 list->Append(Value::CreateIntegerValue(SkColorGetB(color)));
589 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); 588 list->Append(Value::CreateIntegerValue(SkColorGetA(color)));
590 SetResult(list); 589 SetResult(list);
591 return true; 590 return true;
592 } 591 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/extension_action/extension_script_badge_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698