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

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

Issue 11308012: Remove some TabContentses from extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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/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_piece.h" 11 #include "base/string_piece.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/browser/ui/tab_contents/tab_contents.h"
24 #include "chrome/common/chrome_notification_types.h" 23 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/extensions/extension.h" 24 #include "chrome/common/extensions/extension.h"
26 #include "chrome/common/extensions/extension_error_utils.h" 25 #include "chrome/common/extensions/extension_error_utils.h"
27 #include "chrome/common/render_messages.h" 26 #include "chrome/common/render_messages.h"
28 #include "content/public/browser/navigation_entry.h" 27 #include "content/public/browser/navigation_entry.h"
29 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
30 29
31 namespace { 30 namespace {
32 31
33 const char kBrowserActionStorageKey[] = "browser_action"; 32 const char kBrowserActionStorageKey[] = "browser_action";
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 335
337 case Value::TYPE_NULL: 336 case Value::TYPE_NULL:
338 // The tabId might be an optional argument. 337 // The tabId might be an optional argument.
339 break; 338 break;
340 339
341 default: 340 default:
342 EXTENSION_FUNCTION_VALIDATE(false); 341 EXTENSION_FUNCTION_VALIDATE(false);
343 } 342 }
344 } 343 }
345 344
346 // Find the TabContents that contains this tab id if one is required. 345 // Find the WebContents that contains this tab id if one is required.
347 if (tab_id_ == ExtensionAction::kDefaultTabId) { 346 if (tab_id_ == ExtensionAction::kDefaultTabId) {
348 EXTENSION_FUNCTION_VALIDATE( 347 EXTENSION_FUNCTION_VALIDATE(
349 extensions::ExtensionActionManager::Get(profile_)-> 348 extensions::ExtensionActionManager::Get(profile_)->
350 GetBrowserAction(*GetExtension())); 349 GetBrowserAction(*GetExtension()));
351 } else { 350 } else {
352 ExtensionTabUtil::GetTabById( 351 ExtensionTabUtil::GetTabById(
353 tab_id_, profile(), include_incognito(), NULL, NULL, &contents_, NULL); 352 tab_id_, profile(), include_incognito(), NULL, NULL, &contents_, NULL);
354 if (!contents_) { 353 if (!contents_) {
355 error_ = ExtensionErrorUtils::FormatErrorMessage( 354 error_ = ExtensionErrorUtils::FormatErrorMessage(
356 kNoTabError, base::IntToString(tab_id_)); 355 kNoTabError, base::IntToString(tab_id_));
(...skipping 24 matching lines...) Expand all
381 } 380 }
382 381
383 void ExtensionActionFunction::NotifyBrowserActionChange() { 382 void ExtensionActionFunction::NotifyBrowserActionChange() {
384 content::NotificationService::current()->Notify( 383 content::NotificationService::current()->Notify(
385 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, 384 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED,
386 content::Source<ExtensionAction>(extension_action_), 385 content::Source<ExtensionAction>(extension_action_),
387 content::Details<Profile>(profile())); 386 content::Details<Profile>(profile()));
388 } 387 }
389 388
390 void ExtensionActionFunction::NotifyLocationBarChange() { 389 void ExtensionActionFunction::NotifyLocationBarChange() {
391 extensions::TabHelper::FromWebContents(contents_->web_contents())-> 390 extensions::TabHelper::FromWebContents(contents_)->
392 location_bar_controller()->NotifyChange(); 391 location_bar_controller()->NotifyChange();
393 } 392 }
394 393
395 // static 394 // static
396 bool ExtensionActionFunction::ParseCSSColorString( 395 bool ExtensionActionFunction::ParseCSSColorString(
397 const std::string& color_string, 396 const std::string& color_string,
398 SkColor* result) { 397 SkColor* result) {
399 std::string formatted_color = "#"; 398 std::string formatted_color = "#";
400 // Check the string for incorrect formatting. 399 // Check the string for incorrect formatting.
401 if (color_string[0] != '#') 400 if (color_string[0] != '#')
(...skipping 29 matching lines...) Expand all
431 430
432 bool ExtensionActionFunction::SetVisible(bool visible) { 431 bool ExtensionActionFunction::SetVisible(bool visible) {
433 extension_action_->SetAppearance( 432 extension_action_->SetAppearance(
434 tab_id_, visible ? ExtensionAction::ACTIVE : ExtensionAction::INVISIBLE); 433 tab_id_, visible ? ExtensionAction::ACTIVE : ExtensionAction::INVISIBLE);
435 NotifyChange(); 434 NotifyChange();
436 return true; 435 return true;
437 } 436 }
438 437
439 extensions::TabHelper& ExtensionActionFunction::tab_helper() const { 438 extensions::TabHelper& ExtensionActionFunction::tab_helper() const {
440 CHECK(contents_); 439 CHECK(contents_);
441 return *extensions::TabHelper::FromWebContents(contents_->web_contents()); 440 return *extensions::TabHelper::FromWebContents(contents_);
442 } 441 }
443 442
444 bool ExtensionActionShowFunction::RunExtensionAction() { 443 bool ExtensionActionShowFunction::RunExtensionAction() {
445 return SetVisible(true); 444 return SetVisible(true);
446 } 445 }
447 446
448 bool ExtensionActionHideFunction::RunExtensionAction() { 447 bool ExtensionActionHideFunction::RunExtensionAction() {
449 return SetVisible(false); 448 return SetVisible(false);
450 } 449 }
451 450
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { 555 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() {
557 ListValue* list = new ListValue(); 556 ListValue* list = new ListValue();
558 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); 557 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_);
559 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); 558 list->Append(Value::CreateIntegerValue(SkColorGetR(color)));
560 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); 559 list->Append(Value::CreateIntegerValue(SkColorGetG(color)));
561 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); 560 list->Append(Value::CreateIntegerValue(SkColorGetB(color)));
562 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); 561 list->Append(Value::CreateIntegerValue(SkColorGetA(color)));
563 SetResult(list); 562 SetResult(list);
564 return true; 563 return true;
565 } 564 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698