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

Side by Side Diff: chrome/browser/views/bookmark_manager_view.cc

Issue 418044: sync: Show the expired credential errors in the Bookmark Manager. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: fix nit Created 11 years 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
« no previous file with comments | « chrome/browser/views/bookmark_manager_view.h ('k') | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/views/bookmark_manager_view.h" 5 #include "chrome/browser/views/bookmark_manager_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/gfx/canvas.h" 9 #include "app/gfx/canvas.h"
10 #include "app/gfx/color_utils.h" 10 #include "app/gfx/color_utils.h"
11 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
12 #include "app/resource_bundle.h"
12 #include "base/keyboard_codes.h" 13 #include "base/keyboard_codes.h"
13 #include "base/thread.h" 14 #include "base/thread.h"
14 #include "chrome/browser/bookmarks/bookmark_folder_tree_model.h" 15 #include "chrome/browser/bookmarks/bookmark_folder_tree_model.h"
15 #include "chrome/browser/bookmarks/bookmark_html_writer.h" 16 #include "chrome/browser/bookmarks/bookmark_html_writer.h"
16 #include "chrome/browser/bookmarks/bookmark_manager.h" 17 #include "chrome/browser/bookmarks/bookmark_manager.h"
17 #include "chrome/browser/bookmarks/bookmark_model.h" 18 #include "chrome/browser/bookmarks/bookmark_model.h"
18 #include "chrome/browser/bookmarks/bookmark_table_model.h" 19 #include "chrome/browser/bookmarks/bookmark_table_model.h"
19 #include "chrome/browser/bookmarks/bookmark_utils.h" 20 #include "chrome/browser/bookmarks/bookmark_utils.h"
20 #include "chrome/browser/browser_list.h" 21 #include "chrome/browser/browser_list.h"
21 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/importer/importer.h" 23 #include "chrome/browser/importer/importer.h"
23 #include "chrome/browser/metrics/user_metrics.h" 24 #include "chrome/browser/metrics/user_metrics.h"
24 #include "chrome/browser/profile.h" 25 #include "chrome/browser/profile.h"
25 #include "chrome/browser/sync/sync_ui_util.h" 26 #include "chrome/browser/sync/sync_ui_util.h"
26 #include "chrome/browser/views/bookmark_editor_view.h" 27 #include "chrome/browser/views/bookmark_editor_view.h"
27 #include "chrome/browser/views/bookmark_folder_tree_view.h" 28 #include "chrome/browser/views/bookmark_folder_tree_view.h"
28 #include "chrome/browser/views/bookmark_table_view.h" 29 #include "chrome/browser/views/bookmark_table_view.h"
29 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
30 #include "chrome/common/pref_service.h" 31 #include "chrome/common/pref_service.h"
31 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
32 #include "grit/locale_settings.h" 33 #include "grit/locale_settings.h"
34 #include "grit/theme_resources.h"
33 #include "skia/ext/skia_utils.h" 35 #include "skia/ext/skia_utils.h"
34 #include "third_party/skia/include/core/SkShader.h" 36 #include "third_party/skia/include/core/SkShader.h"
35 #include "views/controls/button/menu_button.h" 37 #include "views/controls/button/menu_button.h"
36 #include "views/controls/label.h" 38 #include "views/controls/label.h"
37 #include "views/controls/menu/menu_item_view.h" 39 #include "views/controls/menu/menu_item_view.h"
38 #include "views/controls/single_split_view.h" 40 #include "views/controls/single_split_view.h"
39 #include "views/grid_layout.h" 41 #include "views/grid_layout.h"
40 #include "views/standard_layout.h" 42 #include "views/standard_layout.h"
41 #include "views/widget/widget.h" 43 #include "views/widget/widget.h"
42 #include "views/window/window.h" 44 #include "views/window/window.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 161 }
160 162
161 // ----------------------------------------------------------------------------- 163 // -----------------------------------------------------------------------------
162 164
163 BookmarkManagerView::BookmarkManagerView(Profile* profile) 165 BookmarkManagerView::BookmarkManagerView(Profile* profile)
164 : profile_(profile->GetOriginalProfile()), 166 : profile_(profile->GetOriginalProfile()),
165 table_view_(NULL), 167 table_view_(NULL),
166 tree_view_(NULL), 168 tree_view_(NULL),
167 sync_status_button_(NULL), 169 sync_status_button_(NULL),
168 sync_service_(NULL), 170 sync_service_(NULL),
171 sync_relogin_required_(false),
169 ALLOW_THIS_IN_INITIALIZER_LIST(search_factory_(this)) { 172 ALLOW_THIS_IN_INITIALIZER_LIST(search_factory_(this)) {
170 search_tf_ = new views::Textfield(); 173 search_tf_ = new views::Textfield();
171 search_tf_->set_default_width_in_chars(30); 174 search_tf_->set_default_width_in_chars(30);
172 175
173 table_view_ = new BookmarkTableView(profile_, NULL); 176 table_view_ = new BookmarkTableView(profile_, NULL);
174 table_view_->SetObserver(this); 177 table_view_->SetObserver(this);
175 table_view_->SetContextMenuController(this); 178 table_view_->SetContextMenuController(this);
176 179
177 tree_view_ = new BookmarkFolderTreeView(profile_, NULL); 180 tree_view_ = new BookmarkFolderTreeView(profile_, NULL);
178 tree_view_->SetController(this); 181 tree_view_->SetController(this);
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 507
505 default: 508 default:
506 OnCutCopyPaste(KeyCodeToCutCopyPaste(keycode), false); 509 OnCutCopyPaste(KeyCodeToCutCopyPaste(keycode), false);
507 break; 510 break;
508 } 511 }
509 } 512 }
510 513
511 void BookmarkManagerView::ButtonPressed(views::Button* sender, 514 void BookmarkManagerView::ButtonPressed(views::Button* sender,
512 const views::Event& event) { 515 const views::Event& event) {
513 if (sender == sync_status_button_) { 516 if (sender == sync_status_button_) {
514 UserMetrics::RecordAction("BookmarkManager_Sync", profile_); 517 if (sync_relogin_required_) {
515 sync_ui_util::OpenSyncMyBookmarksDialog( 518 DCHECK(sync_service_);
516 profile_, ProfileSyncService::START_FROM_BOOKMARK_MANAGER); 519 sync_service_->ShowLoginDialog();
520 } else {
521 UserMetrics::RecordAction("BookmarkManager_Sync", profile_);
522 sync_ui_util::OpenSyncMyBookmarksDialog(
523 profile_, ProfileSyncService::START_FROM_BOOKMARK_MANAGER);
524 }
517 } 525 }
518 } 526 }
519 527
520 void BookmarkManagerView::Loaded(BookmarkModel* model) { 528 void BookmarkManagerView::Loaded(BookmarkModel* model) {
521 model->RemoveObserver(this); 529 model->RemoveObserver(this);
522 LoadedImpl(); 530 LoadedImpl();
523 } 531 }
524 532
525 void BookmarkManagerView::ContentsChanged(views::Textfield* sender, 533 void BookmarkManagerView::ContentsChanged(views::Textfield* sender,
526 const std::wstring& new_contents) { 534 const std::wstring& new_contents) {
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 select_file_dialog_ = SelectFileDialog::Create(this); 817 select_file_dialog_ = SelectFileDialog::Create(this);
810 select_file_dialog_->SelectFile( 818 select_file_dialog_->SelectFile(
811 SelectFileDialog::SELECT_SAVEAS_FILE, std::wstring(), 819 SelectFileDialog::SELECT_SAVEAS_FILE, std::wstring(),
812 FilePath(FILE_PATH_LITERAL("bookmarks.html")), &file_type_info, 0, 820 FilePath(FILE_PATH_LITERAL("bookmarks.html")), &file_type_info, 0,
813 L"html", GetWidget()->GetNativeView(), 821 L"html", GetWidget()->GetNativeView(),
814 reinterpret_cast<void*>(IDS_BOOKMARK_MANAGER_EXPORT_MENU)); 822 reinterpret_cast<void*>(IDS_BOOKMARK_MANAGER_EXPORT_MENU));
815 } 823 }
816 824
817 void BookmarkManagerView::UpdateSyncStatus() { 825 void BookmarkManagerView::UpdateSyncStatus() {
818 DCHECK(sync_service_); 826 DCHECK(sync_service_);
819 std::wstring status_label; 827 string16 status_label;
820 std::wstring link_label; 828 string16 link_label;
821 bool synced = sync_ui_util::GetStatusLabels(sync_service_, 829 sync_relogin_required_ = sync_ui_util::GetStatusLabels(sync_service_,
822 &status_label, &link_label) == sync_ui_util::SYNCED; 830 &status_label, &link_label) == sync_ui_util::SYNC_ERROR;
831
832 if (sync_relogin_required_) {
833 sync_status_button_->SetText(
834 l10n_util::GetString(IDS_SYNC_BOOKMARK_BAR_ERROR));
835 // The tooltip is the only way we have to display text explaining the error
836 // to the user.
837 sync_status_button_->SetTooltipText(
838 l10n_util::GetString(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC));
839 sync_status_button_->SetAccessibleName(
840 l10n_util::GetString(IDS_ACCNAME_SYNC_ERROR_BUTTON));
841 sync_status_button_->SetIcon(
842 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING));
843 sync_status_button_->GetParent()->Layout();
844 return;
845 }
823 846
824 if (sync_service_->HasSyncSetupCompleted()) { 847 if (sync_service_->HasSyncSetupCompleted()) {
825 std::wstring username = sync_service_->GetAuthenticatedUsername(); 848 std::wstring username = sync_service_->GetAuthenticatedUsername();
826 status_label = l10n_util::GetStringF(IDS_SYNC_NTP_SYNCED_TO, username); 849 status_label = l10n_util::GetStringF(IDS_SYNC_NTP_SYNCED_TO, username);
827 } else if (!sync_service_->SetupInProgress() && !synced) { 850 } else if (sync_service_->SetupInProgress()) {
851 status_label = l10n_util::GetString(IDS_SYNC_NTP_SETUP_IN_PROGRESS);
852 } else {
828 status_label = l10n_util::GetString(IDS_SYNC_START_SYNC_BUTTON_LABEL); 853 status_label = l10n_util::GetString(IDS_SYNC_START_SYNC_BUTTON_LABEL);
829 } 854 }
830 sync_status_button_->SetText(status_label); 855 sync_status_button_->SetText(status_label);
856 sync_status_button_->SetTooltipText(L"");
857 sync_status_button_->SetAccessibleName(L"");
858 sync_status_button_->SetIcon(SkBitmap());
831 sync_status_button_->GetParent()->Layout(); 859 sync_status_button_->GetParent()->Layout();
832 } 860 }
OLDNEW
« no previous file with comments | « chrome/browser/views/bookmark_manager_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698