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

Unified Diff: chrome/browser/ui/webui/chromeos/drive_internals_ui.cc

Issue 10808116: gdata: Add authentication status section to chrome:drive-internals (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/chromeos/drive_internals.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
diff --git a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
index 3706c2e861686d41838c780f88e06e5dc047c7ac..02f98a5de2704890fa3da9fcb8df98dbcbb1cf85 100644
--- a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
@@ -4,16 +4,73 @@
#include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h"
+#include "base/bind.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/chromeos/gdata/gdata_auth_service.h"
+#include "chrome/browser/chromeos/gdata/gdata_documents_service.h"
+#include "chrome/browser/chromeos/gdata/gdata_system_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_message_handler.h"
#include "grit/browser_resources.h"
namespace chromeos {
+namespace {
+
+// Class to handle messages from chrome://drive-internals.
+class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
+ public:
+ DriveInternalsWebUIHandler()
+ : weak_ptr_factory_(this) {
+ }
+
+ virtual ~DriveInternalsWebUIHandler() {
+ }
+
+ private:
+ // WebUIMessageHandler override.
+ virtual void RegisterMessages() OVERRIDE {
+ web_ui()->RegisterMessageCallback(
+ "pageLoaded",
+ base::Bind(&DriveInternalsWebUIHandler::OnPageLoaded,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
+
+ // Called when the page is first loaded.
+ void OnPageLoaded(const base::ListValue* args) {
+ Profile* profile = Profile::FromWebUI(web_ui());
+ gdata::GDataSystemService* system_service =
+ gdata::GDataSystemServiceFactory::GetForProfile(profile);
+ // |system_service| may be NULL in the guest/incognito mode.
achuithb 2012/07/25 00:37:00 You may want to test this. Some chrome:// pages au
+ if (!system_service)
+ return;
+
+ gdata::DocumentsServiceInterface* documents_service =
+ system_service->docs_service();
+ DCHECK(documents_service);
+
+ // Update the auth status section.
+ DictionaryValue auth_status;
+ auth_status.SetBoolean("has-fresh-token",
+ documents_service->IsFullyAuthenticated());
+ auth_status.SetBoolean("has-auth-token",
+ documents_service->IsPartiallyAuthenticated());
+ web_ui()->CallJavascriptFunction("UpdateAuthStatus", auth_status);
+ }
+
+ base::WeakPtrFactory<DriveInternalsWebUIHandler> weak_ptr_factory_;
+ DISALLOW_COPY_AND_ASSIGN(DriveInternalsWebUIHandler);
+};
+
+} // namespace
+
DriveInternalsUI::DriveInternalsUI(content::WebUI* web_ui)
: WebUIController(web_ui) {
+ web_ui->AddMessageHandler(new DriveInternalsWebUIHandler());
+
ChromeWebUIDataSource* source =
new ChromeWebUIDataSource(chrome::kChromeUIDriveInternalsHost);
source->add_resource_path("drive_internals.js", IDR_DRIVE_INTERNALS_JS);
« no previous file with comments | « chrome/browser/resources/chromeos/drive_internals.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698