summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-04 16:37:34 +0000
committerrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-04 16:37:34 +0000
commit8c885f66a6a432a182ddb1e09bd10ed6aeb4c178 (patch)
tree3129651d957439b6961a08b60573907d4e4e57c1
parent7cefa6bf1eae4bce7b5e28f94f595661415c89f9 (diff)
downloadchromium_src-8c885f66a6a432a182ddb1e09bd10ed6aeb4c178.zip
chromium_src-8c885f66a6a432a182ddb1e09bd10ed6aeb4c178.tar.gz
chromium_src-8c885f66a6a432a182ddb1e09bd10ed6aeb4c178.tar.bz2
Add mirror support to cloud print.
BUG=388826 TBR=sky@chromium.org Review URL: https://codereview.chromium.org/349343002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281413 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/printing/print_dialog_cloud.cc32
-rw-r--r--chrome/browser/profiles/profile_window.cc19
-rw-r--r--chrome/browser/profiles/profile_window.h7
-rw-r--r--chrome/browser/ui/browser_window.h1
-rw-r--r--chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm18
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc20
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_handler.cc29
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_handler.h19
8 files changed, 101 insertions, 44 deletions
diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc
index 6d92817..0f8ab4a 100644
--- a/chrome/browser/printing/print_dialog_cloud.cc
+++ b/chrome/browser/printing/print_dialog_cloud.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/print_messages.h"
@@ -28,6 +29,7 @@
#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "components/google/core/browser/google_util.h"
#include "components/pref_registry/pref_registry_syncable.h"
+#include "components/signin/core/common/profile_management_switches.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
@@ -711,16 +713,26 @@ void CreateCloudPrintSigninTab(Browser* browser,
bool add_account,
const base::Closure& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- GURL url = add_account ? cloud_devices::GetCloudPrintAddAccountURL()
- : cloud_devices::GetCloudPrintSigninURL();
- content::WebContents* web_contents = browser->OpenURL(content::OpenURLParams(
- google_util::AppendGoogleLocaleParam(
- url, g_browser_process->GetApplicationLocale()),
- content::Referrer(),
- NEW_FOREGROUND_TAB,
- content::PAGE_TRANSITION_AUTO_BOOKMARK,
- false));
- new SignInObserver(web_contents, cloud_devices::GetCloudPrintURL(), callback);
+ if (switches::IsEnableAccountConsistency() &&
+ !browser->profile()->IsOffTheRecord()) {
+ browser->window()->ShowAvatarBubbleFromAvatarButton(
+ add_account ? BrowserWindow::AVATAR_BUBBLE_MODE_ADD_ACCOUNT
+ : BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN,
+ signin::ManageAccountsParams());
+ } else {
+ GURL url = add_account ? cloud_devices::GetCloudPrintAddAccountURL()
+ : cloud_devices::GetCloudPrintSigninURL();
+ content::WebContents* web_contents =
+ browser->OpenURL(content::OpenURLParams(
+ google_util::AppendGoogleLocaleParam(
+ url, g_browser_process->GetApplicationLocale()),
+ content::Referrer(),
+ NEW_FOREGROUND_TAB,
+ content::PAGE_TRANSITION_AUTO_BOOKMARK,
+ false));
+ new SignInObserver(web_contents, cloud_devices::GetCloudPrintURL(),
+ callback);
+ }
}
void CreatePrintDialogForBytes(content::BrowserContext* browser_context,
diff --git a/chrome/browser/profiles/profile_window.cc b/chrome/browser/profiles/profile_window.cc
index df9e407..a4d6af2 100644
--- a/chrome/browser/profiles/profile_window.cc
+++ b/chrome/browser/profiles/profile_window.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/signin/account_reconcilor_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
+#include "chrome/browser/ui/profile_chooser_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -361,4 +362,22 @@ void DisableNewProfileManagementPreview(Profile* profile) {
UpdateServicesWithNewProfileManagementFlag(profile, false);
}
+BubbleViewMode BubbleViewModeFromAvatarBubbleMode(
+ BrowserWindow::AvatarBubbleMode mode) {
+ switch (mode) {
+ case BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT:
+ return profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
+ case BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN:
+ return profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN;
+ case BrowserWindow::AVATAR_BUBBLE_MODE_ADD_ACCOUNT:
+ return profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT;
+ case BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH:
+ return profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH;
+ case BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT:
+ return profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
+ }
+ NOTREACHED();
+ return profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
+}
+
} // namespace profiles
diff --git a/chrome/browser/profiles/profile_window.h b/chrome/browser/profiles/profile_window.h
index f60dae0..a4ac419d 100644
--- a/chrome/browser/profiles/profile_window.h
+++ b/chrome/browser/profiles/profile_window.h
@@ -7,7 +7,9 @@
#include "base/callback_forward.h"
#include "chrome/browser/profiles/profile_metrics.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/host_desktop.h"
+#include "chrome/browser/ui/profile_chooser_constants.h"
#include "chrome/browser/ui/startup/startup_types.h"
class Profile;
@@ -88,6 +90,11 @@ void EnableNewProfileManagementPreview(Profile* profile);
// Disables new profile management preview and attempts to relaunch Chrome.
void DisableNewProfileManagementPreview(Profile* profile);
+// Converts from modes in the avatar menu to modes understood by
+// ProfileChooserView.
+BubbleViewMode BubbleViewModeFromAvatarBubbleMode(
+ BrowserWindow::AvatarBubbleMode mode);
+
} // namespace profiles
#endif // CHROME_BROWSER_PROFILES_PROFILE_WINDOW_H_
diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h
index 2c1626a..bc81be4 100644
--- a/chrome/browser/ui/browser_window.h
+++ b/chrome/browser/ui/browser_window.h
@@ -367,6 +367,7 @@ class BrowserWindow : public ui::BaseWindow {
AVATAR_BUBBLE_MODE_DEFAULT,
AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT,
AVATAR_BUBBLE_MODE_SIGNIN,
+ AVATAR_BUBBLE_MODE_ADD_ACCOUNT,
AVATAR_BUBBLE_MODE_REAUTH,
};
virtual void ShowAvatarBubbleFromAvatarButton(AvatarBubbleMode mode,
diff --git a/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm b/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm
index c0273c0..fdaf601d 100644
--- a/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm
+++ b/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm
@@ -12,6 +12,7 @@
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/signin/signin_header_helper.h"
#include "chrome/browser/profiles/profiles_state.h"
+#include "chrome/browser/profiles/profile_window.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
@@ -161,21 +162,8 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver,
// |menuController_| will automatically release itself on close.
if (switches::IsNewAvatarMenu()) {
- profiles::BubbleViewMode viewMode;
- switch (mode) {
- case BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT:
- viewMode = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
- break;
- case BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN:
- viewMode = profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN;
- break;
- case BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH:
- viewMode = profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH;
- break;
- case BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT:
- viewMode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
- break;
- }
+ profiles::BubbleViewMode viewMode =
+ profiles::BubbleViewModeFromAvatarBubbleMode(mode);
menuController_ =
[[ProfileChooserController alloc] initWithBrowser:browser_
anchoredAt:point
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index b273ec9..11aa710 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -2396,23 +2396,9 @@ void BrowserView::ShowAvatarBubbleFromAvatarButton(
alignment = views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE;
}
- profiles::BubbleViewMode view_mode;
- switch (mode) {
- case AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT:
- view_mode = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
- break;
- case AVATAR_BUBBLE_MODE_SIGNIN:
- view_mode = profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN;
- break;
- case AVATAR_BUBBLE_MODE_REAUTH:
- view_mode = profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH;
- break;
- default:
- view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
- break;
- }
- ProfileChooserView::ShowBubble(view_mode, manage_accounts_params,
- anchor_view, arrow, alignment, browser());
+ ProfileChooserView::ShowBubble(
+ profiles::BubbleViewModeFromAvatarBubbleMode(mode),
+ manage_accounts_params, anchor_view, arrow, alignment, browser());
} else {
gfx::Point origin;
views::View::ConvertPointToScreen(anchor_view, &origin);
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
index f47fe27..ffc06bd 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
@@ -36,6 +36,7 @@
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/printing/printer_manager_dialog.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/account_reconcilor_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -54,9 +55,10 @@
#include "components/cloud_devices/common/cloud_device_description.h"
#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "components/cloud_devices/common/printer_description.h"
+#include "components/signin/core/browser/account_reconcilor.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
-#include "components/signin/core/browser/signin_manager_base.h"
+#include "components/signin/core/common/profile_management_switches.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
@@ -551,6 +553,7 @@ PrintPreviewHandler::PrintPreviewHandler()
manage_cloud_printers_dialog_request_count_(0),
reported_failed_preview_(false),
has_logged_printers_count_(false),
+ reconcilor_(NULL),
weak_factory_(this) {
ReportUserActionHistogram(PREVIEW_STARTED);
}
@@ -558,6 +561,8 @@ PrintPreviewHandler::PrintPreviewHandler()
PrintPreviewHandler::~PrintPreviewHandler() {
if (select_file_dialog_.get())
select_file_dialog_->ListenerDestroyed();
+
+ UnregisterForMergeSession();
}
void PrintPreviewHandler::RegisterMessages() {
@@ -621,6 +626,7 @@ void PrintPreviewHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("getPrivetPrinterCapabilities",
base::Bind(&PrintPreviewHandler::HandleGetPrivetPrinterCapabilities,
base::Unretained(this)));
+ RegisterForMergeSession();
}
bool PrintPreviewHandler::PrivetPrintingEnabled() {
@@ -1267,6 +1273,12 @@ void PrintPreviewHandler::OnPrintDialogShown() {
ClosePreviewDialog();
}
+void PrintPreviewHandler::MergeSessionCompleted(
+ const std::string& account_id,
+ const GoogleServiceAuthError& error) {
+ OnSigninComplete();
+}
+
void PrintPreviewHandler::SelectFile(const base::FilePath& default_filename) {
ui::SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.extensions.resize(1);
@@ -1587,3 +1599,18 @@ void PrintPreviewHandler::FillPrinterDescription(
}
#endif // defined(ENABLE_SERVICE_DISCOVERY)
+
+void PrintPreviewHandler::RegisterForMergeSession() {
+ DCHECK(!reconcilor_);
+ Profile* profile = Profile::FromWebUI(web_ui());
+ if (switches::IsEnableAccountConsistency() && !profile->IsOffTheRecord()) {
+ reconcilor_ = AccountReconcilorFactory::GetForProfile(profile);
+ if (reconcilor_)
+ reconcilor_->AddMergeSessionObserver(this);
+ }
+}
+
+void PrintPreviewHandler::UnregisterForMergeSession() {
+ if (reconcilor_)
+ reconcilor_->RemoveMergeSessionObserver(this);
+}
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.h b/chrome/browser/ui/webui/print_preview/print_preview_handler.h
index 3f4a48a..efc5720 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.h
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.h
@@ -13,6 +13,7 @@
#include "base/memory/weak_ptr.h"
#include "chrome/browser/printing/print_view_manager_observer.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "google_apis/gaia/merge_session_helper.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#if defined(ENABLE_SERVICE_DISCOVERY)
@@ -20,6 +21,7 @@
#include "chrome/browser/local_discovery/service_discovery_shared_client.h"
#endif // ENABLE_SERVICE_DISCOVERY
+class AccountReconcilor;
class PrintSystemTaskProxy;
namespace base {
@@ -43,7 +45,8 @@ class PrintPreviewHandler
public local_discovery::PrivetLocalPrintOperation::Delegate,
#endif
public ui::SelectFileDialog::Listener,
- public printing::PrintViewManagerObserver {
+ public printing::PrintViewManagerObserver,
+ public MergeSessionHelper::Observer {
public:
PrintPreviewHandler();
virtual ~PrintPreviewHandler();
@@ -60,6 +63,11 @@ class PrintPreviewHandler
// PrintViewManagerObserver implementation.
virtual void OnPrintDialogShown() OVERRIDE;
+ // MergeSessionHelper::Observer implementation.
+ virtual void MergeSessionCompleted(
+ const std::string& account_id,
+ const GoogleServiceAuthError& error) OVERRIDE;
+
// Displays a modal dialog, prompting the user to select a file.
void SelectFile(const base::FilePath& default_path);
@@ -271,6 +279,11 @@ class PrintPreviewHandler
base::DictionaryValue* printer_value);
#endif
+ // Register/unregister from notifications of changes done to the GAIA
+ // cookie.
+ void RegisterForMergeSession();
+ void UnregisterForMergeSession();
+
// The underlying dialog object.
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
@@ -295,6 +308,10 @@ class PrintPreviewHandler
// Holds token service to get OAuth2 access tokens.
scoped_ptr<AccessTokenService> token_service_;
+ // Pointer to reconcilor so that print preview can listen for GAIA cookie
+ // changes.
+ AccountReconcilor* reconcilor_;
+
#if defined(ENABLE_SERVICE_DISCOVERY)
scoped_refptr<local_discovery::ServiceDiscoverySharedClient>
service_discovery_client_;