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

Side by Side Diff: chrome/browser/extensions/extension_browser_actions_api.cc

Issue 377036: Fix memory leak in AsyncExtensionFunction. (Closed)
Patch Set: feedback Created 11 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extension_browser_actions_api.h" 5 #include "chrome/browser/extensions/extension_browser_actions_api.h"
6 6
7 #include "chrome/browser/browser.h" 7 #include "chrome/browser/browser.h"
8 #include "chrome/browser/browser_list.h" 8 #include "chrome/browser/browser_list.h"
9 #include "chrome/common/notification_service.h" 9 #include "chrome/common/notification_service.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
11 11
12 namespace { 12 namespace {
13 // Errors. 13 // Errors.
14 const char kNoBrowserActionError[] = 14 const char kNoBrowserActionError[] =
15 "This extension has no browser action specified."; 15 "This extension has no browser action specified.";
16 const char kIconIndexOutOfBounds[] = 16 const char kIconIndexOutOfBounds[] =
17 "Browser action icon index out of bounds."; 17 "Browser action icon index out of bounds.";
18 } 18 }
19 19
20 bool BrowserActionFunction::RunImpl() { 20 bool BrowserActionFunction::RunImpl() {
21 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); 21 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY));
22 details_ = static_cast<DictionaryValue*>(args_); 22 details_ = args_as_dictionary();
23 23
24 if (details_->HasKey(L"tabId")) 24 if (details_->HasKey(L"tabId"))
25 EXTENSION_FUNCTION_VALIDATE(details_->GetInteger(L"tabId", &tab_id_)); 25 EXTENSION_FUNCTION_VALIDATE(details_->GetInteger(L"tabId", &tab_id_));
26 26
27 Extension* extension = dispatcher()->GetExtension(); 27 Extension* extension = dispatcher()->GetExtension();
28 browser_action_ = extension->browser_action(); 28 browser_action_ = extension->browser_action();
29 if (!browser_action_) { 29 if (!browser_action_) {
30 error_ = kNoBrowserActionError; 30 error_ = kNoBrowserActionError;
31 return false; 31 return false;
32 } 32 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 for (size_t i = 0; i < arraysize(color_array); ++i) { 76 for (size_t i = 0; i < arraysize(color_array); ++i) {
77 EXTENSION_FUNCTION_VALIDATE(list->GetInteger(i, &color_array[i])); 77 EXTENSION_FUNCTION_VALIDATE(list->GetInteger(i, &color_array[i]));
78 } 78 }
79 79
80 SkColor color = SkColorSetARGB(color_array[3], color_array[0], color_array[1], 80 SkColor color = SkColorSetARGB(color_array[3], color_array[0], color_array[1],
81 color_array[2]); 81 color_array[2]);
82 browser_action_->SetBadgeBackgroundColor(tab_id_, color); 82 browser_action_->SetBadgeBackgroundColor(tab_id_, color);
83 83
84 return true; 84 return true;
85 } 85 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browser_actions_api.h ('k') | chrome/browser/extensions/extension_function.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698