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

Side by Side Diff: chrome/browser/bookmarks/bookmark_manager_extension_api.cc

Issue 9224002: Make WebUI objects not derive from WebUI. WebUI objects own the controller. This is the ownership... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync to head to clear linux_chromeos browsertest failures Created 8 years, 11 months 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) 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/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"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/bookmarks/bookmark_model.h" 12 #include "chrome/browser/bookmarks/bookmark_model.h"
13 #include "chrome/browser/bookmarks/bookmark_node_data.h" 13 #include "chrome/browser/bookmarks/bookmark_node_data.h"
14 #include "chrome/browser/bookmarks/bookmark_utils.h" 14 #include "chrome/browser/bookmarks/bookmark_utils.h"
15 #include "chrome/browser/bookmarks/bookmark_extension_api_constants.h" 15 #include "chrome/browser/bookmarks/bookmark_extension_api_constants.h"
16 #include "chrome/browser/bookmarks/bookmark_extension_helpers.h" 16 #include "chrome/browser/bookmarks/bookmark_extension_helpers.h"
17 #include "chrome/browser/extensions/extension_event_router.h" 17 #include "chrome/browser/extensions/extension_event_router.h"
18 #include "chrome/browser/extensions/extension_function_dispatcher.h" 18 #include "chrome/browser/extensions/extension_function_dispatcher.h"
19 #include "chrome/browser/extensions/extension_web_ui.h" 19 #include "chrome/browser/extensions/extension_web_ui.h"
20 #include "chrome/browser/prefs/pref_service.h" 20 #include "chrome/browser/prefs/pref_service.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
23 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 23 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
24 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
25 #include "chrome/common/chrome_view_type.h" 25 #include "chrome/common/chrome_view_type.h"
26 #include "content/browser/renderer_host/render_view_host.h" 26 #include "content/browser/renderer_host/render_view_host.h"
27 #include "content/browser/renderer_host/render_view_host_delegate.h" 27 #include "content/browser/renderer_host/render_view_host_delegate.h"
28 #include "content/browser/webui/web_ui.h"
28 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
29 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
30 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
31 32
32 namespace keys = bookmark_extension_api_constants; 33 namespace keys = bookmark_extension_api_constants;
33 34
34 using content::WebContents; 35 using content::WebContents;
35 36
36 namespace { 37 namespace {
37 38
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &drop_index)); 421 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &drop_index));
421 else 422 else
422 drop_index = drop_parent->child_count(); 423 drop_index = drop_parent->child_count();
423 424
424 if (render_view_host_->delegate()->GetRenderViewType() == 425 if (render_view_host_->delegate()->GetRenderViewType() ==
425 content::VIEW_TYPE_TAB_CONTENTS) { 426 content::VIEW_TYPE_TAB_CONTENTS) {
426 WebContents* web_contents = 427 WebContents* web_contents =
427 dispatcher()->delegate()->GetAssociatedWebContents(); 428 dispatcher()->delegate()->GetAssociatedWebContents();
428 CHECK(web_contents); 429 CHECK(web_contents);
429 ExtensionWebUI* web_ui = 430 ExtensionWebUI* web_ui =
430 static_cast<ExtensionWebUI*>(web_contents->GetWebUI()); 431 static_cast<ExtensionWebUI*>(web_contents->GetWebUI()->GetController());
431 CHECK(web_ui); 432 CHECK(web_ui);
432 BookmarkManagerExtensionEventRouter* router = 433 BookmarkManagerExtensionEventRouter* router =
433 web_ui->bookmark_manager_extension_event_router(); 434 web_ui->bookmark_manager_extension_event_router();
434 435
435 DCHECK(router); 436 DCHECK(router);
436 const BookmarkNodeData* drag_data = router->GetBookmarkNodeData(); 437 const BookmarkNodeData* drag_data = router->GetBookmarkNodeData();
437 if (drag_data == NULL) { 438 if (drag_data == NULL) {
438 NOTREACHED() <<"Somehow we're dropping null bookmark data"; 439 NOTREACHED() <<"Somehow we're dropping null bookmark data";
439 return false; 440 return false;
440 } 441 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 bool CanEditBookmarkManagerFunction::RunImpl() { 488 bool CanEditBookmarkManagerFunction::RunImpl() {
488 result_.reset(Value::CreateBooleanValue( 489 result_.reset(Value::CreateBooleanValue(
489 profile_->GetPrefs()->GetBoolean(prefs::kEditBookmarksEnabled))); 490 profile_->GetPrefs()->GetBoolean(prefs::kEditBookmarksEnabled)));
490 return true; 491 return true;
491 } 492 }
492 493
493 bool RecordLaunchBookmarkFunction::RunImpl() { 494 bool RecordLaunchBookmarkFunction::RunImpl() {
494 bookmark_utils::RecordBookmarkLaunch(bookmark_utils::LAUNCH_MANAGER); 495 bookmark_utils::RecordBookmarkLaunch(bookmark_utils::LAUNCH_MANAGER);
495 return true; 496 return true;
496 } 497 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698