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