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/extensions/api/bookmark_manager_private/bookmark_manage
r_private_api.h" | 5 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage
r_private_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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
15 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 15 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
16 #include "chrome/browser/bookmarks/bookmark_utils.h" | 16 #include "chrome/browser/bookmarks/bookmark_utils.h" |
17 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage
r_private_api_constants.h" | 17 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage
r_private_api_constants.h" |
18 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_constants.h" | 18 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_constants.h" |
19 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.h" | 19 #include "chrome/browser/extensions/api/bookmarks/bookmark_api_helpers.h" |
20 #include "chrome/browser/extensions/event_router.h" | 20 #include "chrome/browser/extensions/event_router.h" |
21 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 21 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
22 #include "chrome/browser/extensions/extension_system.h" | 22 #include "chrome/browser/extensions/extension_system.h" |
23 #include "chrome/browser/extensions/extension_web_ui.h" | 23 #include "chrome/browser/extensions/extension_web_ui.h" |
24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" | 25 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" |
26 #include "chrome/browser/view_type_utils.h" | |
27 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
28 #include "components/user_prefs/user_prefs.h" | 27 #include "components/user_prefs/user_prefs.h" |
29 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
30 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
31 #include "content/public/browser/web_contents_view.h" | 30 #include "content/public/browser/web_contents_view.h" |
32 #include "content/public/browser/web_ui.h" | 31 #include "content/public/browser/web_ui.h" |
| 32 #include "extensions/browser/view_type_utils.h" |
33 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
35 #include "ui/webui/web_ui_util.h" | 35 #include "ui/webui/web_ui_util.h" |
36 | 36 |
37 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
38 #include "win8/util/win8_util.h" | 38 #include "win8/util/win8_util.h" |
39 #endif // OS_WIN | 39 #endif // OS_WIN |
40 | 40 |
41 namespace extensions { | 41 namespace extensions { |
42 | 42 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 bool BookmarkManagerPrivateStartDragFunction::RunImpl() { | 395 bool BookmarkManagerPrivateStartDragFunction::RunImpl() { |
396 if (!EditBookmarksEnabled()) | 396 if (!EditBookmarksEnabled()) |
397 return false; | 397 return false; |
398 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 398 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
399 std::vector<const BookmarkNode*> nodes; | 399 std::vector<const BookmarkNode*> nodes; |
400 EXTENSION_FUNCTION_VALIDATE( | 400 EXTENSION_FUNCTION_VALIDATE( |
401 GetNodesFromArguments(model, args_.get(), 0, &nodes)); | 401 GetNodesFromArguments(model, args_.get(), 0, &nodes)); |
402 | 402 |
403 WebContents* web_contents = | 403 WebContents* web_contents = |
404 WebContents::FromRenderViewHost(render_view_host_); | 404 WebContents::FromRenderViewHost(render_view_host_); |
405 if (chrome::GetViewType(web_contents) == chrome::VIEW_TYPE_TAB_CONTENTS) { | 405 if (GetViewType(web_contents) == VIEW_TYPE_TAB_CONTENTS) { |
406 WebContents* web_contents = | 406 WebContents* web_contents = |
407 dispatcher()->delegate()->GetAssociatedWebContents(); | 407 dispatcher()->delegate()->GetAssociatedWebContents(); |
408 CHECK(web_contents); | 408 CHECK(web_contents); |
409 chrome::DragBookmarks(profile(), nodes, | 409 chrome::DragBookmarks(profile(), nodes, |
410 web_contents->GetView()->GetNativeView()); | 410 web_contents->GetView()->GetNativeView()); |
411 | 411 |
412 return true; | 412 return true; |
413 } else { | 413 } else { |
414 NOTREACHED(); | 414 NOTREACHED(); |
415 return false; | 415 return false; |
(...skipping 22 matching lines...) Expand all Loading... |
438 } | 438 } |
439 | 439 |
440 int drop_index; | 440 int drop_index; |
441 if (HasOptionalArgument(1)) | 441 if (HasOptionalArgument(1)) |
442 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &drop_index)); | 442 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &drop_index)); |
443 else | 443 else |
444 drop_index = drop_parent->child_count(); | 444 drop_index = drop_parent->child_count(); |
445 | 445 |
446 WebContents* web_contents = | 446 WebContents* web_contents = |
447 WebContents::FromRenderViewHost(render_view_host_); | 447 WebContents::FromRenderViewHost(render_view_host_); |
448 if (chrome::GetViewType(web_contents) == chrome::VIEW_TYPE_TAB_CONTENTS) { | 448 if (GetViewType(web_contents) == VIEW_TYPE_TAB_CONTENTS) { |
449 WebContents* web_contents = | 449 WebContents* web_contents = |
450 dispatcher()->delegate()->GetAssociatedWebContents(); | 450 dispatcher()->delegate()->GetAssociatedWebContents(); |
451 CHECK(web_contents); | 451 CHECK(web_contents); |
452 ExtensionWebUI* web_ui = | 452 ExtensionWebUI* web_ui = |
453 static_cast<ExtensionWebUI*>(web_contents->GetWebUI()->GetController()); | 453 static_cast<ExtensionWebUI*>(web_contents->GetWebUI()->GetController()); |
454 CHECK(web_ui); | 454 CHECK(web_ui); |
455 BookmarkManagerPrivateEventRouter* router = | 455 BookmarkManagerPrivateEventRouter* router = |
456 web_ui->bookmark_manager_private_event_router(); | 456 web_ui->bookmark_manager_private_event_router(); |
457 | 457 |
458 DCHECK(router); | 458 DCHECK(router); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 #if defined(OS_WIN) | 519 #if defined(OS_WIN) |
520 if (win8::IsSingleWindowMetroMode()) | 520 if (win8::IsSingleWindowMetroMode()) |
521 can_open_new_windows = false; | 521 can_open_new_windows = false; |
522 #endif // OS_WIN | 522 #endif // OS_WIN |
523 | 523 |
524 SetResult(new base::FundamentalValue(can_open_new_windows)); | 524 SetResult(new base::FundamentalValue(can_open_new_windows)); |
525 return true; | 525 return true; |
526 } | 526 } |
527 | 527 |
528 } // namespace extensions | 528 } // namespace extensions |
OLD | NEW |