OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_sidebar_api.h" | 5 #include "chrome/browser/extensions/extension_sidebar_api.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 const char kHiddenState[] = "hidden"; | 51 const char kHiddenState[] = "hidden"; |
52 const char kShownState[] = "shown"; | 52 const char kShownState[] = "shown"; |
53 } // namespace extension_sidebar_constants | 53 } // namespace extension_sidebar_constants |
54 | 54 |
55 // static | 55 // static |
56 void ExtensionSidebarEventRouter::OnStateChanged( | 56 void ExtensionSidebarEventRouter::OnStateChanged( |
57 Profile* profile, TabContents* tab, const std::string& content_id, | 57 Profile* profile, TabContents* tab, const std::string& content_id, |
58 const std::string& state) { | 58 const std::string& state) { |
59 int tab_id = ExtensionTabUtil::GetTabId(tab); | 59 int tab_id = ExtensionTabUtil::GetTabId(tab); |
60 DictionaryValue* details = new DictionaryValue; | 60 DictionaryValue* details = new DictionaryValue; |
61 details->Set(kTabIdKey, Value::CreateIntegerValue(tab_id)); | 61 details->Set(kTabIdKey, base::NumberValue::New(tab_id)); |
62 details->Set(kStateKey, Value::CreateStringValue(state)); | 62 details->Set(kStateKey, base::StringValue::New(state)); |
63 | 63 |
64 ListValue args; | 64 ListValue args; |
65 args.Set(0, details); | 65 args.Set(0, details); |
66 std::string json_args; | 66 std::string json_args; |
67 base::JSONWriter::Write(&args, false, &json_args); | 67 base::JSONWriter::Write(&args, false, &json_args); |
68 | 68 |
69 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 69 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
70 extension_sidebar_utils::GetExtensionIdByContentId(content_id), | 70 extension_sidebar_utils::GetExtensionIdByContentId(content_id), |
71 kOnStateChanged, json_args, profile, GURL()); | 71 kOnStateChanged, json_args, profile, GURL()); |
72 } | 72 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 &default_tab_id)) { | 183 &default_tab_id)) { |
184 is_active = default_tab_id == tab_id; | 184 is_active = default_tab_id == tab_id; |
185 } | 185 } |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 result = is_active ? extension_sidebar_constants::kActiveState : | 189 result = is_active ? extension_sidebar_constants::kActiveState : |
190 extension_sidebar_constants::kShownState; | 190 extension_sidebar_constants::kShownState; |
191 } | 191 } |
192 | 192 |
193 result_.reset(Value::CreateStringValue(result)); | 193 result_.reset(base::StringValue::New(result)); |
194 return true; | 194 return true; |
195 } | 195 } |
196 | 196 |
197 bool HideSidebarFunction::RunImpl(TabContents* tab, | 197 bool HideSidebarFunction::RunImpl(TabContents* tab, |
198 const std::string& content_id, | 198 const std::string& content_id, |
199 const DictionaryValue& details) { | 199 const DictionaryValue& details) { |
200 SidebarManager::GetInstance()->HideSidebar(tab, content_id); | 200 SidebarManager::GetInstance()->HideSidebar(tab, content_id); |
201 return true; | 201 return true; |
202 } | 202 } |
203 | 203 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 SidebarManager::GetInstance()->SetSidebarTitle(tab, content_id, title); | 248 SidebarManager::GetInstance()->SetSidebarTitle(tab, content_id, title); |
249 return true; | 249 return true; |
250 } | 250 } |
251 | 251 |
252 bool ShowSidebarFunction::RunImpl(TabContents* tab, | 252 bool ShowSidebarFunction::RunImpl(TabContents* tab, |
253 const std::string& content_id, | 253 const std::string& content_id, |
254 const DictionaryValue& details) { | 254 const DictionaryValue& details) { |
255 SidebarManager::GetInstance()->ShowSidebar(tab, content_id); | 255 SidebarManager::GetInstance()->ShowSidebar(tab, content_id); |
256 return true; | 256 return true; |
257 } | 257 } |
OLD | NEW |