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

Side by Side Diff: chrome/browser/extensions/extension_toolstrip_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
« no previous file with comments | « chrome/browser/extensions/extension_tabs_module.cc ('k') | no next file » | 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) 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_toolstrip_api.h" 5 #include "chrome/browser/extensions/extension_toolstrip_api.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/browser.h" 9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/extensions/extension_host.h" 10 #include "chrome/browser/extensions/extension_host.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 bool ToolstripExpandFunction::RunImpl() { 61 bool ToolstripExpandFunction::RunImpl() {
62 if (!ToolstripFunction::RunImpl()) 62 if (!ToolstripFunction::RunImpl())
63 return false; 63 return false;
64 if (toolstrip_->height != 0) { 64 if (toolstrip_->height != 0) {
65 error_ = kAlreadyExpandedError; 65 error_ = kAlreadyExpandedError;
66 return false; 66 return false;
67 } 67 }
68 68
69 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); 69 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY));
70 const DictionaryValue* args = static_cast<const DictionaryValue*>(args_); 70 const DictionaryValue* args = args_as_dictionary();
71 71
72 int height; 72 int height;
73 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kHeightKey, 73 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kHeightKey,
74 &height)); 74 &height));
75 EXTENSION_FUNCTION_VALIDATE(height >= 0); 75 EXTENSION_FUNCTION_VALIDATE(height >= 0);
76 if (height < kMinHeight || height > kMaxHeight) { 76 if (height < kMinHeight || height > kMaxHeight) {
77 error_ = kBadHeightError; 77 error_ = kBadHeightError;
78 return false; 78 return false;
79 } 79 }
80 80
(...skipping 18 matching lines...) Expand all
99 return false; 99 return false;
100 100
101 if (toolstrip_->height == 0) { 101 if (toolstrip_->height == 0) {
102 error_ = kAlreadyCollapsedError; 102 error_ = kAlreadyCollapsedError;
103 return false; 103 return false;
104 } 104 }
105 105
106 GURL url; 106 GURL url;
107 if (args_->GetType() != Value::TYPE_NULL) { 107 if (args_->GetType() != Value::TYPE_NULL) {
108 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); 108 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY));
109 const DictionaryValue* args = static_cast<const DictionaryValue*>(args_); 109 const DictionaryValue* args = args_as_dictionary();
110 110
111 if (args->HasKey(keys::kUrlKey)) { 111 if (args->HasKey(keys::kUrlKey)) {
112 std::string url_string; 112 std::string url_string;
113 EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kUrlKey, 113 EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kUrlKey,
114 &url_string)); 114 &url_string));
115 url = dispatcher()->url().Resolve(url_string); 115 url = dispatcher()->url().Resolve(url_string);
116 if (!url.is_valid()) { 116 if (!url.is_valid()) {
117 error_ = kInvalidURLError; 117 error_ = kInvalidURLError;
118 return false; 118 return false;
119 } 119 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 void ToolstripEventRouter::OnToolstripCollapsed(Profile* profile, 156 void ToolstripEventRouter::OnToolstripCollapsed(Profile* profile,
157 int routing_id, 157 int routing_id,
158 const GURL &url) { 158 const GURL &url) {
159 ListValue args; 159 ListValue args;
160 DictionaryValue* obj = new DictionaryValue(); 160 DictionaryValue* obj = new DictionaryValue();
161 if (!url.is_empty()) 161 if (!url.is_empty())
162 obj->SetString(keys::kUrlKey, url.spec()); 162 obj->SetString(keys::kUrlKey, url.spec());
163 args.Append(obj); 163 args.Append(obj);
164 DispatchEvent(profile, routing_id, events::kOnToolstripCollapsed, args); 164 DispatchEvent(profile, routing_id, events::kOnToolstripCollapsed, args);
165 } 165 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tabs_module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698