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

Side by Side Diff: chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc

Issue 2592293003: [MD Bookmarks] Add skeleton for MD Bookmarks. (Closed)
Patch Set: Remove unused imports. Created 3 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
« no previous file with comments | « chrome/browser/resources/md_bookmarks/toolbar.js ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/md_bookmarks/md_bookmarks_ui.h" 5 #include "chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.h"
6 6
7 #include <algorithm>
8
9 #include "base/strings/string16.h"
7 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/common/chrome_features.h" 11 #include "chrome/common/chrome_features.h"
9 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
10 #include "chrome/grit/browser_resources.h" 13 #include "chrome/grit/browser_resources.h"
11 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
12 #include "components/strings/grit/components_strings.h" 15 #include "components/strings/grit/components_strings.h"
13 #include "content/public/browser/web_ui.h" 16 #include "content/public/browser/web_ui.h"
14 #include "content/public/browser/web_ui_data_source.h" 17 #include "content/public/browser/web_ui_data_source.h"
18 #include "ui/base/l10n/l10n_util.h"
15 19
16 namespace { 20 namespace {
17 21
22 void AddLocalizedString(content::WebUIDataSource* source,
23 const std::string& message,
24 int id) {
25 base::string16 str = l10n_util::GetStringUTF16(id);
26 str.erase(std::remove(str.begin(), str.end(), '&'), str.end());
27 source->AddString(message, str);
28 }
29
18 content::WebUIDataSource* CreateMdBookmarksUIHTMLSource(Profile* profile) { 30 content::WebUIDataSource* CreateMdBookmarksUIHTMLSource(Profile* profile) {
19 content::WebUIDataSource* source = 31 content::WebUIDataSource* source =
20 content::WebUIDataSource::Create(chrome::kChromeUIBookmarksHost); 32 content::WebUIDataSource::Create(chrome::kChromeUIBookmarksHost);
21 33
22 // Localized strings (alphabetical order). 34 // Localized strings (alphabetical order).
23 source->AddLocalizedString("title", IDS_BOOKMARK_MANAGER_TITLE); 35 AddLocalizedString(source, "clearSearch",
36 IDS_MD_BOOKMARK_MANAGER_CLEAR_SEARCH);
37 AddLocalizedString(source, "menuAddBookmark",
38 IDS_MD_BOOKMARK_MANAGER_MENU_ADD_BOOKMARK);
39 AddLocalizedString(source, "menuAddFolder",
40 IDS_MD_BOOKMARK_MANAGER_MENU_ADD_FOLDER);
41 AddLocalizedString(source, "menuBulkEdit",
42 IDS_MD_BOOKMARK_MANAGER_MENU_BULK_EDIT);
43 AddLocalizedString(source, "menuCopyURL",
44 IDS_MD_BOOKMARK_MANAGER_MENU_COPY_URL);
45 AddLocalizedString(source, "menuDelete", IDS_DELETE);
46 AddLocalizedString(source, "menuEdit", IDS_EDIT);
47 AddLocalizedString(source, "menuExport", IDS_MD_BOOKMARK_MANAGER_MENU_EXPORT);
48 AddLocalizedString(source, "menuImport", IDS_MD_BOOKMARK_MANAGER_MENU_IMPORT);
49 AddLocalizedString(source, "menuSort", IDS_MD_BOOKMARK_MANAGER_MENU_SORT);
50 AddLocalizedString(source, "searchPrompt",
51 IDS_BOOKMARK_MANAGER_SEARCH_BUTTON);
52 AddLocalizedString(source, "title", IDS_MD_BOOKMARK_MANAGER_TITLE);
24 53
54 // Resources.
55 source->AddResourcePath("app.html", IDR_MD_BOOKMARKS_APP_HTML);
56 source->AddResourcePath("app.js", IDR_MD_BOOKMARKS_APP_JS);
57 source->AddResourcePath("shared_style.html",
58 IDR_MD_BOOKMARKS_SHARED_STYLE_HTML);
59 source->AddResourcePath("shared_vars.html",
60 IDR_MD_BOOKMARKS_SHARED_VARS_HTML);
61 source->AddResourcePath("store.html", IDR_MD_BOOKMARKS_STORE_HTML);
62 source->AddResourcePath("store.js", IDR_MD_BOOKMARKS_STORE_JS);
63 source->AddResourcePath("toolbar.html", IDR_MD_BOOKMARKS_TOOLBAR_HTML);
64 source->AddResourcePath("toolbar.js", IDR_MD_BOOKMARKS_TOOLBAR_JS);
25 source->SetDefaultResource(IDR_MD_BOOKMARKS_BOOKMARKS_HTML); 65 source->SetDefaultResource(IDR_MD_BOOKMARKS_BOOKMARKS_HTML);
26 source->SetJsonPath("strings.js"); 66 source->SetJsonPath("strings.js");
27 67
28 return source; 68 return source;
29 } 69 }
30 70
31 } // namespace 71 } // namespace
32 72
33 MdBookmarksUI::MdBookmarksUI(content::WebUI* web_ui) : WebUIController(web_ui) { 73 MdBookmarksUI::MdBookmarksUI(content::WebUI* web_ui) : WebUIController(web_ui) {
34 // Set up the chrome://bookmarks/ source. 74 // Set up the chrome://bookmarks/ source.
35 Profile* profile = Profile::FromWebUI(web_ui); 75 Profile* profile = Profile::FromWebUI(web_ui);
36 content::WebUIDataSource::Add(profile, 76 content::WebUIDataSource::Add(profile,
37 CreateMdBookmarksUIHTMLSource(profile)); 77 CreateMdBookmarksUIHTMLSource(profile));
38 } 78 }
39 79
40 // static 80 // static
41 bool MdBookmarksUI::IsEnabled() { 81 bool MdBookmarksUI::IsEnabled() {
42 return base::FeatureList::IsEnabled(features::kMaterialDesignBookmarks); 82 return base::FeatureList::IsEnabled(features::kMaterialDesignBookmarks);
43 } 83 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_bookmarks/toolbar.js ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698