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

Side by Side Diff: chrome/browser/automation/automation_provider_json.cc

Issue 106433007: Update some uses of Value in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 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) 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/automation/automation_provider_json.h" 5 #include "chrome/browser/automation/automation_provider_json.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/json/string_escape.h" 8 #include "base/json/string_escape.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/autocomplete/autocomplete_match.h" 10 #include "chrome/browser/autocomplete/autocomplete_match.h"
(...skipping 11 matching lines...) Expand all
22 AutomationJSONReply::AutomationJSONReply(AutomationProvider* provider, 22 AutomationJSONReply::AutomationJSONReply(AutomationProvider* provider,
23 IPC::Message* reply_message) 23 IPC::Message* reply_message)
24 : provider_(provider), 24 : provider_(provider),
25 message_(reply_message) { 25 message_(reply_message) {
26 } 26 }
27 27
28 AutomationJSONReply::~AutomationJSONReply() { 28 AutomationJSONReply::~AutomationJSONReply() {
29 DCHECK(!message_) << "JSON automation request not replied!"; 29 DCHECK(!message_) << "JSON automation request not replied!";
30 } 30 }
31 31
32 void AutomationJSONReply::SendSuccess(const Value* value) { 32 void AutomationJSONReply::SendSuccess(const base::Value* value) {
33 DCHECK(message_) << "Resending reply for JSON automation request"; 33 DCHECK(message_) << "Resending reply for JSON automation request";
34 std::string json_string = "{}"; 34 std::string json_string = "{}";
35 if (value) 35 if (value)
36 base::JSONWriter::Write(value, &json_string); 36 base::JSONWriter::Write(value, &json_string);
37 AutomationMsg_SendJSONRequest::WriteReplyParams( 37 AutomationMsg_SendJSONRequest::WriteReplyParams(
38 message_, json_string, true); 38 message_, json_string, true);
39 provider_->Send(message_); 39 provider_->Send(message_);
40 message_ = NULL; 40 message_ = NULL;
41 } 41 }
42 42
43 void AutomationJSONReply::SendError(const std::string& error_message) { 43 void AutomationJSONReply::SendError(const std::string& error_message) {
44 DCHECK(message_) << "Resending reply for JSON automation request"; 44 DCHECK(message_) << "Resending reply for JSON automation request";
45 45
46 base::DictionaryValue dict; 46 base::DictionaryValue dict;
47 dict.SetString("error", error_message); 47 dict.SetString("error", error_message);
48 std::string json; 48 std::string json;
49 base::JSONWriter::Write(&dict, &json); 49 base::JSONWriter::Write(&dict, &json);
50 50
51 AutomationMsg_SendJSONRequest::WriteReplyParams(message_, json, false); 51 AutomationMsg_SendJSONRequest::WriteReplyParams(message_, json, false);
52 provider_->Send(message_); 52 provider_->Send(message_);
53 message_ = NULL; 53 message_ = NULL;
54 } 54 }
55 55
56 bool GetBrowserFromJSONArgs( 56 bool GetBrowserFromJSONArgs(
57 DictionaryValue* args, 57 base::DictionaryValue* args,
58 Browser** browser, 58 Browser** browser,
59 std::string* error) { 59 std::string* error) {
60 int browser_index; 60 int browser_index;
61 if (!args->GetInteger("windex", &browser_index)) { 61 if (!args->GetInteger("windex", &browser_index)) {
62 *error = "'windex' missing or invalid"; 62 *error = "'windex' missing or invalid";
63 return false; 63 return false;
64 } 64 }
65 *browser = automation_util::GetBrowserAt(browser_index); 65 *browser = automation_util::GetBrowserAt(browser_index);
66 if (!*browser) { 66 if (!*browser) {
67 *error = "Cannot locate browser from given index"; 67 *error = "Cannot locate browser from given index";
68 return false; 68 return false;
69 } 69 }
70 return true; 70 return true;
71 } 71 }
72 72
73 bool GetTabFromJSONArgs( 73 bool GetTabFromJSONArgs(
74 DictionaryValue* args, 74 base::DictionaryValue* args,
75 WebContents** tab, 75 WebContents** tab,
76 std::string* error) { 76 std::string* error) {
77 int browser_index, tab_index; 77 int browser_index, tab_index;
78 if (!args->GetInteger("windex", &browser_index)) { 78 if (!args->GetInteger("windex", &browser_index)) {
79 *error = "'windex' missing or invalid"; 79 *error = "'windex' missing or invalid";
80 return false; 80 return false;
81 } 81 }
82 if (!args->GetInteger("tab_index", &tab_index)) { 82 if (!args->GetInteger("tab_index", &tab_index)) {
83 *error = "'tab_index' missing or invalid"; 83 *error = "'tab_index' missing or invalid";
84 return false; 84 return false;
85 } 85 }
86 *tab = automation_util::GetWebContentsAt(browser_index, tab_index); 86 *tab = automation_util::GetWebContentsAt(browser_index, tab_index);
87 if (!*tab) { 87 if (!*tab) {
88 *error = "Cannot locate tab from given indices"; 88 *error = "Cannot locate tab from given indices";
89 return false; 89 return false;
90 } 90 }
91 return true; 91 return true;
92 } 92 }
93 93
94 bool GetBrowserAndTabFromJSONArgs( 94 bool GetBrowserAndTabFromJSONArgs(
95 DictionaryValue* args, 95 base::DictionaryValue* args,
96 Browser** browser, 96 Browser** browser,
97 WebContents** tab, 97 WebContents** tab,
98 std::string* error) { 98 std::string* error) {
99 return GetBrowserFromJSONArgs(args, browser, error) && 99 return GetBrowserFromJSONArgs(args, browser, error) &&
100 GetTabFromJSONArgs(args, tab, error); 100 GetTabFromJSONArgs(args, tab, error);
101 } 101 }
102 102
103 bool GetRenderViewFromJSONArgs( 103 bool GetRenderViewFromJSONArgs(
104 DictionaryValue* args, 104 base::DictionaryValue* args,
105 Profile* profile, 105 Profile* profile,
106 content::RenderViewHost** rvh, 106 content::RenderViewHost** rvh,
107 std::string* error) { 107 std::string* error) {
108 WebContents* tab = NULL; 108 WebContents* tab = NULL;
109 if (!GetTabFromJSONArgs(args, &tab, error)) 109 if (!GetTabFromJSONArgs(args, &tab, error))
110 return false; 110 return false;
111 *rvh = tab->GetRenderViewHost(); 111 *rvh = tab->GetRenderViewHost();
112 return true; 112 return true;
113 } 113 }
114 114
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 bool GetEnabledExtensionFromJSONArgs( 164 bool GetEnabledExtensionFromJSONArgs(
165 base::DictionaryValue* args, 165 base::DictionaryValue* args,
166 const std::string& key, 166 const std::string& key,
167 Profile* profile, 167 Profile* profile,
168 const extensions::Extension** extension, 168 const extensions::Extension** extension,
169 std::string* error) { 169 std::string* error) {
170 return GetExtensionFromJSONArgsHelper( 170 return GetExtensionFromJSONArgsHelper(
171 args, key, profile, false /* include_disabled */, extension, error); 171 args, key, profile, false /* include_disabled */, extension, error);
172 } 172 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider.cc ('k') | chrome/browser/automation/automation_provider_observers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698