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/ui/webui/bookmarks_ui.h" | 5 #include "chrome/browser/ui/webui/bookmarks_ui.h" |
6 | 6 |
7 #include "base/memory/ref_counted_memory.h" | 7 #include "base/memory/ref_counted_memory.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "chrome/browser/bookmarks/bookmark_editor.h" | 12 #include "chrome/browser/bookmarks/bookmark_editor.h" |
13 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
14 #include "chrome/browser/bookmarks/bookmark_utils.h" | 14 #include "chrome/browser/bookmarks/bookmark_utils.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
18 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 18 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 20 #include "content/browser/webui/web_ui.h" |
20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
21 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
22 #include "grit/theme_resources_standard.h" | 23 #include "grit/theme_resources_standard.h" |
23 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
24 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
25 | 26 |
26 using content::WebContents; | 27 using content::WebContents; |
27 | 28 |
28 //////////////////////////////////////////////////////////////////////////////// | 29 //////////////////////////////////////////////////////////////////////////////// |
29 // | 30 // |
(...skipping 19 matching lines...) Expand all Loading... |
49 << "been triggered"; | 50 << "been triggered"; |
50 return "text/html"; | 51 return "text/html"; |
51 } | 52 } |
52 | 53 |
53 //////////////////////////////////////////////////////////////////////////////// | 54 //////////////////////////////////////////////////////////////////////////////// |
54 // | 55 // |
55 // BookmarksUI | 56 // BookmarksUI |
56 // | 57 // |
57 //////////////////////////////////////////////////////////////////////////////// | 58 //////////////////////////////////////////////////////////////////////////////// |
58 | 59 |
59 BookmarksUI::BookmarksUI(WebContents* contents) : WebUI(contents, this) { | 60 BookmarksUI::BookmarksUI(WebUI* web_ui) : WebUIController(web_ui) { |
60 BookmarksUIHTMLSource* html_source = new BookmarksUIHTMLSource(); | 61 BookmarksUIHTMLSource* html_source = new BookmarksUIHTMLSource(); |
61 | 62 |
62 // Set up the chrome://bookmarks/ source. | 63 // Set up the chrome://bookmarks/ source. |
63 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); | 64 Profile* profile = Profile::FromBrowserContext( |
| 65 web_ui->web_contents()->GetBrowserContext()); |
64 profile->GetChromeURLDataManager()->AddDataSource(html_source); | 66 profile->GetChromeURLDataManager()->AddDataSource(html_source); |
65 } | 67 } |
66 | 68 |
67 // static | 69 // static |
68 RefCountedMemory* BookmarksUI::GetFaviconResourceBytes() { | 70 RefCountedMemory* BookmarksUI::GetFaviconResourceBytes() { |
69 return ResourceBundle::GetSharedInstance(). | 71 return ResourceBundle::GetSharedInstance(). |
70 LoadDataResourceBytes(IDR_BOOKMARKS_FAVICON); | 72 LoadDataResourceBytes(IDR_BOOKMARKS_FAVICON); |
71 } | 73 } |
72 | 74 |
73 //////////////////////////////////////////////////////////////////////////////// | 75 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 base::Int64ToString(editId).c_str())); | 108 base::Int64ToString(editId).c_str())); |
107 | 109 |
108 // Invoke the WebUI bookmark editor to edit the specified bookmark. | 110 // Invoke the WebUI bookmark editor to edit the specified bookmark. |
109 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); | 111 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); |
110 DCHECK(browser); | 112 DCHECK(browser); |
111 browser::NavigateParams params( | 113 browser::NavigateParams params( |
112 browser->GetSingletonTabNavigateParams(url)); | 114 browser->GetSingletonTabNavigateParams(url)); |
113 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; | 115 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
114 browser->ShowSingletonTabOverwritingNTP(params); | 116 browser->ShowSingletonTabOverwritingNTP(params); |
115 } | 117 } |
OLD | NEW |