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

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

Issue 441008: Many changes to DictionaryValues:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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) 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/execute_code_in_tab_function.h" 5 #include "chrome/browser/extensions/execute_code_in_tab_function.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/browser.h" 8 #include "chrome/browser/browser.h"
9 #include "chrome/browser/extensions/extension_tabs_module.h" 9 #include "chrome/browser/extensions/extension_tabs_module.h"
10 #include "chrome/browser/extensions/extension_tabs_module_constants.h" 10 #include "chrome/browser/extensions/extension_tabs_module_constants.h"
11 #include "chrome/browser/extensions/file_reader.h" 11 #include "chrome/browser/extensions/file_reader.h"
12 #include "chrome/browser/tab_contents/tab_contents.h" 12 #include "chrome/browser/tab_contents/tab_contents.h"
13 #include "chrome/common/extensions/extension.h" 13 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/extensions/extension_error_utils.h" 14 #include "chrome/common/extensions/extension_error_utils.h"
15 15
16 namespace keys = extension_tabs_module_constants; 16 namespace keys = extension_tabs_module_constants;
17 17
18 const wchar_t* kCodeKey = L"code"; 18 const wchar_t* kCodeKey = L"code";
19 const wchar_t* kFileKey = L"file"; 19 const wchar_t* kFileKey = L"file";
20 const wchar_t* kAllFramesKey = L"allFrames"; 20 const wchar_t* kAllFramesKey = L"allFrames";
21 21
22 bool ExecuteCodeInTabFunction::RunImpl() { 22 bool ExecuteCodeInTabFunction::RunImpl() {
23 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST)); 23 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST));
24 const ListValue* args = args_as_list(); 24 const ListValue* args = args_as_list();
25 25
26 DictionaryValue* script_info; 26 DictionaryValue* script_info;
27 EXTENSION_FUNCTION_VALIDATE(args->GetDictionary(1, &script_info)); 27 EXTENSION_FUNCTION_VALIDATE(args->GetDictionary(1, &script_info));
28 size_t number_of_value = script_info->GetSize(); 28 size_t number_of_value = script_info->size();
29 if (number_of_value == 0) { 29 if (number_of_value == 0) {
30 error_ = keys::kNoCodeOrFileToExecuteError; 30 error_ = keys::kNoCodeOrFileToExecuteError;
31 return false; 31 return false;
32 } else { 32 } else {
33 bool has_code = script_info->HasKey(kCodeKey); 33 bool has_code = script_info->HasKey(kCodeKey);
34 bool has_file = script_info->HasKey(kFileKey); 34 bool has_file = script_info->HasKey(kFileKey);
35 if (has_code && has_file) { 35 if (has_code && has_file) {
36 error_ = keys::kMoreThanOneValuesError; 36 error_ = keys::kMoreThanOneValuesError;
37 return false; 37 return false;
38 } else if (!has_code && !has_file) { 38 } else if (!has_code && !has_file) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 void ExecuteCodeInTabFunction::Observe(NotificationType type, 152 void ExecuteCodeInTabFunction::Observe(NotificationType type,
153 const NotificationSource& source, 153 const NotificationSource& source,
154 const NotificationDetails& details) { 154 const NotificationDetails& details) {
155 std::pair<int, bool>* result_details = 155 std::pair<int, bool>* result_details =
156 Details<std::pair<int, bool> >(details).ptr(); 156 Details<std::pair<int, bool> >(details).ptr();
157 if (result_details->first == request_id()) { 157 if (result_details->first == request_id()) {
158 SendResponse(result_details->second); 158 SendResponse(result_details->second);
159 Release(); // balanced in Execute() 159 Release(); // balanced in Execute()
160 } 160 }
161 } 161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698