OLD | NEW |
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/bookmarks/bookmark_manager_extension_api.h" | 5 #include "chrome/browser/bookmarks/bookmark_manager_extension_api.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 : profile_(profile), | 159 : profile_(profile), |
160 tab_(tab) { | 160 tab_(tab) { |
161 tab_->bookmark_tab_helper()->SetBookmarkDragDelegate(this); | 161 tab_->bookmark_tab_helper()->SetBookmarkDragDelegate(this); |
162 } | 162 } |
163 | 163 |
164 BookmarkManagerExtensionEventRouter::~BookmarkManagerExtensionEventRouter() { | 164 BookmarkManagerExtensionEventRouter::~BookmarkManagerExtensionEventRouter() { |
165 if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate() == this) | 165 if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate() == this) |
166 tab_->bookmark_tab_helper()->SetBookmarkDragDelegate(NULL); | 166 tab_->bookmark_tab_helper()->SetBookmarkDragDelegate(NULL); |
167 } | 167 } |
168 | 168 |
169 void BookmarkManagerExtensionEventRouter::DispatchEvent(const char* event_name, | 169 void BookmarkManagerExtensionEventRouter::DispatchEvent( |
170 const ListValue* args) { | 170 const char* event_name, scoped_ptr<ListValue> args) { |
171 if (!profile_->GetExtensionEventRouter()) | 171 if (!profile_->GetExtensionEventRouter()) |
172 return; | 172 return; |
173 | 173 |
174 std::string json_args; | |
175 base::JSONWriter::Write(args, &json_args); | |
176 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 174 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
177 event_name, json_args, NULL, GURL(), extensions::EventFilteringInfo()); | 175 event_name, args.Pass(), NULL, GURL(), extensions::EventFilteringInfo()); |
178 } | 176 } |
179 | 177 |
180 void BookmarkManagerExtensionEventRouter::DispatchDragEvent( | 178 void BookmarkManagerExtensionEventRouter::DispatchDragEvent( |
181 const BookmarkNodeData& data, const char* event_name) { | 179 const BookmarkNodeData& data, const char* event_name) { |
182 if (data.size() == 0) | 180 if (data.size() == 0) |
183 return; | 181 return; |
184 | 182 |
185 ListValue args; | 183 scoped_ptr<ListValue> args(new ListValue()); |
186 BookmarkNodeDataToJSON(profile_, data, &args); | 184 BookmarkNodeDataToJSON(profile_, data, args.get()); |
187 DispatchEvent(event_name, &args); | 185 DispatchEvent(event_name, args.Pass()); |
188 } | 186 } |
189 | 187 |
190 void BookmarkManagerExtensionEventRouter::OnDragEnter( | 188 void BookmarkManagerExtensionEventRouter::OnDragEnter( |
191 const BookmarkNodeData& data) { | 189 const BookmarkNodeData& data) { |
192 DispatchDragEvent(data, keys::kOnBookmarkDragEnter); | 190 DispatchDragEvent(data, keys::kOnBookmarkDragEnter); |
193 } | 191 } |
194 | 192 |
195 void BookmarkManagerExtensionEventRouter::OnDragOver( | 193 void BookmarkManagerExtensionEventRouter::OnDragOver( |
196 const BookmarkNodeData& data) { | 194 const BookmarkNodeData& data) { |
197 // Intentionally empty since these events happens too often and floods the | 195 // Intentionally empty since these events happens too often and floods the |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 bool can_open_new_windows = true; | 508 bool can_open_new_windows = true; |
511 | 509 |
512 #if defined(OS_WIN) | 510 #if defined(OS_WIN) |
513 if (base::win::IsMetroProcess()) | 511 if (base::win::IsMetroProcess()) |
514 can_open_new_windows = false; | 512 can_open_new_windows = false; |
515 #endif // OS_WIN | 513 #endif // OS_WIN |
516 | 514 |
517 SetResult(Value::CreateBooleanValue(can_open_new_windows)); | 515 SetResult(Value::CreateBooleanValue(can_open_new_windows)); |
518 return true; | 516 return true; |
519 } | 517 } |
OLD | NEW |